Method: GRPC::ClientStub#initialize
- Defined in:
- src/ruby/lib/grpc/generic/client_stub.rb
#initialize(host, creds, channel_override: nil, timeout: nil, propagate_mask: nil, channel_args: {}, interceptors: []) ⇒ ClientStub
Creates a new ClientStub.
Minimally, a stub is created with the just the host of the gRPC service it wishes to access, e.g.,
my_stub = ClientStub.new(example.host.com:50505,
:this_channel_is_insecure)
If a channel_override argument is passed, it will be used as the underlying channel. Otherwise, the channel_args argument will be used to construct a new underlying channel.
There are some specific keyword args that are not used to configure the channel:
-
:channel_override
when present, this must be a pre-created GRPC::Core::Channel. If it’s present the host and arbitrary keyword arg areignored, and the RPC connection uses this channel.
-
:timeout
when present, this is the default timeout used for calls
98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'src/ruby/lib/grpc/generic/client_stub.rb', line 98 def initialize(host, creds, channel_override: nil, timeout: nil, propagate_mask: nil, channel_args: {}, interceptors: []) @ch = ClientStub.setup_channel(channel_override, host, creds, channel_args.dup) alt_host = channel_args[Core::Channel::SSL_TARGET] @host = alt_host.nil? ? host : alt_host @propagate_mask = propagate_mask @timeout = timeout.nil? ? DEFAULT_TIMEOUT : timeout @interceptors = InterceptorRegistry.new(interceptors) end |