Class: Async::GRPC::Service
- Inherits:
-
Object
- Object
- Async::GRPC::Service
- Defined in:
- lib/async/grpc/service.rb
Overview
Represents a concrete service implementation that uses an Interface. Subclass this and implement the RPC methods defined in the interface. Services are registered with Dispatcher for routing.
Instance Attribute Summary collapse
-
#interface_class ⇒ Object
readonly
Returns the value of attribute interface_class.
-
#service_name ⇒ Object
readonly
Returns the value of attribute service_name.
- #The service name.(servicename.) ⇒ Object readonly
Instance Method Summary collapse
-
#initialize(interface_class, service_name) ⇒ Service
constructor
Initialize a new service instance.
-
#rpc_descriptions ⇒ Object
Get RPC descriptions from the interface class.
- #The interface class.=(interface) ⇒ Object
Constructor Details
#initialize(interface_class, service_name) ⇒ Service
Initialize a new service instance.
42 43 44 45 |
# File 'lib/async/grpc/service.rb', line 42 def initialize(interface_class, service_name) @interface_class = interface_class @service_name = service_name end |
Instance Attribute Details
#interface_class ⇒ Object (readonly)
Returns the value of attribute interface_class.
48 49 50 |
# File 'lib/async/grpc/service.rb', line 48 def interface_class @interface_class end |
#service_name ⇒ Object (readonly)
Returns the value of attribute service_name.
51 52 53 |
# File 'lib/async/grpc/service.rb', line 51 def service_name @service_name end |
#The service name.(servicename.) ⇒ Object (readonly)
51 |
# File 'lib/async/grpc/service.rb', line 51 attr_reader :service_name |
Instance Method Details
#rpc_descriptions ⇒ Object
Get RPC descriptions from the interface class. Converts Interface RPC definitions (PascalCase) to rpc_descriptions format. Maps gRPC method names (PascalCase) to Ruby method names (snake_case).
57 58 59 60 61 62 63 64 65 66 |
# File 'lib/async/grpc/service.rb', line 57 def rpc_descriptions descriptions = {} @interface_class.rpcs.each do |pascal_case_name, rpc| # rpc.method is always set (either explicitly or auto-converted in Interface.rpc) descriptions[pascal_case_name.to_s] = rpc end descriptions end |
#The interface class.=(interface) ⇒ Object
48 |
# File 'lib/async/grpc/service.rb', line 48 attr_reader :interface_class |