Class: GrpcKit::RpcDesc
- Inherits:
-
Object
- Object
- GrpcKit::RpcDesc
- Defined in:
- lib/grpc_kit/rpc_desc.rb
Instance Attribute Summary collapse
- #marshal ⇒ Class, GrpcKit::Grpc::Stream readonly
- #marshal_method ⇒ Symbol readonly
- #name ⇒ String readonly
- #service_name ⇒ String readonly
- #unmarshal ⇒ Class, GrpcKit::Grpc::Stream readonly
- #unmarshal_method ⇒ Symbol readonly
Instance Method Summary collapse
- #bidi_streamer? ⇒ Boolean
-
#build_client(interceptors: [], max_send_message_size: nil, max_receive_message_size: nil) ⇒ #invoke
Client version of rpc class.
-
#build_server(handler, interceptors: [], max_send_message_size: nil, max_receive_message_size: nil) ⇒ #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 Attribute Details
#marshal ⇒ Class, GrpcKit::Grpc::Stream (readonly)
45 46 47 |
# File 'lib/grpc_kit/rpc_desc.rb', line 45 def marshal @marshal end |
#marshal_method ⇒ Symbol (readonly)
48 49 50 |
# File 'lib/grpc_kit/rpc_desc.rb', line 48 def marshal_method @marshal_method end |
#name ⇒ String (readonly)
42 43 44 |
# File 'lib/grpc_kit/rpc_desc.rb', line 42 def name @name end |
#service_name ⇒ String (readonly)
42 43 44 |
# File 'lib/grpc_kit/rpc_desc.rb', line 42 def service_name @service_name end |
#unmarshal ⇒ Class, GrpcKit::Grpc::Stream (readonly)
45 46 47 |
# File 'lib/grpc_kit/rpc_desc.rb', line 45 def unmarshal @unmarshal end |
#unmarshal_method ⇒ Symbol (readonly)
48 49 50 |
# File 'lib/grpc_kit/rpc_desc.rb', line 48 def unmarshal_method @unmarshal_method end |
Instance Method Details
#bidi_streamer? ⇒ Boolean
117 118 119 |
# File 'lib/grpc_kit/rpc_desc.rb', line 117 def bidi_streamer? @marshal.is_a?(GrpcKit::Grpc::Stream) && @unmarshal.is_a?(GrpcKit::Grpc::Stream) end |
#build_client(interceptors: [], max_send_message_size: nil, max_receive_message_size: nil) ⇒ #invoke
Returns Client version of rpc class.
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/grpc_kit/rpc_desc.rb', line 75 def build_client(interceptors: [], max_send_message_size: nil, max_receive_message_size: nil) 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, max_receive_message_size: || GrpcKit::MAX_CLIENT_RECEIVE_MESSAGE_SIZE, max_send_message_size: || GrpcKit::MAX_CLIENT_SEND_MESSAGE_SIZE, ) client.new(config) end |
#build_server(handler, interceptors: [], max_send_message_size: nil, max_receive_message_size: nil) ⇒ #invoke
Returns Server version of rpc class.
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/grpc_kit/rpc_desc.rb', line 55 def build_server(handler, interceptors: [], max_send_message_size: nil, max_receive_message_size: nil) 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, max_receive_message_size: || GrpcKit::MAX_SERVER_RECEIVE_MESSAGE_SIZE, max_send_message_size: || GrpcKit::MAX_SERVER_SEND_MESSAGE_SIZE, ) server.new(handler, config) end |
#client_streamer? ⇒ Boolean
107 108 109 |
# File 'lib/grpc_kit/rpc_desc.rb', line 107 def client_streamer? @marshal.is_a?(GrpcKit::Grpc::Stream) && !@unmarshal.is_a?(GrpcKit::Grpc::Stream) end |
#path ⇒ String
Returns Full name of path name.
97 98 99 |
# File 'lib/grpc_kit/rpc_desc.rb', line 97 def path @path ||= "/#{@service_name}/#{@name}" end |
#request_response? ⇒ Boolean
102 103 104 |
# File 'lib/grpc_kit/rpc_desc.rb', line 102 def request_response? !@marshal.is_a?(GrpcKit::Grpc::Stream) && !@unmarshal.is_a?(GrpcKit::Grpc::Stream) end |
#ruby_style_name ⇒ Symbol
Returns Snake case name.
92 93 94 |
# File 'lib/grpc_kit/rpc_desc.rb', line 92 def ruby_style_name @ruby_style_name ||= to_underscore(@name).to_sym end |