Class: Etcdv3::Connection
- Inherits:
-
Object
- Object
- Etcdv3::Connection
- Defined in:
- lib/etcdv3/connection.rb
Constant Summary collapse
- HANDLERS =
{ auth: Etcdv3::Auth, kv: Etcdv3::KV, maintenance: Etcdv3::Maintenance, lease: Etcdv3::Lease, watch: Etcdv3::Watch }
Instance Attribute Summary collapse
-
#credentials ⇒ Object
readonly
Returns the value of attribute credentials.
-
#endpoint ⇒ Object
readonly
Returns the value of attribute endpoint.
-
#handlers ⇒ Object
readonly
Returns the value of attribute handlers.
-
#hostname ⇒ Object
readonly
Returns the value of attribute hostname.
Instance Method Summary collapse
- #call(stub, method, method_args = []) ⇒ Object
-
#initialize(url, timeout, metadata = {}) ⇒ Connection
constructor
A new instance of Connection.
- #refresh_metadata(metadata) ⇒ Object
Constructor Details
#initialize(url, timeout, metadata = {}) ⇒ Connection
Returns a new instance of Connection.
14 15 16 17 18 19 20 |
# File 'lib/etcdv3/connection.rb', line 14 def initialize(url, timeout, ={}) @endpoint = URI(url) @hostname = "#{@endpoint.hostname}:#{@endpoint.port}" @credentials = resolve_credentials @timeout = timeout @handlers = handler_map() end |
Instance Attribute Details
#credentials ⇒ Object (readonly)
Returns the value of attribute credentials.
12 13 14 |
# File 'lib/etcdv3/connection.rb', line 12 def credentials @credentials end |
#endpoint ⇒ Object (readonly)
Returns the value of attribute endpoint.
12 13 14 |
# File 'lib/etcdv3/connection.rb', line 12 def endpoint @endpoint end |
#handlers ⇒ Object (readonly)
Returns the value of attribute handlers.
12 13 14 |
# File 'lib/etcdv3/connection.rb', line 12 def handlers @handlers end |
#hostname ⇒ Object (readonly)
Returns the value of attribute hostname.
12 13 14 |
# File 'lib/etcdv3/connection.rb', line 12 def hostname @hostname end |
Instance Method Details
#call(stub, method, method_args = []) ⇒ Object
22 23 24 |
# File 'lib/etcdv3/connection.rb', line 22 def call(stub, method, method_args=[]) @handlers.fetch(stub).send(method, *method_args) end |
#refresh_metadata(metadata) ⇒ Object
26 27 28 |
# File 'lib/etcdv3/connection.rb', line 26 def () @handlers = handler_map() end |