DirectClient<T> class Null safety

Abstract client that calls controller directly in the same memory space.

It is used when multiple microservices are deployed in a single container (monolyth) and communication between them can be done by direct calls rather then through the network.

Configuration parameters

  • dependencies:

References

  • \*:logger:\*:\*:1.0 (optional) ILogger components to pass log messages
  • \*:counters:\*:\*:1.0 (optional) ICounters components to pass collected measurements
  • \*:controller:\*:\*:1.0 controller to call business methods

Example

class MyDirectClient extends DirectClient<IMyController> implements IMyClient {

    public MyDirectClient(): super() {

      dependencyResolver.put('controller', Descriptor(
          "mygroup", "controller", "*", "*", "*"));
    }
    ...

    Future<MyData> getData(String? correlationId, String id) async {
      var timing = instrument(correlationId, 'myclient.get_data');
      try {
      var result = await controller.getData(correlationId, id)
      timing.endTiming();
      return result;
      } catch (err){
         timing.endTiming();
         instrumentError(correlationId, 'myclient.get_data', err, reerror=true);
      });
    }
    ...
}

var client = MyDirectClient();
client.setReferences(References.fromTuples([
     Descriptor("mygroup","controller","default","default","1.0"), controller
]));

var result = await client.getData("123", "1")
  ...
Implemented types

Constructors

DirectClient()
Creates a new instance of the client.

Properties

controller ↔ T
The controller reference.
read / write
counters CompositeCounters
The performance counters
read / write
dependencyResolver DependencyResolver
The dependency resolver to get controller reference.
read / write
hashCode int
The hash code for this object.
read-onlyinherited
logger CompositeLogger
The logger.
read / write
opened bool
The open flag.
read / write
runtimeType Type
A representation of the runtime type of the object.
read-onlyinherited
tracer CompositeTracer
The tracer.
read / write

Methods

close(String? correlationId) Future
Closes component and frees used resources.
override
configure(ConfigParams config) → void
Configures component by passing configuration parameters.
override
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.
instrumentError(String? correlationId, String name, dynamic err, [bool? reerror = false]) → void
Adds instrumentation to error handling.
isOpen() bool
Checks if the component is opened.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed.
inherited
open(String? correlationId) Future
Opens the component.
override
setReferences(IReferences references) → void
Sets references to dependent components.
override
toString() String
A string representation of this object.
inherited

Operators

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