consume method

  1. @override
Future<Uint8List> consume(
  1. Context ctx,
  2. String urn,
  3. Execution exec,
  4. Uint8List inbound,
)
override

Consume the input payload. urn Actual uniform resource Domain Name. execution Service reference. inbound Input arguments. Output payload

Implementation

@override
Future<Uint8List> consume(
    Context ctx, String urn, Execution exec, Uint8List inbound) async {
  final uri = Uri.parse(ctx.getAttribute(addressKey));
  final r = await hc
      .post(Uri.https(uri.authority, '/mpc/invoke'), body: inbound, headers: {
    'mesh-urn': urn,
  }).timeout(exec.schema().timeout);
  if (r.statusCode != 200) {
    throw Status.system.err(r: '${r.statusCode}, ${r.reasonPhrase ?? ''}');
  }
  return r.bodyBytes;
}