callCommand method

Future callCommand(
  1. String name,
  2. String? correlationId,
  3. dynamic params
)

Calls a remote method via HTTP commadable protocol. The call is made via POST operation and all parameters are sent in body object. The complete route to remote method is defined as baseRoute + "/" + name.

  • name a name of the command to call.
  • correlationId (optional) transaction id to trace execution through call chain.
  • params command parameters. Return Future that receives result or error.

Implementation

Future callCommand(String name, String? correlationId, params) async {
  var timing = instrument(correlationId, (baseRoute ?? '') + '.' + name);

  try {
    var response = await call('post', name, correlationId, {}, params ?? {});
    timing.endTiming();
    return response;
  } catch (err) {
    timing.endTiming();
    instrumentError(correlationId, (baseRoute ?? '') + '.' + name, err, true);
  }
}