From b946b42ca90cb01d6411675a87db0c30c2bd937a Mon Sep 17 00:00:00 2001 From: Pavlo Date: Wed, 10 May 2023 16:17:33 +0300 Subject: [PATCH] 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 } }) ``` --- lib/etcdv3/auth.rb | 2 +- lib/etcdv3/kv.rb | 2 +- lib/etcdv3/lease.rb | 2 +- lib/etcdv3/lock.rb | 2 +- lib/etcdv3/maintenance.rb | 2 +- lib/etcdv3/namespace/kv.rb | 2 +- lib/etcdv3/namespace/lock.rb | 2 +- lib/etcdv3/namespace/watch.rb | 2 +- lib/etcdv3/watch.rb | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/etcdv3/auth.rb b/lib/etcdv3/auth.rb index 0167870..d8d85c7 100644 --- a/lib/etcdv3/auth.rb +++ b/lib/etcdv3/auth.rb @@ -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 diff --git a/lib/etcdv3/kv.rb b/lib/etcdv3/kv.rb index ba1ebdb..48f9d63 100644 --- a/lib/etcdv3/kv.rb +++ b/lib/etcdv3/kv.rb @@ -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 diff --git a/lib/etcdv3/lease.rb b/lib/etcdv3/lease.rb index 462c3f6..437976c 100644 --- a/lib/etcdv3/lease.rb +++ b/lib/etcdv3/lease.rb @@ -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 diff --git a/lib/etcdv3/lock.rb b/lib/etcdv3/lock.rb index ce9b36c..cb6ee81 100644 --- a/lib/etcdv3/lock.rb +++ b/lib/etcdv3/lock.rb @@ -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 diff --git a/lib/etcdv3/maintenance.rb b/lib/etcdv3/maintenance.rb index 341c452..d8cd890 100644 --- a/lib/etcdv3/maintenance.rb +++ b/lib/etcdv3/maintenance.rb @@ -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 diff --git a/lib/etcdv3/namespace/kv.rb b/lib/etcdv3/namespace/kv.rb index a6b8fb2..f9195c2 100644 --- a/lib/etcdv3/namespace/kv.rb +++ b/lib/etcdv3/namespace/kv.rb @@ -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 diff --git a/lib/etcdv3/namespace/lock.rb b/lib/etcdv3/namespace/lock.rb index 76b60f6..6822f1a 100644 --- a/lib/etcdv3/namespace/lock.rb +++ b/lib/etcdv3/namespace/lock.rb @@ -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 diff --git a/lib/etcdv3/namespace/watch.rb b/lib/etcdv3/namespace/watch.rb index 199a348..6030d0e 100644 --- a/lib/etcdv3/namespace/watch.rb +++ b/lib/etcdv3/namespace/watch.rb @@ -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 diff --git a/lib/etcdv3/watch.rb b/lib/etcdv3/watch.rb index a08691b..84fbfa9 100644 --- a/lib/etcdv3/watch.rb +++ b/lib/etcdv3/watch.rb @@ -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