-
Notifications
You must be signed in to change notification settings - Fork 163
Using Ephemeral nodes
Ephemeral Nodes are a way, in Noah, to break out of the opinionated structure 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.
The Ephemeral Node API is unlikely to change. It essentially operates as a 512 byte key/value store.
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 add watch
a path.
Ephemeral endpoints exist under the /e
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/e/mycompany/config/decrypt
You would grab this (e.g. via Ruby) like so:
require 'open-uri'
key = open('http://localhost:5678/e/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
.