Class: GrpcKit::RpcDesc
- Inherits:
-
Object
- Object
- GrpcKit::RpcDesc
- Defined in:
- lib/grpc_kit/rpc_desc.rb
Instance Method Summary collapse
- #bidi_streamer? ⇒ Boolean
-
#build_client(interceptors: []) ⇒ #invoke
Client version of rpc class.
-
#build_server(handler, interceptors: []) ⇒ #invoke
Server version of rpc class.
- #client_streamer? ⇒ Boolean
-
#initialize(name:, marshal:, unmarshal:, marshal_method:, unmarshal_method:, service_name:) ⇒ RpcDesc
constructor
A new instance of RpcDesc.
-
#path ⇒ String
Full name of path name.
- #request_response? ⇒ Boolean
-
#ruby_style_name ⇒ Symbol
Snake case name.
- #server_streamer? ⇒ Boolean
Constructor Details
#initialize(name:, marshal:, unmarshal:, marshal_method:, unmarshal_method:, service_name:) ⇒ RpcDesc
Returns a new instance of RpcDesc.
32 33 34 35 36 37 38 39 |
# File 'lib/grpc_kit/rpc_desc.rb', line 32 def initialize(name:, marshal:, unmarshal:, marshal_method:, unmarshal_method:, service_name:) @name = name @marshal = marshal @unmarshal = unmarshal @marshal_method = marshal_method @unmarshal_method = unmarshal_method @service_name = service_name end |
Instance Method Details
#bidi_streamer? ⇒ Boolean
100 101 102 |
# File 'lib/grpc_kit/rpc_desc.rb', line 100 def bidi_streamer? @marshal.is_a?(GrpcKit::Grpc::Stream) && @unmarshal.is_a?(GrpcKit::Grpc::Stream) end |
#build_client(interceptors: []) ⇒ #invoke
Returns Client version of rpc class.
60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/grpc_kit/rpc_desc.rb', line 60 def build_client(interceptors: []) inter = interceptors.empty? ? nil : client_interceptor.new(interceptors) config = GrpcKit::MethodConfig.build_for_client( path: path, ruby_style_method_name: ruby_style_name, codec: client_codec, service_name: @service_name, method_name: @name, interceptor: inter, ) client.new(config) end |
#build_server(handler, interceptors: []) ⇒ #invoke
Returns Server version of rpc class.
44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/grpc_kit/rpc_desc.rb', line 44 def build_server(handler, interceptors: []) inter = interceptors.empty? ? nil : server_interceptor.new(interceptors) config = GrpcKit::MethodConfig.build_for_server( path: path, ruby_style_method_name: ruby_style_name, codec: server_codec, service_name: @service_name, method_name: @name, interceptor: inter, ) server.new(handler, config) end |
#client_streamer? ⇒ Boolean
90 91 92 |
# File 'lib/grpc_kit/rpc_desc.rb', line 90 def client_streamer? @marshal.is_a?(GrpcKit::Grpc::Stream) && !@unmarshal.is_a?(GrpcKit::Grpc::Stream) end |
#path ⇒ String
Returns Full name of path name.
80 81 82 |
# File 'lib/grpc_kit/rpc_desc.rb', line 80 def path @path ||= "/#{@service_name}/#{@name}" end |
#request_response? ⇒ Boolean
85 86 87 |
# File 'lib/grpc_kit/rpc_desc.rb', line 85 def request_response? !@marshal.is_a?(GrpcKit::Grpc::Stream) && !@unmarshal.is_a?(GrpcKit::Grpc::Stream) end |
#ruby_style_name ⇒ Symbol
Returns Snake case name.
75 76 77 |
# File 'lib/grpc_kit/rpc_desc.rb', line 75 def ruby_style_name @ruby_style_name ||= to_underscore(@name).to_sym end |
#server_streamer? ⇒ Boolean
95 96 97 |
# File 'lib/grpc_kit/rpc_desc.rb', line 95 def server_streamer? !@marshal.is_a?(GrpcKit::Grpc::Stream) && @unmarshal.is_a?(GrpcKit::Grpc::Stream) end |