]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
modules/ketcd: added polling
authorMarek Vavruša <marek.vavrusa@nic.cz>
Thu, 7 May 2015 13:42:57 +0000 (15:42 +0200)
committerMarek Vavruša <marek.vavrusa@nic.cz>
Thu, 7 May 2015 13:42:57 +0000 (15:42 +0200)
modules/ketcd/ketcd.lua

index fed767632d6ace0ae5569c986da1b14c0a552576..5a43af086b49d077ea7186f45c80abd55a8786ae 100644 (file)
@@ -39,11 +39,17 @@ function ketcd.config(conf)
        if type(conf) == 'table' then
                for k,v in pairs(conf) do options[k] = v end
        end
+       -- create connection
        local cli, err = ketcd.Etcd.new(options)
        if err then
                error(err) 
        end
        ketcd.cli = cli
+       -- schedule recurrent polling
+       -- @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)
 end
 
 return ketcd