invoke method
Run the Runtime in loop and digest events that are fetched from the AWS Lambda API Interface. The events are processed sequentially and are fetched from the AWS Lambda API Interface.
If the invocation of an event was successful the function
sends the InvocationResult via _client.postInvocationResponse(result) to the API.
If there is an error during the execution. The exception gets caught
and the error is posted via _client.postInvocationError(err) to the API.
Implementation
@override
void invoke() async {
if (_invocations.isEmpty) return;
final invocation = _invocations.removeFirst();
final context = invocation.context;
final callback = invocation.callback;
final func = _handlers[context.handler];
if (func == null) {
return callback.completeError(
RuntimeException(
'No handler with name "${context.handler}" registered in runtime!',
),
);
}
final json = invocation.eventJson;
final dynamic event = Event.fromHandler<dynamic>(func.type, json);
final dynamic result = await func.handler(context, event);
callback.complete(result);
}