Class: Etcdv3::Connection

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#credentialsObject (readonly)

Returns the value of attribute credentials.



12
13
14
# File 'lib/etcdv3/connection.rb', line 12

def credentials
  @credentials
end

#endpointObject (readonly)

Returns the value of attribute endpoint.



12
13
14
# File 'lib/etcdv3/connection.rb', line 12

def endpoint
  @endpoint
end

#handlersObject (readonly)

Returns the value of attribute handlers.



12
13
14
# File 'lib/etcdv3/connection.rb', line 12

def handlers
  @handlers
end

#hostnameObject (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