CommandableGrpcClient class
Abstract client that calls commandable GRPC service.
Commandable services are generated automatically for ICommandable objects. Each command is exposed as Invoke method that receives all parameters as args.
Configuration parameters
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
options
:retries
: number of retries (default: 3)connect_timeout
: connection timeout in milliseconds (default: 10 sec)timeout
: invocation timeout in milliseconds (default: 10 sec)
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
Example
class MyCommandableGrpcClient extends CommandableGrpcClient implements IMyClient {
...
Future<MyData> getData(String? correlationId, String id) async {
var result = await callCommand(
'get_data',
correlationId,
{ 'id': id }
);
var item = MyData()
item.fromJson(result);
return item;
}
...
}
var client = MyCommandableGrpcClient();
client.configure(ConfigParams.fromTuples([
'connection.protocol', 'http',
'connection.host', 'localhost',
'connection.port', 8080
]));
var item = await client.getData('123', '1')
...
- Inheritance
-
- Object
- GrpcClient
- CommandableGrpcClient
Constructors
- CommandableGrpcClient(String name)
- Creates a new instance of the client.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
addFilterParams(
StringValueMap? params, FilterParams? filter) → StringValueMap -
AddFilterParams method are adds filter parameters (with the same name as they defined)
to invocation parameter map.
inherited
-
addPagingParams(
StringValueMap? params, PagingParams? paging) → StringValueMap -
AddPagingParams method are adds paging parameters (skip, take, total) to invocation parameter map.
inherited
-
call<
Q extends GeneratedMessage, R extends GeneratedMessage> (String method, String? correlationId, Q request, {CallOptions? options}) → ResponseFuture< R> -
Calls a remote method via GRPC protocol.
inherited
-
callCommand(
String name, String? correlationId, dynamic params) → Future - Calls a remote method via GRPC commadable protocol. The call is made via Invoke method and all parameters are sent in args object. The complete route to remote method is defined as serviceName + '.' + name.
-
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
-
setReferences(
IReferences references) → void -
Sets references to dependent components.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited