Hi,

There is an example of using the "channel_override" for stub creation in 
these tests: 
https://github.com/grpc/grpc/blob/master/src/ruby/spec/generic/rpc_server_spec.rb#L318.
And a brief example of creating a GRPC::Core::Channel with credentials is 
in https://github.com/grpc/grpc/blob/master/src/ruby/spec/channel_spec.rb#L86. 
What you have posted here looks like it should work.

See 
https://github.com/grpc/grpc/blob/master/src/ruby/ext/grpc/rb_channel_credentials.c#L139
 
and https://github.com/grpc/grpc/blob/master/include/grpc/grpc_security.h#L156 
for more details on the secure ChannelCredentials constructor params.

I would indeed recommend sharing the same channel across multiple channels 
as a way to reduce resource usage and make fewer connections. If you are 
seeing problems when sharing the same channel across the same stub, I would 
recommend reporting the problem or filing an issue, as this kind of use of 
the "channel_override" parameter should work.

thanks


On Tuesday, September 19, 2017 at 11:10:46 AM UTC-7, Jason Liu wrote:
>
> Hey everyone,
>
> Looking through the gRPC ruby guide, I noticed that the channel isn't 
> created separately from the Stub like in other examples (such as Java). 
> After digging into gRPC, I found that the ClientStub takes a 
> channel_override parameter 
> <https://github.com/grpc/grpc/blob/aafa875cb389140cf721d8470a3a05cf930f74b2/src/ruby/lib/grpc/generic/client_stub.rb#L64-L66>,
>  
> which may allow us to share channels across many stubs.
>
> 1. How do I properly instantiate a GRPC::Core::Channel object? The 
> documentation for this pattern doesn't exist. I've currently got something 
> like:
>
> ssl_creds = GRPC::Core::ChannelCredentials.new("ca_file_path")
> grpc_channel = GRPC::Core::Channel.new("url", {}, ssl_creds)
> client = MyService::Stub.new("url", nil, :channel_override => grpc_channel)
>
>
> Also, 
> 2. Is sharing channels in gRPC ruby recommended? An older discussion here 
> <https://groups.google.com/forum/#!searchin/grpc-io/sharing$20channels%7Csort:relevance/grpc-io/jc-cZak29V4/At25yF4-AAAJ>
>  recommends 
> it, but I found a commit here on gitlab 
> <https://gitlab.com/gitlab-org/gitlab-ce/commit/4ea02bf88a2e2271878ffef5998d9414e82a8f44>,
>  
> which suggests that many stubs sharing a single channel may not be stable.
>
>
> Thanks,
> Jason
>

-- 
You received this message because you are subscribed to the Google Groups 
"grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/grpc-io.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/grpc-io/4292b2f3-afc1-4b87-b7bf-1b1e72ad24ea%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to