CommandableGrpcService class abstract
Abstract service that receives commands via GRPC protocol to operations automatically generated for commands defined in ICommandable components. Each command is exposed as invoke method that receives command name and parameters.
Commandable services require only 3 lines of code to implement a robust external GRPC-based remote interface.
Configuration parameters
dependencies
:- endpoint: override for HTTP Endpoint dependency
controller
: override for Controller dependency
connection(s)
:discovery_key
: (optional) a key to retrieve the connection from IDiscoveryprotocol
: connection protocol: http or httpshost
: host name or IP addressport
: port numberuri
: resource URI or connection string with all parameters in it
References
- :logger::*:1.0 (optional) ILogger components to pass log messages
- :counters::*:1.0 (optional) ICounters components to pass collected measurements
- :discovery::*:1.0 (optional) IDiscovery services to resolve connection
- :endpoint:grpc::1.0 (optional) GrpcEndpoint reference
See CommandableGrpcClient See GrpcService
Example
class MyCommandableGrpcService extends CommandableGrpcService {
MyCommandableGrpcService():super('mydata') {
_dependencyResolver.put(
"controller",
Descriptor("mygroup","controller","*","*","1.0")
);
}
}
var service = MyCommandableGrpcService();
service.configure(ConfigParams.fromTuples([
"connection.protocol", "http",
"connection.host", "localhost",
"connection.port", 8080
]));
service.setReferences(References.fromTuples([
Descriptor("mygroup","controller","default","default","1.0"), controller
]));
await service.open("123");
print("The GRPC service is running on port 8080");
- Mixed in types
Constructors
- CommandableGrpcService(String name)
- Creates a new instance of the service.
Properties
- counters → CompositeCounters
-
The performance counters.
finalinherited
- dependencyResolver → DependencyResolver
-
The dependency resolver.
finalinherited
- endpoint ↔ GrpcEndpoint?
-
The GRPC endpoint that exposes this service.
getter/setter pairinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
- logger → CompositeLogger
-
The logger.
finalinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- serviceName ← String
-
Sets service name
no getterinherited
- tracer → CompositeTracer
-
The tracer.
finalinherited
Methods
-
close(
String? correlationId) → Future -
Closes component and frees used resources.
inherited
-
configure(
ConfigParams config) → void -
Configures component by passing configuration parameters.
inherited
-
instrument(
String? correlationId, String name) → InstrumentTiming -
Adds instrumentation to log calls and measure call time.
It returns a Timing object that is used to end the time measurement.
inherited
-
isOpen(
) → bool -
Adds instrumentation to error handling.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
open(
String? correlationId) → Future -
Opens the component.
inherited
-
register(
) → void -
Registers all service routes in gRPC endpoint.
Call automaticaly in open component procedure
override
-
registerCommadableMethod(
String method, Schema? schema, Future action(String? correlationId, Parameters args)) → void -
Registers a commandable method in this objects GRPC server (service) by the given name.,
inherited
-
registerInterceptor(
Interceptor action) → void -
Registers a middleware for methods in GRPC endpoint.
inherited
-
registerService(
Service implementation) → void -
Registers a service with related implementation
inherited
-
setReferences(
IReferences references) → void -
Sets references to dependent components.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
unsetReferences(
) → void -
Unsets (clears) previously set references to dependent components.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited