Etcd module
-----------
+The module connects to Etcd peers and watches for configuration change.
+By default, the module looks for the subtree under ``/kresolved`` directory,
+but you can change this `in the configuration <https://github.com/mah0x211/lua-etcd#cli-err--etcdnew-optiontable->`_.
+
+The subtree structure corresponds to the configuration variables in the declarative style.
+
+.. code-block::
+
+ $ etcdctl set /kresolved/net/127.0.0.1 53
+ $ etcdctl set /kresolved/modules/cachectl true
+ $ etcdctl set /kresolved/cache/size 10000000
+
+Configures all listening nodes to following configuration:
+
+.. code-block:: lua
+
+ net = { '127.0.0.1' }
+ modules = { 'cachectl' }
+ cache.size = 10000000
+
+Example configuration
+^^^^^^^^^^^^^^^^^^^^^
+
+.. code-block:: lua
+
+ modules = {
+ ketcd = {
+ prefix = '/kresolved',
+ peer = 'http://127.0.0.1:7001'
+ }
+ }
+
.. warning:: Work in progress!
Dependencies
update_subtree(k.nodes)
else
local key,opt = k.key:gmatch('([^/]+)/([^/]+)$')()
- eval_cmd(key..'='..'{'..opt..'='..k.value..'}')
+ if _G[key][opt] ~= k.value then
+ _G[key][opt] = k.value
+ end
end
end
end
-- @function reload whole configuration
-function ketcd.reload()
+local function reload()
local res, err = ketcd.cli:readdir('/', true)
if err then
error(err)
-- @todo: the etcd has watch() API, but this requires
-- coroutines on socket operations
if ketcd.ev then event.cancel(ketcd.ev) end
- ketcd.ev = event.recurrent(5 * sec, ketcd.reload)
+ ketcd.ev = event.recurrent(5 * sec, reload)
end
return ketcd