-
Notifications
You must be signed in to change notification settings - Fork 164
Using Ephemeral nodes
Ephemeral Nodes are a way, in Noah, to break out of the opinionated primitives of Host/Service and Application/Configuration.
Combined with the Watcher callback feature, ephemeral nodes are a great way to have your infrastructure be self-aware. Think of it like a RESTish key/value store with triggers.
The Ephemeral Node API is unlikely to change except for the addition of an optional TTL value.
There's no method for browsing ephemeral nodes. This is by design. You can only GET
a path that you know, PUT
to a path, DELETE
a path or watch
/tag
/link
a path.
Ephemeral endpoints exist under the /ephemerals
namespace. Anything beyond that is part of the node path. Again, the path is entirely arbitrary.
The only limitation is that the size of the data at the endpoint is 512 bytes or less. GET
requests will return the data as application/octet-stream
. If you require content-aware values, you are encouraged to use the Configuration API endpoint which understands a few types such as JSON or Yaml and returns the appropriate mime-type.
The following example shows storing a shared key that is used by multiple sources.
curl -XPUT -d"reallylongsharedkeyhere" http://localhost:5678/ephemerals/mycompany/config/decrypt
You would grab this (e.g. via Ruby) like so:
require 'open-uri'
key = open('http://localhost:5678/ephemerals/mycompany/config/decrypt').read
# Do something with key
Any part of your infrastructure (cronjob/shell script/application) that needs access to that value can access it at that URL.
See Registering Watchers for more information. Watches on ephemeral nodes can be created in the same way, by calling /watch
and passing and endpoint.
The path structure is entirely arbitrary. Nothing prevents you from assigning data at a path element above or below an existing entry. For instance, you might want to store a list of chidren under a given key:
curl -XPUT -d'{"children":["decrypt"]}' http://localhost:5678/e/mycompany/config
Calling GET
on /e/mycompany/config
will return {"children":["decrypt"]}
, while calling GET
on /e/mycompany/config/decrypt
will return reallylongsharedkeyhere
.