Skip to content

Commit

Permalink
pass client_options all the way down
Browse files Browse the repository at this point in the history
  • Loading branch information
t0ch1k committed Nov 19, 2023
1 parent bcdeee8 commit 584ba1b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions lib/etcdv3.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ def initialize(**options)
*sanitized_endpoints,
@namespace,
@options.fetch(:allow_reconnect, true),
@options.fetch(:client_options, {}),
)
warn "WARNING: `url` is deprecated. Please use `endpoints` instead." if @options.key?(:url)
authenticate(@options[:user], @options[:password]) if @options.key?(:user)
Expand Down
3 changes: 3 additions & 0 deletions lib/etcdv3/connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def initialize(url, timeout, namespace, metadata={})
@namespace = namespace
@credentials = resolve_credentials
@timeout = timeout
@client_options = metadata[:client_options]
@handlers = handler_map(metadata)
end

Expand All @@ -44,6 +45,8 @@ def refresh_metadata(metadata)
private

def handler_map(metadata={})
metadata = metadata.merge(client_options: @client_options) if @client_options

handlers = Hash[
HANDLERS.map do |key, klass|
[key, klass.new(@hostname, @credentials, @timeout, metadata)]
Expand Down
4 changes: 2 additions & 2 deletions lib/etcdv3/connection_wrapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ class ConnectionWrapper

attr_accessor :connection, :endpoints, :user, :password, :token, :timeout

def initialize(timeout, *endpoints, namespace, allow_reconnect)
def initialize(timeout, *endpoints, namespace, allow_reconnect, **client_options)
@user, @password, @token = nil, nil, nil
@timeout = timeout
@namespace = namespace
@endpoints = endpoints.map{|endpoint| Etcdv3::Connection.new(endpoint, @timeout, @namespace) }
@endpoints = endpoints.map{|endpoint| Etcdv3::Connection.new(endpoint, @timeout, @namespace, client_options: client_options) }
@allow_reconnect = allow_reconnect
@connection = @endpoints.first
end
Expand Down

0 comments on commit 584ba1b

Please sign in to comment.