0.0
No commit activity in last 3 years
No release in over 3 years
Sync remote services into consul
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

 Project Readme

Sync remote services into consul

  • cleaned up removed
  • updates changed
  • adds new

Install

gem install consul_syncer

Usage

# address = ENV.fetch("CONSUL_HTTP_ADDR") # prefer using standard consul env var
address = 'http://localhost:8500'
syncer = ConsulSyncer.new(address, logger: Logger.new(STDOUT))
syncer.sync(
  [
    {node: 'N', address: 'A', service: 'S', service_id: 'ID', service_address: 'A', port: 123, tags: ['abc']},
    # ...
  ], 
  ['managed-by-consul-syncer']
)

When fetching the service itself works, but getting additional info like tags fails keep: true can be added to the definition to make it not update/remove the service. This can be useful when tags come from the actual services metadata but the service is in trouble somehow.

To identify the origin of consul requests or send other information along, use params. They will get logged in consuls log consul monitor --log-level=debug and will tell others who made updates.

ConsulSyncer.new('http://localhost:8500', logger: Logger.new(STDOUT), params: {host: Socket.gethostname, app: 'consul-filler'})

Spliting planning and execution to for example add confirmation or inspect the changes.

plan = syncer.plan(...)
puts "Planned #{plan.size} changes"
syncer.execute plan

Author

Michael Grosser
michael@grosser.it
License: MIT
Build Status