Class: Synapse::ConfigGenerator::BaseGenerator

Inherits:
Object
  • Object
show all
Includes:
Logging
Defined in:
lib/synapse/config_generator/base.rb

Direct Known Subclasses

FileOutput, Haproxy

Constant Summary collapse

NAME =
'base'.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Logging

configure_logger_for, #log, logger_for

Constructor Details

#initialize(opts = {}) ⇒ BaseGenerator

Returns a new instance of BaseGenerator.



11
12
13
# File 'lib/synapse/config_generator/base.rb', line 11

def initialize(opts={})
  @opts = opts
end

Instance Attribute Details

#optsObject (readonly)

Returns the value of attribute opts.



9
10
11
# File 'lib/synapse/config_generator/base.rb', line 9

def opts
  @opts
end

Instance Method Details

#nameObject

Exposes NAME as ‘name’ so we can remain consistent with how we refer to service_watchers’ by generator.name access (instead of generator.class::NAME) even though the names of generators don’t change



18
19
20
# File 'lib/synapse/config_generator/base.rb', line 18

def name
  self.class::NAME
end

#normalize_watcher_provided_config(service_watcher_name, service_watcher_config) ⇒ Object

Service watchers have a subsection of their “services“ entry that is dedicated to the watcher specific configuration for how to configure the config generator. This method will be called with each of these watcher hashes, and should normalize them to what the config generator needs, such as adding defaults. Return the properly populated default hash



39
40
41
# File 'lib/synapse/config_generator/base.rb', line 39

def normalize_watcher_provided_config(service_watcher_name, service_watcher_config)
  service_watcher_config.dup
end

#tickObject

The synapse main loop will call this every tick of the logical clock (~1s). You can use this to intiate reloads or restarts in a rate limited fashion



31
32
# File 'lib/synapse/config_generator/base.rb', line 31

def tick
end

#update_config(watchers) ⇒ Object

The synapse main loop will call this any time watchers change, the config_generator is responsible for diffing the passed watcher state against the output configuration



25
26
# File 'lib/synapse/config_generator/base.rb', line 25

def update_config(watchers)
end