Class: ProtoPharm::Introspection::RpcInspector
- Inherits:
-
Object
- Object
- ProtoPharm::Introspection::RpcInspector
- Defined in:
- lib/proto_pharm/introspection/rpc_inspector.rb
Instance Attribute Summary collapse
-
#endpoint_name ⇒ Object
readonly
Returns the value of attribute endpoint_name.
-
#grpc_service ⇒ Object
readonly
Returns the value of attribute grpc_service.
Instance Method Summary collapse
- #grpc_path ⇒ Object
-
#initialize(service, endpoint_name) ⇒ RpcInspector
constructor
A new instance of RpcInspector.
- #input_type ⇒ Object
- #normalize_request_proto(proto = nil, **kwargs) ⇒ Object
- #normalize_response_proto(proto = nil, **kwargs) ⇒ Object
- #normalized_rpc_name ⇒ Object
- #output_type ⇒ Object
- #rpc_desc ⇒ Object
Constructor Details
#initialize(service, endpoint_name) ⇒ RpcInspector
Returns a new instance of RpcInspector.
10 11 12 13 14 |
# File 'lib/proto_pharm/introspection/rpc_inspector.rb', line 10 def initialize(service, endpoint_name) @grpc_service = ServiceResolver.resolve(service) @endpoint_name = endpoint_name end |
Instance Attribute Details
#endpoint_name ⇒ Object (readonly)
Returns the value of attribute endpoint_name.
6 7 8 |
# File 'lib/proto_pharm/introspection/rpc_inspector.rb', line 6 def endpoint_name @endpoint_name end |
#grpc_service ⇒ Object (readonly)
Returns the value of attribute grpc_service.
6 7 8 |
# File 'lib/proto_pharm/introspection/rpc_inspector.rb', line 6 def grpc_service @grpc_service end |
Instance Method Details
#grpc_path ⇒ Object
34 35 36 |
# File 'lib/proto_pharm/introspection/rpc_inspector.rb', line 34 def grpc_path @grpc_path ||= "/#{service_name}/#{normalized_rpc_name}" end |
#input_type ⇒ Object
38 39 40 |
# File 'lib/proto_pharm/introspection/rpc_inspector.rb', line 38 def input_type rpc_desc.input end |
#normalize_request_proto(proto = nil, **kwargs) ⇒ Object
16 17 18 |
# File 'lib/proto_pharm/introspection/rpc_inspector.rb', line 16 def normalize_request_proto(proto = nil, **kwargs) cast_proto(input_type, proto, **kwargs) end |
#normalize_response_proto(proto = nil, **kwargs) ⇒ Object
20 21 22 |
# File 'lib/proto_pharm/introspection/rpc_inspector.rb', line 20 def normalize_response_proto(proto = nil, **kwargs) cast_proto(output_type, proto, **kwargs) end |
#normalized_rpc_name ⇒ Object
24 25 26 |
# File 'lib/proto_pharm/introspection/rpc_inspector.rb', line 24 def normalized_rpc_name @normalized_rpc_name ||= endpoint_name.to_s.camelize.to_sym end |
#output_type ⇒ Object
42 43 44 |
# File 'lib/proto_pharm/introspection/rpc_inspector.rb', line 42 def output_type rpc_desc.output end |
#rpc_desc ⇒ Object
28 29 30 31 32 |
# File 'lib/proto_pharm/introspection/rpc_inspector.rb', line 28 def rpc_desc @rpc_desc ||= rpc_descs[normalized_rpc_name].tap do |endpoint| raise RpcNotFoundError, "Service #{service_name} does not implement '#{normalized_rpc_name}'" if endpoint.blank? end end |