CommandableGrpcService class
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 fromIDiscovery
protocol
: 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.
final, inherited
- dependencyResolver → DependencyResolver
-
The dependency resolver.
final, inherited
- endpoint ↔ GrpcEndpoint
-
The GRPC endpoint that exposes this service.
read / write, inherited
- hashCode → int
-
The hash code for this object. [...]
read-only, inherited
- logger → CompositeLogger
-
The logger.
final, inherited
- runtimeType → Type
-
A representation of the runtime type of the object.
read-only, inherited
- serviceName ← String
-
Sets service name [...]
write-only, inherited
Methods
-
register(
) → void -
Registers all service routes in gRPC endpoint.
Call automaticaly in open component procedure
override
-
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) → Timing -
Adds instrumentation to log calls and measure call time.
It returns a Timing object that is used to end the time measurement. [...]
inherited
-
instrumentError(
String correlationId, String name, dynamic err, [ bool reerror = false ]) → void -
Adds instrumentation to error handling. [...]
inherited
-
isOpen(
) → bool -
Checks if the component is opened. [...]
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a non-existent method or property is accessed. [...]
inherited
-
open(
String correlationId) → Future -
Opens the component. [...]
inherited
-
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 -
Returns a string representation of this object.
inherited
-
unsetReferences(
) → void -
Unsets (clears) previously set references to dependent components.
inherited
Operators
-
operator ==(
dynamic other) → bool -
The equality operator. [...]
inherited