Skip to content

Commit

Permalink
Allow passing additional options directly to GRPC clients (#139)
Browse files Browse the repository at this point in the history
This can be useful, for example, to configure max message size, which is now possible via
```
Etcdv3::Connection.new('http://localhost:2379', 10, nil, :client_options => { :channel_args => { GRPC::Core::Channel::MAX_MESSAGE_LENGTH => 16*1024*1024 } })
```
  • Loading branch information
fxposter authored May 10, 2023
1 parent af8d2f0 commit b946b42
Show file tree
Hide file tree
Showing 9 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion lib/etcdv3/auth.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Auth
}

def initialize(hostname, credentials, timeout, metadata = {})
@stub = Etcdserverpb::Auth::Stub.new(hostname, credentials)
@stub = Etcdserverpb::Auth::Stub.new(hostname, credentials, **metadata.delete(:client_options) || {})
@timeout = timeout
@metadata = metadata
end
Expand Down
2 changes: 1 addition & 1 deletion lib/etcdv3/kv.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class KV
include GRPC::Core::TimeConsts

def initialize(hostname, credentials, timeout, metadata={})
@stub = Etcdserverpb::KV::Stub.new(hostname, credentials)
@stub = Etcdserverpb::KV::Stub.new(hostname, credentials, **metadata.delete(:client_options) || {})
@timeout = timeout
@metadata = metadata
end
Expand Down
2 changes: 1 addition & 1 deletion lib/etcdv3/lease.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class Lease
include GRPC::Core::TimeConsts

def initialize(hostname, credentials, timeout, metadata={})
@stub = Etcdserverpb::Lease::Stub.new(hostname, credentials)
@stub = Etcdserverpb::Lease::Stub.new(hostname, credentials, **metadata.delete(:client_options) || {})
@timeout = timeout
@metadata = metadata
end
Expand Down
2 changes: 1 addition & 1 deletion lib/etcdv3/lock.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class Lock
include GRPC::Core::TimeConsts

def initialize(hostname, credentials, timeout, metadata = {})
@stub = V3lockpb::Lock::Stub.new(hostname, credentials)
@stub = V3lockpb::Lock::Stub.new(hostname, credentials, **metadata.delete(:client_options) || {})
@timeout = timeout
@metadata = metadata
end
Expand Down
2 changes: 1 addition & 1 deletion lib/etcdv3/maintenance.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Maintenance
}

def initialize(hostname, credentials, _timeout, metadata = {})
@stub = Etcdserverpb::Maintenance::Stub.new(hostname, credentials)
@stub = Etcdserverpb::Maintenance::Stub.new(hostname, credentials, **metadata.delete(:client_options) || {})
@metadata = metadata
end

Expand Down
2 changes: 1 addition & 1 deletion lib/etcdv3/namespace/kv.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class KV
include GRPC::Core::TimeConsts

def initialize(hostname, credentials, timeout, namespace, metadata={})
@stub = Etcdserverpb::KV::Stub.new(hostname, credentials)
@stub = Etcdserverpb::KV::Stub.new(hostname, credentials, **metadata.delete(:client_options) || {})
@timeout = timeout
@namespace = namespace
@metadata = metadata
Expand Down
2 changes: 1 addition & 1 deletion lib/etcdv3/namespace/lock.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class Lock
include Etcdv3::Namespace::Utilities

def initialize(hostname, credentials, timeout, namespace, metadata = {})
@stub = V3lockpb::Lock::Stub.new(hostname, credentials)
@stub = V3lockpb::Lock::Stub.new(hostname, credentials, **metadata.delete(:client_options) || {})
@timeout = timeout
@namespace = namespace
@metadata = metadata
Expand Down
2 changes: 1 addition & 1 deletion lib/etcdv3/namespace/watch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class Watch
include Etcdv3::Namespace::Utilities

def initialize(hostname, credentials, timeout, namespace, metadata = {})
@stub = Etcdserverpb::Watch::Stub.new(hostname, credentials)
@stub = Etcdserverpb::Watch::Stub.new(hostname, credentials, **metadata.delete(:client_options) || {})
@timeout = timeout
@namespace = namespace
@metadata = metadata
Expand Down
2 changes: 1 addition & 1 deletion lib/etcdv3/watch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class Watch
include GRPC::Core::TimeConsts

def initialize(hostname, credentials, timeout, metadata = {})
@stub = Etcdserverpb::Watch::Stub.new(hostname, credentials)
@stub = Etcdserverpb::Watch::Stub.new(hostname, credentials, **metadata.delete(:client_options) || {})
@timeout = timeout
@metadata = metadata
end
Expand Down

0 comments on commit b946b42

Please sign in to comment.