GrpcClient class abstract

Abstract client that calls remove endpoints using GRPC protocol.

Configuration parameters

  • connection(s):
    • discovery_key: (optional) a key to retrieve the connection from IDiscovery
    • protocol: connection protocol: http or https
    • host: host name or IP address
    • port: port number
    • uri: 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.
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.
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) → InstrumentTiming
Adds instrumentation to log calls and measure call time. It returns a Timing object that is used to end the time measurement.
isOpen() bool
Adds instrumentation to error handling.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
open(String? correlationId) Future
Opens the component.
setReferences(IReferences references) → void
Sets references to dependent components.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited