Module: Services
- Defined in:
- lib/services.rb,
lib/services/entity.rb,
lib/services/member.rb,
lib/services/service.rb,
lib/services/version.rb,
lib/services/endpoint.rb,
lib/services/connection.rb
Overview
Services::Endpoint The VIP of the service. This class describes where an endpoint lives
Defined Under Namespace
Classes: Connection, Endpoint, Entity, Member, Service
Constant Summary collapse
- KEY =
this will change or be slurped up from a config/node attrib
'/services'
- VERSION =
'1.0.8'
Class Attribute Summary collapse
-
.connection ⇒ Object
Returns the value of attribute connection.
-
.run_context ⇒ Object
Returns the value of attribute run_context.
Class Method Summary collapse
-
.all ⇒ Object
return a list of all services.
-
.exists?(*args) ⇒ Boolean
proxy method to Etcd::Client.exists?.
-
.get(*args) ⇒ Object
proxy method to Etcd::Client.get.
-
.set(*args) ⇒ Object
proxy method to Etcd::Client.set.
-
.subscribed(f = nil) ⇒ Object
return all services a node is subscribed to.
Class Attribute Details
.connection ⇒ Object
Returns the value of attribute connection.
21 22 23 |
# File 'lib/services.rb', line 21 def connection @connection end |
.run_context ⇒ Object
Returns the value of attribute run_context.
21 22 23 |
# File 'lib/services.rb', line 21 def run_context @run_context end |
Class Method Details
.all ⇒ Object
return a list of all services
41 42 43 44 45 46 47 48 |
# File 'lib/services.rb', line 41 def all services = [] get(KEY).node.children.each do |s| name = File.basename s.key services << Services::Service.new(name) end services end |
.exists?(*args) ⇒ Boolean
proxy method to Etcd::Client.exists?
36 37 38 |
# File 'lib/services.rb', line 36 def exists?(*args) connection.exists?(*args) end |
.get(*args) ⇒ Object
proxy method to Etcd::Client.get
24 25 26 27 |
# File 'lib/services.rb', line 24 def get(*args) Chef::Log.debug "connection.get args #{args}" unless run_context.nil? connection.get(*args) if exists?(*args) end |
.set(*args) ⇒ Object
proxy method to Etcd::Client.set
30 31 32 33 |
# File 'lib/services.rb', line 30 def set(*args) Chef::Log.debug "connection.set args #{args}" unless run_context.nil? connection.set(*args) end |
.subscribed(f = nil) ⇒ Object
return all services a node is subscribed to
51 52 53 54 55 56 57 58 59 |
# File 'lib/services.rb', line 51 def subscribed(f = nil) fail 'param and run_context can not both be nil' if f.nil? && run_context.nil? fqdn = f.nil? ? run_context.node.fqdn : f services = [] all.each do |s| services.concat s.members.map { |m| m.name == fqdn ? s.name : nil } end services.compact end |