GrpcClient class
Abstract client that calls remove endpoints using GRPC protocol.
Configuration parameters
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
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
See GrpcService
See CommandableHttpService
Example
class MyGrpcClient extends GrpcClient implements IMyClient {
...
Future<MyData> getData(String correlationId, string id) async {
var timing = this.instrument(correlationId, 'myclient.get_data');
var request = MyDataRequest();
request.id = id;
var response = await call<MydataRequest,MyDataResponse>('get_data', correlationId, request)
timing.endTiming();
MyData item;
///... convert MyDataResponse to MyData
return item;
}
...
}
var client = MyGrpcClient();
client.configure(ConfigParams.fromTuples([
'connection.protocol', 'http',
'connection.host', 'localhost',
'connection.port', 8080
]));
var item = await client.getData('123', '1')
...
- Implementers
Constructors
- GrpcClient(String clientName)
Properties
- hashCode → int
-
The hash code for this object. [...]
read-only, inherited
- runtimeType → Type
-
A representation of the runtime type of the object.
read-only, inherited
Methods
-
addFilterParams(
StringValueMap params, FilterParams filter) → StringValueMap - AddFilterParams method are adds filter parameters (with the same name as they defined) to invocation parameter map. [...]
-
addPagingParams(
StringValueMap params, PagingParams paging) → StringValueMap - AddPagingParams method are adds paging parameters (skip, take, total) to invocation parameter map. [...]
-
call<
Q extends GeneratedMessage, R extends GeneratedMessage> (String method, String correlationId, Q request, { CallOptions options }) → ResponseFuture< R> - Calls a remote method via GRPC protocol. [...]
-
close(
String correlationId) → Future - Closes component and frees used resources. [...]
-
configure(
ConfigParams config) → void - Configures component by passing configuration parameters. [...]
-
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. [...]
-
instrumentError(
String correlationId, String name, dynamic err, [ bool reerror = false ]) → void - Adds instrumentation to error handling. [...]
-
isOpen(
) → bool - Checks if the component is opened. [...]
-
open(
String correlationId) → Future - Opens the component. [...]
-
setReferences(
IReferences references) → void - Sets references to dependent components. [...]
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a non-existent method or property is accessed. [...]
inherited
-
toString(
) → String -
Returns a string representation of this object.
inherited
Operators
-
operator ==(
dynamic other) → bool -
The equality operator. [...]
inherited