Class: AutoConsul::Cluster
- Inherits:
-
Object
- Object
- AutoConsul::Cluster
- Defined in:
- lib/auto-consul/cluster.rb
Defined Under Namespace
Modules: Registry
Instance Attribute Summary collapse
-
#uri_string ⇒ Object
readonly
Returns the value of attribute uri_string.
Class Method Summary collapse
Instance Method Summary collapse
- #agents ⇒ Object
-
#initialize(uri) ⇒ Cluster
constructor
A new instance of Cluster.
- #servers ⇒ Object
- #set_mode!(local_state, expiry, desired_servers = 1) ⇒ Object
Constructor Details
#initialize(uri) ⇒ Cluster
Returns a new instance of Cluster.
12 13 14 |
# File 'lib/auto-consul/cluster.rb', line 12 def initialize uri @uri_string = uri end |
Instance Attribute Details
#uri_string ⇒ Object (readonly)
Returns the value of attribute uri_string.
10 11 12 |
# File 'lib/auto-consul/cluster.rb', line 10 def uri_string @uri_string end |
Class Method Details
.get_provider_for_uri(uri_string) ⇒ Object
5 6 7 8 |
# File 'lib/auto-consul/cluster.rb', line 5 def self.get_provider_for_uri uri_string uri = URI(uri_string) Registry.supported_schemes[uri.scheme.downcase].new uri end |
Instance Method Details
#agents ⇒ Object
20 21 22 |
# File 'lib/auto-consul/cluster.rb', line 20 def agents @agents ||= self.class.get_provider_for_uri File.join(uri_string, 'agents') end |
#servers ⇒ Object
16 17 18 |
# File 'lib/auto-consul/cluster.rb', line 16 def servers @servers ||= self.class.get_provider_for_uri File.join(uri_string, 'servers') end |
#set_mode!(local_state, expiry, desired_servers = 1) ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/auto-consul/cluster.rb', line 24 def set_mode! local_state, expiry, desired_servers=1 if servers.members(expiry).size < desired_servers local_state.set_server! else local_state.set_agent! end end |