diff options
Diffstat (limited to 'docker/netiquette/src/catalog/consul.mjs')
-rw-r--r-- | docker/netiquette/src/catalog/consul.mjs | 30 |
1 files changed, 0 insertions, 30 deletions
diff --git a/docker/netiquette/src/catalog/consul.mjs b/docker/netiquette/src/catalog/consul.mjs deleted file mode 100644 index 655c61f..0000000 --- a/docker/netiquette/src/catalog/consul.mjs +++ /dev/null @@ -1,30 +0,0 @@ -'use strict' - -let l -export default l = async (node, consul, log, notify) => { - const watch = consul.watch({ method: consul.catalog.node.services, options: {node: node}}) - - const extract_tags = data => - data ? - Object - .keys(data.Services) - .map(k => data.Services[k].Tags) - .reduce((acc, v) => [...acc, ...v], []) : - [] - - watch.on('error', err => { - console.error('error', err) - }) - - watch.on('change', async (data, res) => { - try { - const tags = extract_tags(data) - log(`[consul] new update, detected ${tags.length} tags`) - await notify(tags) - } catch(e) { - console.error('failed to notify target', e) - } - }) - - log('[consul] initialized') -} |