Class: Synapse::ZookeeperAuroraWatcher

Inherits:
ZookeeperWatcher show all
Defined in:
lib/synapse/service_watcher/zookeeper_aurora.rb

Overview

Watcher for Zookeeper announcements from Apache Aurora

Constant Summary

Constants inherited from ZookeeperWatcher

Synapse::ZookeeperWatcher::NUMBERS_RE

Constants inherited from BaseWatcher

BaseWatcher::LEADER_WARN_INTERVAL

Instance Attribute Summary

Attributes inherited from BaseWatcher

#haproxy, #name

Instance Method Summary collapse

Methods inherited from ZookeeperWatcher

#ping?, #start, #stop

Methods inherited from BaseWatcher

#backends, #initialize, #ping?, #start, #stop

Methods included from Logging

configure_logger_for, #log, logger_for

Constructor Details

This class inherits a constructor from Synapse::BaseWatcher

Instance Method Details

#deserialize_service_instance(data) ⇒ Object



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/synapse/service_watcher/zookeeper_aurora.rb', line 55

def deserialize_service_instance(data)
  log.debug 'Deserializing process data'
  decoded = JSON.parse(data)

  name = decoded['shard'].to_s ||
    fail("Instance JSON data missing 'shard' key")

  hostport = if @discovery['port_name']
               decoded['additionalEndpoints'][@discovery['port_name']] ||
                 fail("Endpoint '#{@discovery['port_name']}' not found " \
                      'in instance JSON data')
             else
               decoded['serviceEndpoint']
             end

  host = hostport['host'] || fail("Instance JSON data missing 'host' key")
  port = hostport['port'] || fail("Instance JSON data missing 'port' key")

  [host, port, name]
end

#validate_discovery_optsObject



44
45
46
47
48
49
50
51
52
53
# File 'lib/synapse/service_watcher/zookeeper_aurora.rb', line 44

def validate_discovery_opts
  @discovery['method'] == 'zookeeper_aurora' ||
    fail(ArgumentError,
         "Invalid discovery method: #{@discovery['method']}")
  @discovery['hosts'] ||
    fail(ArgumentError,
         "Missing or invalid zookeeper host for service #{@name}")
  @discovery['path'] ||
    fail(ArgumentError, "Invalid zookeeper path for service #{@name}")
end