consul-ruby-client 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ea81d2569729debbb271b229358775f919a0de0c
4
- data.tar.gz: 521ad0389c65a8d57ca62202faada9546d467416
3
+ metadata.gz: 16424ed2483c59320693c5fa6e98ae986c2c20c7
4
+ data.tar.gz: a2a578aefa883f5ce9da392619724479ae2f4324
5
5
  SHA512:
6
- metadata.gz: 5c86f347a8a0ca26a65a4cf825688544ce14d75d2988a6e38d78c5c4adfdb3f9f9cbfbef0ebe78dab87212220bf13bcf68a43be07f18160aa1253ceac90e7073
7
- data.tar.gz: 93e0c798a11880043e1545daa87eb84e6210af4f91f5849bd1640c0a3adbc6db127db645943f7a5ed40244bcbb65591367d05196ed177908bae3c2cc6c27546a
6
+ metadata.gz: 83ed8596afaacb62abdb09acb649093c97f36cafb1c2fd1cb0f032132bb98e5e33ad0f9db772b55755bb9d988f6dc6d9340fbb3e737a57e17d531dd85c779c99
7
+ data.tar.gz: 95222ebb6153c603f5292ffa0e2eb0710c9e3c1aaffef719adaa00336da64d36b2b6259ed7d1fc82396d42bf06831575eae359af07871808b73e18ad3b6034de
@@ -23,7 +23,7 @@ Gem::Specification.new do |spec|
23
23
  spec.add_development_dependency 'rspec', '~> 3.2'
24
24
  spec.add_development_dependency 'simplecov', '~> 0.9'
25
25
  spec.add_development_dependency 'webmock', '~> 1.21'
26
- spec.add_dependency 'rest-client', '~> 1.6'
26
+ spec.add_dependency 'rest-client', '~> 1.8'
27
27
  spec.add_dependency 'representable', '~> 2.1'
28
28
  spec.add_dependency 'json', '~> 1.8'
29
29
  end
@@ -1,4 +1,5 @@
1
1
  require_relative 'base'
2
+ require_relative '../model/agent'
2
3
  require_relative '../model/service'
3
4
  require_relative '../model/health_check'
4
5
 
@@ -6,8 +7,39 @@ require_relative '../model/health_check'
6
7
  # Represents Ruby endpoint as described here: https://www.consul.io/docs/agent/http/agent.html
7
8
  module Consul
8
9
  module Client
9
- class Agent
10
- include Consul::Client::Base
10
+ class Agent < Base
11
+
12
+ # Public: Describes the agent. It is actually the same method as /v1/agent/self
13
+ #
14
+ # Example:
15
+ # a = Agent.new
16
+ # a.describe =>
17
+ # <Consul::Model::Agent config=#<Consul::Model::Config bootstrap=true, server=true,
18
+ # datacenter="dc1", datadir="/path/to/data", dns_recursor="", dns_recursors=[],
19
+ # domain="consul.", log_level="INFO", node_name="MyComputer.local", client_addr="127.0.0.1",
20
+ # bind_addr="0.0.0.0", advertise_addr="172.19.12.106", ports={"DNS"=>8600, "HTTP"=>8500, "HTTPS"=>-1,
21
+ # "RPC"=>8400, "SerfLan"=>8301, "SerfWan"=>8302, "Server"=>8300}, leave_on_term=false,
22
+ # skip_leave_on_int=false, stat_site_addr="", protocol=2, enable_debug=false, verify_incoming=false,
23
+ # verify_outgoing=false, ca_file="", cert_file="", key_file="", start_join=[], ui_dir="", pid_file="",
24
+ # enable_syslog=false, rejoin_after_leave=false>, member=#<Consul::Model::Member name="MyComputer.local",
25
+ # addr="172.19.12.106", port=8301, tags={"bootstrap"=>"1", "build"=>"0.5.0:0c7ca91c", "dc"=>"dc1", "port"=>"8300",
26
+ # "role"=>"consul", "vsn"=>"2", "vsn_max"=>"2", "vsn_min"=>"1"}, status=1, protocol_min=1, protocol_max=2,
27
+ # protocol_cur=2, delegate_min=2, delegate_max=4, delegate_cur=4>>
28
+ # a.describe.config.node_name =>
29
+ # "MyComputer.local"
30
+ # a.describe.member.name =>
31
+ # "MyComputer.local"
32
+ #
33
+ # Return: Consul::Model::Agent instance that represents this agent.
34
+ def describe
35
+ begin
36
+ resp = _get build_agent_url('self')
37
+ rescue
38
+ logger.warn('Unable to request all the services on this through the HTTP API')
39
+ return nil
40
+ end
41
+ Consul::Model::Agent.new.extend(Consul::Model::Agent::Representer).from_json(resp)
42
+ end
11
43
 
12
44
  # Public: Returns all the services registered with this Agent.
13
45
  #
@@ -16,7 +48,7 @@ module Consul
16
48
  begin
17
49
  resp = _get build_agent_url('services')
18
50
  rescue
19
- @logger.warn('Unable to request all the services on this through the HTTP API')
51
+ logger.warn('Unable to request all the services on this through the HTTP API')
20
52
  return nil
21
53
  end
22
54
  # Consul returns id => ConsulServiceObjects.
@@ -36,7 +68,7 @@ module Consul
36
68
  begin
37
69
  resp = _get build_agent_url('checks')
38
70
  rescue
39
- @logger.warn('Unable to request all the checks on this through the HTTP API')
71
+ logger.warn('Unable to request all the checks on this through the HTTP API')
40
72
  return nil
41
73
  end
42
74
  # Consul returns id => ConsulServiceObjects.
@@ -81,11 +113,11 @@ module Consul
81
113
  entity = entity.extend(Consul::Model::Service::Representer)
82
114
  success = register_with_backoff(build_service_url('register'), entity, 0, 3)
83
115
  if success
84
- @logger.info("Successfully registered service #{entity.name}.")
116
+ logger.info("Successfully registered service #{entity.name}.")
85
117
  unless entity.check.nil?
86
118
  # Pass the first health check
87
119
  c = check("service:#{entity.name}")
88
- @logger.info("Updating status for health check #{c.check_id} to \"pass\".")
120
+ logger.info("Updating status for health check #{c.check_id} to \"pass\".")
89
121
  _get build_check_status_url(c.check_id, 'pass')
90
122
  end
91
123
  end
@@ -174,7 +206,7 @@ module Consul
174
206
  c
175
207
  end
176
208
 
177
- # Public: TTL Check
209
+ # Public: Script Check
178
210
  #
179
211
  # name - The name of the check, Cannot be nil
180
212
  # script - The script to run locally
@@ -193,7 +225,7 @@ module Consul
193
225
  c
194
226
  end
195
227
 
196
- # Public: TTL Check
228
+ # Public: HTTP Check
197
229
  #
198
230
  # name - The name of the check, Cannot be nil
199
231
  # http - The HTTP endpoint to hit with periodic GET.
@@ -287,10 +319,11 @@ module Consul
287
319
  success, _ = _put(url, entity.to_json)
288
320
  unless success # Unless we successfully registered.
289
321
  if threshold == iteration
290
- @logger.error("Unable to complete registration after #{threshold + 1} attempts")
322
+ logger.error("Unable to complete registration after #{threshold + 1} attempts")
323
+ return false
291
324
  else
292
325
  # Attempt to register again using the exponential backoff.
293
- @logger.warn("Unable to complete registration after #{iteration + 1} attempts, Retrying up to #{threshold+1} attempts")
326
+ logger.warn("Unable to complete registration after #{iteration + 1} attempts, Retrying up to #{threshold+1} attempts")
294
327
  register_with_backoff(url, entity, iteration + 1, threshold)
295
328
  end
296
329
  end
@@ -319,4 +352,4 @@ module Consul
319
352
 
320
353
  end
321
354
  end
322
- end
355
+ end
@@ -7,22 +7,22 @@ module Consul
7
7
  module Client
8
8
 
9
9
  # Public API Base.
10
- module Base
10
+ class Base
11
11
 
12
- # Public: Creates an API Endpoint
12
+ # Public: Constructor with options hash
13
13
  #
14
- # data_center - The data center to utilize, defaults to bootstrap 'dc1' datat center
15
- # api_host - The host the Consul Agent is running on. Default: 127.0.0.1
16
- # api_port - The port the Consul Agent is listening on. Default: 8500
17
- # version - The version of the api to use.
18
- # logger - Logging mechanism. Must conform to Ruby Logger interface
14
+ # Optional Parameters:
15
+ # options[:data_center] - The consul data center. Default: 'dc1'.
16
+ # options[:api_host] - The api host to request against. Default: '127.0.0.1'.
17
+ # options[:api_port] - The api port the api host is listening to. Default: '8500'.
18
+ # options[:version] - The Consul API version to use. Default: 'v1'.
19
+ # options[:logger] - The default logging mechanism. Default: Logger.new(STDOUT).
19
20
  #
