request<T> method
Future
request<T>(
- EventKey<
T> key, - T data, {
- Map<
String, String> ? arguments, - Duration? timeout,
- CancelToken? cancelToken,
- String? correlationId,
inherited
Sends a request on an exact typed key and waits for the handler result.
Implementation
@override
Future<dynamic> request<T>(EventKey<T> key, T data,
{Map<String, String>? arguments,
Duration? timeout,
CancelToken? cancelToken,
String? correlationId}) async {
_checkNotDisposed();
if (cancelToken?.isCancelled ?? false) {
if (_metricsEnabled) {
metrics.recordRequestStarted(key.address.value);
metrics.recordRequestOutcome(
key.address.value, RequestOutcome.canceled, 0);
}
throw RequestCanceledException(key.address.value);
}
final dto = EventDTO<T>.withKey(key, data,
arguments: arguments, correlationId: correlationId);
return _dispatchRequest(
dto,
incoming: false,
timeout: timeout,
cancelToken: cancelToken,
onAccepted: () => _sendNode<T>(key),
);
}