Class: Synapse::ServiceWatcher

Inherits:
Object
  • Object
show all
Defined in:
lib/synapse/service_watcher.rb

Class Method Summary collapse

Class Method Details

.create(name, opts, synapse) ⇒ Object

the method which actually dispatches watcher creation requests

Raises:

  • (ArgumentError)

21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/synapse/service_watcher.rb', line 21

def self.create(name, opts, synapse)
  opts['name'] = name

  raise ArgumentError, "Missing discovery method when trying to create watcher" \
    unless opts.has_key?('discovery') && opts['discovery'].has_key?('method')

  discovery_method = opts['discovery']['method']
  raise ArgumentError, "Invalid discovery method #{discovery_method}" \
    unless @watchers.has_key?(discovery_method)

  return @watchers[discovery_method].new(opts, synapse)
end