20
- def initialize(data_center = 'dc1', api_host = '127.0.0.1', api_port = '8500', version = 'v1', logger = Logger.new(STDOUT))
21
- @dc = data_center
22
- @host = api_host
23
- @port = api_port
24
- @logger = logger
25
- @version = version
21
+ # Return: This instance
22
+ def initialize(options = nil)
23
+ options = {} if options.nil?
24
+ raise TypeError, 'Options must be nil or a Hash' unless options.is_a?(Hash)
25
+ @options = options.clone
26
26
  end
27
27
 
28
28
  # Public: Test if this Consul Client is reachable.
@@ -88,24 +88,28 @@ module Consul
88
88
  end
89
89
  end
90
90
 
91
+ def options
92
+ @options ||= {}
93
+ end
94
+
91
95
  def data_center
92
- @data_center ||= 'dc1'
96
+ @data_center ||= options[:data_center] || 'dc1'
93
97
  end
94
98
 
95
99
  def host
96
- @host ||= '127.0.0.1'
100
+ @host ||= options[:api_host] || '127.0.0.1'
97
101
  end
98
102
 
99
103
  def port
100
- @port ||= '8500'
104
+ @port ||= options[:api_port] || '8500'
101
105
  end
102
106
 
103
107
  def version
104
- @version ||= 'v1'
108
+ @version ||= options[:version] || 'v1'
105
109
  end
106
110
 
107
111
  def logger
108
- @logger ||= Logger.new(STDOUT)
112
+ @logger ||= options[:logger] || Logger.new(STDOUT)
109
113
  end
110
114
 
111
115
  def https
@@ -4,8 +4,7 @@ require_relative '../model/node'
4
4
  # Consul Catalog End Point.
5
5
  module Consul
6
6
  module Client
7
- class Catalog
8
- include Consul::Client::Base
7
+ class Catalog < Base
9
8
 
10
9
  # Public: Returns a list of all the nodes on this client
11
10
  #
@@ -87,8 +86,6 @@ module Consul
87
86
 
88
87
  # Public: Builds the base url
89
88
  #
90
- # Example:
91
- #
92
89
  # Returns: The base
93
90
  def build_url(suffix)
94
91
  "#{base_versioned_url}/catalog/#{suffix}"
@@ -4,30 +4,21 @@ require_relative '../model/key_value'
4
4
 
5
5
  module Consul
6
6
  module Client
7
- class KeyValue
8
- include Consul::Client::Base
7
+ class KeyValue < Base
9
8
 
10
- # Public: Creates an API Endpoint
9
+ # Public: Constructor with options hash
11
10
  #
12
- # data_center - The data center to utilize, defaults to bootstrap 'dc1' datat center
13
- # api_host - The host the Consul Agent is running on. Default: 127.0.0.1
14
- # api_port - The port the Consul Agent is listening on. Default: 8500
15
- # version - The version of the api to use.
16
- # logger - Logging mechanism. Must conform to Ruby Logger interface
11
+ # Optional Parameters:
12
+ # options[:namespace] - The KeyValue Store namespace.
13
+ # options[:data_center] - The consul data center.
14
+ # options[:api_host] - The api host to request against.
15
+ # options[:api_port] - The api port the api host is listening to.
16
+ # options[:version] - The Consul API version to use.
17
+ # options[:logger] - The default logging mechanism.
17
18
  #
18
- def initialize(name_space = '', data_center = 'dc1', api_host = '127.0.0.1', api_port = '8500', version = 'v1', logger = Logger.new(STDOUT))
19
- name_space = sanitize(name_space)
20
- name_space = "#{name_space}/" unless name_space.nil? or name_space.empty?
21
- @namespace = sanitize(name_space)
22
- @dc = data_center
23
- @host = api_host
24
- @port = api_port
25
- @logger = logger
26
- @version = version
27
- end
28
-
29
- def name_space
30
- @namespace ||= ''
19
+ # Return: This instance
20
+ def initialize(options = nil)
21
+ super(options)
31
22
  end
32
23
 
33
24
  # Public: Gets the value associated with a given key.
@@ -52,21 +43,14 @@ module Consul
52
43
  params[:index] = nil if index
53
44
  params[:keys] = nil if only_keys
54
45
  params[:separator] = separator unless separator.nil?
55
- # begin
56
- # resp = RestClient.get key_url(key), {:params => params}
57
- # rescue
58
- # # TODO need to pass more information back to the client.
59
- # logger.warn("Unable to get value for #{key}")
60
- # nil
61
- # end
62
46
  begin
