Skip to content

Instantly share code, notes, and snippets.

@south37
Created March 12, 2020 02:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save south37/2b1d2dbd9e4ed64529daa55731859c7b to your computer and use it in GitHub Desktop.
Save south37/2b1d2dbd9e4ed64529daa55731859c7b to your computer and use it in GitHub Desktop.
.stub_for の実装
module Servicex::Grpc
class << self
# @example
# Servicex::Grpc.stub_for(UsersPb::UserService, UsersApi.base_url)
# @param service_class [Class<Grpc::GeneralService>]
# @param url [String]
# @yield [opts] To modify options for instantiating a Stub
# @yieldparam opts [Hash] Default options
def stub_for(service_class, url)
opts = {
channel_args: {
'grpc.primary_user_agent' => Servicex.user_agent,
},
interceptors: Servicex::Grpc.client_interceptors,
}
yield opts if block_given?
service_class::Stub.new(url, :this_channel_is_insecure, opts)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment