Skip to content

Commit b946b42

Browse files
authored
Allow passing additional options directly to GRPC clients (#139)
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 } }) ```
1 parent af8d2f0 commit b946b42

9 files changed

Lines changed: 9 additions & 9 deletions

File tree

lib/etcdv3/auth.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class Auth
1010
}
1111

1212
def initialize(hostname, credentials, timeout, metadata = {})
13-
@stub = Etcdserverpb::Auth::Stub.new(hostname, credentials)
13+
@stub = Etcdserverpb::Auth::Stub.new(hostname, credentials, **metadata.delete(:client_options) || {})
1414
@timeout = timeout
1515
@metadata = metadata
1616
end

lib/etcdv3/kv.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ class KV
55
include GRPC::Core::TimeConsts
66

77
def initialize(hostname, credentials, timeout, metadata={})
8-
@stub = Etcdserverpb::KV::Stub.new(hostname, credentials)
8+
@stub = Etcdserverpb::KV::Stub.new(hostname, credentials, **metadata.delete(:client_options) || {})
99
@timeout = timeout
1010
@metadata = metadata
1111
end

lib/etcdv3/lease.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ class Lease
33
include GRPC::Core::TimeConsts
44

55
def initialize(hostname, credentials, timeout, metadata={})
6-
@stub = Etcdserverpb::Lease::Stub.new(hostname, credentials)
6+
@stub = Etcdserverpb::Lease::Stub.new(hostname, credentials, **metadata.delete(:client_options) || {})
77
@timeout = timeout
88
@metadata = metadata
99
end

lib/etcdv3/lock.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ class Lock
33
include GRPC::Core::TimeConsts
44

55
def initialize(hostname, credentials, timeout, metadata = {})
6-
@stub = V3lockpb::Lock::Stub.new(hostname, credentials)
6+
@stub = V3lockpb::Lock::Stub.new(hostname, credentials, **metadata.delete(:client_options) || {})
77
@timeout = timeout
88
@metadata = metadata
99
end

lib/etcdv3/maintenance.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class Maintenance
1313
}
1414

1515
def initialize(hostname, credentials, _timeout, metadata = {})
16-
@stub = Etcdserverpb::Maintenance::Stub.new(hostname, credentials)
16+
@stub = Etcdserverpb::Maintenance::Stub.new(hostname, credentials, **metadata.delete(:client_options) || {})
1717
@metadata = metadata
1818
end
1919

lib/etcdv3/namespace/kv.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ class KV
55
include GRPC::Core::TimeConsts
66

77
def initialize(hostname, credentials, timeout, namespace, metadata={})
8-
@stub = Etcdserverpb::KV::Stub.new(hostname, credentials)
8+
@stub = Etcdserverpb::KV::Stub.new(hostname, credentials, **metadata.delete(:client_options) || {})
99
@timeout = timeout
1010
@namespace = namespace
1111
@metadata = metadata

lib/etcdv3/namespace/lock.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ class Lock
44
include Etcdv3::Namespace::Utilities
55

66
def initialize(hostname, credentials, timeout, namespace, metadata = {})
7-
@stub = V3lockpb::Lock::Stub.new(hostname, credentials)
7+
@stub = V3lockpb::Lock::Stub.new(hostname, credentials, **metadata.delete(:client_options) || {})
88
@timeout = timeout
99
@namespace = namespace
1010
@metadata = metadata

lib/etcdv3/namespace/watch.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ class Watch
44
include Etcdv3::Namespace::Utilities
55

66
def initialize(hostname, credentials, timeout, namespace, metadata = {})
7-
@stub = Etcdserverpb::Watch::Stub.new(hostname, credentials)
7+
@stub = Etcdserverpb::Watch::Stub.new(hostname, credentials, **metadata.delete(:client_options) || {})
88
@timeout = timeout
99
@namespace = namespace
1010
@metadata = metadata

lib/etcdv3/watch.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ class Watch
33
include GRPC::Core::TimeConsts
44

55
def initialize(hostname, credentials, timeout, metadata = {})
6-
@stub = Etcdserverpb::Watch::Stub.new(hostname, credentials)
6+
@stub = Etcdserverpb::Watch::Stub.new(hostname, credentials, **metadata.delete(:client_options) || {})
77
@timeout = timeout
88
@metadata = metadata
99
end

0 commit comments

Comments
 (0)