Method: Synapse::Synapse#initialize
- Defined in:
- lib/synapse.rb
#initialize(opts = {}) ⇒ Synapse
Returns a new instance of Synapse.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/synapse.rb', line 16 def initialize(opts={}) # create the service watchers for all our services raise "specify a list of services to connect in the config" unless opts.has_key?('services') @service_watchers = create_service_watchers(opts['services']) # create objects that need to be notified of service changes @config_generators = [] # create the haproxy config generator, this is mandatory raise "haproxy config section is missing" unless opts.has_key?('haproxy') @config_generators << Haproxy.new(opts['haproxy']) # possibly create a file manifestation for services that do not # want to communicate via haproxy, e.g. cassandra if opts.has_key?('file_output') @config_generators << FileOutput.new(opts['file_output']) end # configuration is initially enabled to configure on first loop @config_updated = true # Any exceptions in the watcher threads should wake the main thread so # that we can fail fast. Thread.abort_on_exception = true log.debug "synapse: completed init" end |