63
- resp = _get key_url(key), params
47
+ resp = _get build_url(compose_key(key)), params
64
48
  rescue Exception => e
65
49
  logger.warn("Unable to get value for #{key} due to: #{e}")
66
50
  return nil
67
51
  end
68
52
  return nil if resp.code == 404
69
- json = JSON.parse(_get key_url(key), params)
53
+ json = JSON.parse(resp)
70
54
  return json if only_keys
71
55
  json.map { |kv|
72
56
  kv = Consul::Model::KeyValue.new.extend(Consul::Model::KeyValue::Representer).from_hash(kv)
@@ -105,9 +89,9 @@ module Consul
105
89
  begin
106
90
  value = JSON.generate(value)
107
91
  rescue JSON::GeneratorError
108
- @logger.debug("Using non-JSON value for key #{key}")
92
+ logger.debug("Using non-JSON value for key #{key}")
109
93
  end
110
- _put build_url(key), value, {:params => params}
94
+ _put build_url(compose_key(key)), value, {:params => params}
111
95
  end
112
96
 
113
97
  # Public: Delete the Key Value pair in consul.
@@ -123,6 +107,14 @@ module Consul
123
107
  RestClient.delete build_url(key), {:params => params}
124
108
  end
125
109
 
110
+ # Public: Returns the name space of this KeyValue Store. This allows you to
111
+ # identify what root namespace all keys will be placed under.
112
+ #
113
+ # Returns: Namespace String.
114
+ def namespace
115
+ @namespace ||= options[:namespace] || ''
116
+ end
117
+
126
118
  def build_url(suffix)
127
119
  "#{base_versioned_url}/kv/#{suffix}"
128
120
  end
@@ -130,11 +122,21 @@ module Consul
130
122
  private
131
123
 
132
124
  def sanitize(key)
133
- key.gsub(/^\//,'').gsub(/\/$/,'')
125
+ unless key.nil? or !key.respond_to?(:to_s)
126
+ key = key.to_s
127
+ while !key.empty? and key[0] == '/' do
128
+ key[0] = ''
129
+ end
130
+ while !key.empty? and key[key.length - 1] == '/' do
131
+ key[key.length - 1] = ''
132
+ end
133
+ end
134
134
  end
135
135
 
136
- def key_url(key)
137
- build_url("#{name_space}#{key}")
136
+ def compose_key(key)
137
+ ns = namespace.strip
138
+ return "#{key}" if ns.empty?
139
+ "#{ns}/#{key}"
138
140
  end
139
141
 
140
142
  end
@@ -5,8 +5,7 @@ require_relative '../util/utils'
5
5
  module Consul
6
6
  module Client
7
7
  # Consul Session Client
8
- class Session
9
- include Consul::Client::Base
8
+ class Session < Base
10
9
 
11
10
  # Public: Creates an instance of Consul::Model::Session with as many preset
12
11
  # defaults as possible.
@@ -2,8 +2,7 @@ require_relative 'base'
2
2
 
3
3
  module Consul
4
4
  module Client
5
- class Status
6
- include Consul::Client::Base
5
+ class Status < Base
7
6
 
8
7
  # Public: This endpoint is used to get the Raft leader for the
9
8
  # datacenter in which the agent is running
@@ -1,5 +1,5 @@
1
1
  module Consul
2
2
  module Client
3
- VERSION = "0.0.2"
3
+ VERSION = "0.0.3"
4
4
  end
5
5
  end
data/lib/consul/client.rb CHANGED
@@ -10,6 +10,7 @@ require_relative '../consul/client/catalog'
10
10
  require_relative '../consul/client/key_value'
11
11
  require_relative '../consul/client/session'
12
12
  require_relative '../consul/client/status'
13
+ require_relative '../consul/extensions/uid'
13
14
 
14
15
  module Consul
15
16
  module Client
@@ -0,0 +1,49 @@
1
+
2
+ module Consul
3
+ module Extensions
4
+ class Base
5
+
6
+ # Public: Constructor for this extension. Ensures a global unique ID for this client for a given namespace.
7
+ #
8
+ # options - (Optional) Hash of Consul Client and extension options.
9
+ # options[:data_center] - (Optional) The Consul data center. Default: 'dc1'.
10
+ # options[:api_host] - (Optional) The Consul api host to request against. Default: '127.0.0.1'.
11
+ # options[:api_port] - (Optional) The Consul api port the api host is listening to. Default: '8500'.
12
+ # options[:version] - (Optional) The Consul API version to use. Default: 'v1'.
13
+ # options[:logger] - (Optional) The default logging mechanism. Default: Logger.new(STDOUT).
14
+ #
15
+ # Extension instance capable of generating GUID.
16
+ def initialize(options)
17
+ options = {} if options.nil?
18
+ @options = options.clone
19
+ end
20
+
21
+ protected
22
+
23
+ # Semantically private namespace for consul-ruby-client extensions.
24
+ def extensions_namespace
25
+ '.extensions'
26
+ end
27
+
28
+ # The Consul Agent Client to use
29
+ def agent
30
+ @agent = Agent.new(options)
31
+ end
32
+
33
+ # The Key Value Store to use.
34
+ def key_value_store
35
+ @kvs = KeyValue.new(options)
36
+ end
37
+
38
+ # TODO Add other clients here.
39
+
40
+ private
41
+
42
+ def options
43
+ @options
44
+ end
45
+
46
+
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,69 @@
1
+ require_relative 'base'
2
+ require_relative '../../consul/client/key_value'
3
+
4
+ module Consul
5
+ module Extensions
6
+
7
+ # Global Unique ID Generator Extension.
8
+ #
9
+ # A utility extension that helps in syncronously and safely generating unique id.
10
+ #
11
+ class UID < Base
12
+ include Consul::Client
13
+
14
+ # Public: Constructor for this extension. Ensures a global unique ID for this client for a given namespace.
15
+ #
16
+ # options - (Required) Hash of Consul Client and extension options.
17
+ # options[:name] - (Required) The name or name space of the GUID to generate. This extension will
18
+ # generate a GUID with respect to other clients is this name space.
19
+ # options[:client_id] - (Optional) External Client ID. This is an additional semantic parameter external to consul.
20
+ # This provides the capability to unique identify your external client.
21
+ # Default: Consul Agent name. Cannot begin with "."
22
+ # options[:data_center] - (Optional) The Consul data center. Default: 'dc1'.
23
+ # options[:api_host] - (Optional) The Consul api host to request against. Default: '127.0.0.1'.
24
+ # options[:api_port] - (Optional) The Consul api port the api host is listening to. Default: '8500'.
25
+ # options[:version] - (Optional) The Consul API version to use. Default: 'v1'.
26
+ # options[:logger] - (Optional) The default logging mechanism. Default: Logger.new(STDOUT).
27
+ #
28
+ # Extension instance capable of generating GUID.
29
+ def initialize(options)
30
+ raise TypeError.new "Options must not be a Hash that contains \":name\"" unless options.is_a?(Hash)
31
+ if options.has_key?(:name) or options[:name].strip.empty?
32
+ raise ArgumentError.new "Illegal GUID Name: \"#{options[:name]}\". Must not be nil or empty"
33
+ end
34
+ raise ArgumentError.new "GUID Name cannot start with special character"
35
+ options[:namespace] = namespace
36
+ @options = options.clone
37
+ end
38
+
39
+ # Public: Generate a global unique id syncronously with other
40
+ def generate
41
+ # TODO Has the key ever been generated
42
+ # Create a Consul Session the the underlying namespace
43
+ # Get the current value for
44
+ # Set the check and set primitive
45
+ end
46
+
47
+ private
48
+
49
+ # The FQ namespace for this GUID
50
+ def namespace
51
+ @namespace ||= "#{extensions_namespace}/uid/#{@options[:name]}"
52
+ end
53
+
54
+ def available_uid
55
+ "#{namespace}/.available"
56
+ end
57
+
58
+ # The individual client id for this uid generator
59
+ def client_id
60
+ client_id = nil
61
+ unless @options[:client_id].nil? or @options[:client_id].strip.empty?
62
+ client_id = client_id.strip
63
+ end
64
+ @client_id ||= client_id || agent.describe.member.name
65
+ end
66
+
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,26 @@
1
+ require 'representable/json'
2
+ require 'ostruct'
3
+ require_relative 'config'
4
+ require_relative 'member'
5
+
6
+ module Consul
7
+ module Model
8
+ # Agent Model class
9
+ #
10
+ # Common use case Agent.self
11
+ #
12
+ # Reference: https://www.consul.io/docs/agent/http/agent.html#agent_self
13
+ #
14
+ class Agent < OpenStruct
15
+ module Representer
16
+ include Representable::JSON
17
+ include Representable::Hash
18
+ include Representable::Hash::AllowSymbols
19
+
20
+ property :config, as: :Config, extend: Consul::Model::Config::Representer, class: Consul::Model::Config
21
+ property :member, as: :Member, extend: Consul::Model::Member::Representer, class: Consul::Model::Member
22
+ end
23
+ extend Representer
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,49 @@
1
+ require 'representable/json'
2
+ require 'ostruct'
3
+
4
+ module Consul
5
+ module Model
6
+ # Consul Config Object Representation
7
+ #
8
+ # Reference: https://www.consul.io/docs/agent/http/agent.html#agent_self
9
+ #
10
+ class Config < OpenStruct
11
+ module Representer
12
+ include Representable::JSON
13
+ include Representable::Hash
14
+ include Representable::Hash::AllowSymbols
15
+
16
+ property :bootstrap, as: :Bootstrap
17
+ property :server, as: :Server
18
+ property :datacenter, as: :Datacenter
19
+ property :datadir, as: :DataDir
20
+ property :dns_recursor, as: :DNSRecursor
21
+ property :dns_recursors, as: :DNSRecursors
22
+ property :domain, as: :Domain
23
+ property :log_level, as: :LogLevel
24
+ property :node_name, as: :NodeName
25
+ property :client_addr, as: :ClientAddr
26
+ property :bind_addr, as: :BindAddr
27
+ property :advertise_addr, as: :AdvertiseAddr
28
+ property :ports, as: :Ports
29
+ property :leave_on_term, as: :LeaveOnTerm
30
+ property :skip_leave_on_int, as: :SkipLeaveOnInt
31
+ property :stat_site_addr, as: :StatsiteAddr
32
+ property :protocol, as: :Protocol
33
+ property :enable_debug, as: :EnableDebug
34
+ property :verify_incoming, as: :VerifyIncoming
35
+ property :verify_outgoing, as: :VerifyOutgoing
36
+ property :ca_file, as: :CAFile
37
+ property :cert_file, as: :CertFile
38
+ property :key_file, as: :KeyFile
39
+ property :start_join, as: :StartJoin
40
+ property :ui_dir, as: :UiDir
41
+ property :pid_file, as: :PidFile
42
+ property :enable_syslog, as: :EnableSyslog
43
+ property :rejoin_after_leave, as: :RejoinAfterLeave
44
+
45
+ end
46
+ extend Representer
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,33 @@
1
+ require 'representable/json'
2
+ require 'ostruct'
3
+
4
+ module Consul
5
+ module Model
6
+
7
+ # Consul Member representation
8
+ #
9
+ # Reference: https://www.consul.io/docs/commands/members.html
10
+ #
11
+ class Member < OpenStruct
12
+ module Representer
13
+ include Representable::JSON
14
+ include Representable::Hash
15
+ include Representable::Hash::AllowSymbols
16
+
17
+ property :name, as: :Name
18
+ property :addr, as: :Addr
19
+ property :port, as: :Port
20
+ # TODO Ensure we map tags into a ruby hash and back
21
+ property :tags, as: :Tags
22
+ property :status, as: :Status
23
+ property :protocol_min, as: :ProtocolMin
24
+ property :protocol_max, as: :ProtocolMax
25
+ property :protocol_cur, as: :ProtocolCur
26
+ property :delegate_min, as: :DelegateMin
27
+ property :delegate_max, as: :DelegateMax
28
+ property :delegate_cur, as: :DelegateCur
29
+ end
30
+ extend Representer
31
+ end
32
+ end
33
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: consul-ruby-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Hotan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-16 00:00:00.000000000 Z
11
+ date: 2015-04-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -86,14 +86,14 @@ dependencies:
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '1.6'
89
+ version: '1.8'
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '1.6'
96
+ version: '1.8'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: representable
99
99
  requirement: !ruby/object:Gem::Requirement
@@ -145,8 +145,13 @@ files:
145
145
  - lib/consul/client/session.rb
146
146
  - lib/consul/client/status.rb
147
147
  - lib/consul/client/version.rb
148
+ - lib/consul/extensions/base.rb
149
+ - lib/consul/extensions/uid.rb
150
+ - lib/consul/model/agent.rb
151
+ - lib/consul/model/config.rb
148
152
  - lib/consul/model/health_check.rb
149
153
  - lib/consul/model/key_value.rb
154
+ - lib/consul/model/member.rb
150
155
  - lib/consul/model/node.rb
151
156
  - lib/consul/model/service.rb
152
157
  - lib/consul/model/session.rb