public async Task <IActionResult> SignUp([FromBody] SignUpUserCommand command) { var result = await _dispatcher.DispatchAsync(command); if (result.Succeeded) { return(Ok(result)); } else { return(BadRequest(result)); } }
public async Task <APIGatewayProxyResponse> ApiGatewayProxyInvocation(APIGatewayProxyRequest apiGatewayProxyRequest, ILambdaContext context) { var targetVerbosity = Verbosity.Silent; if (apiGatewayProxyRequest.StageVariables.ContainsKey("verbosity")) { Enum.TryParse(apiGatewayProxyRequest.StageVariables["verbosity"], out targetVerbosity); } _lambdaLogger.Verbosity = targetVerbosity; _lambdaLogger.LogDebug(() => "Invoked!"); _lambdaLogger.LogDebug(() => ApiGatewayProxyHelpers.ProxyRequestToString(apiGatewayProxyRequest)); try { var restRequest = CreateRestRequest(apiGatewayProxyRequest); var restResponse = await _dispatcher.DispatchAsync(restRequest, _lambdaLogger); return(CreateApiGatewayProxyResponse(restResponse)); } catch (ArgumentException e) { return(new APIGatewayProxyResponse { Body = _payloadConverter.SerializePayload(new { errorMessage = e.Message }), StatusCode = 405 }); } }
/// <summary> /// Dispatches the specified entity /// </summary> /// <param name="dispatcher">The dispatcher in use</param> /// <param name="entity">The entity to dispatch</param> /// <param name="attributes">The attributes to send along with the message</param> /// <returns>A task that completes when the message has been acknowledged by the receiver</returns> public static Task DispatchAsync <T>(this IDispatcher <T> dispatcher, T entity, IEnumerable <KeyValuePair <string, string> > attributes) { var message = new ExtendedMessage <T> { Value = entity, Properties = attributes ?? Enumerable.Empty <KeyValuePair <string, string> >() }; return(dispatcher.DispatchAsync(message, default)); }
public static Task DispatchAsync <T>(this IDispatcher <T> dispatcher, T entity) { if (dispatcher == null) { throw new ArgumentNullException(nameof(dispatcher)); } return(dispatcher.DispatchAsync(entity, TimeSpan.Zero)); }
public async Task <string> Mediator([FromQuery] TestCommand testCommand) { var sw = Stopwatch.StartNew(); for (int i = 0; i < 1000000; i++) { await _dispatcher.DispatchAsync(testCommand); } sw.Stop(); return(sw.Elapsed.ToString()); }
protected override async Task OnCollectAsync(IDispatcher dispatcher) { var value = _counter.NextValue(); var point = new MeasurementPoint(Name) .AddTag("host", _counter.MachineName) .AddField("value", (decimal)value) .AddTimeStamp(SysTime.Now()); var measurement = new PerformanceCounterMeasurement(point); await dispatcher.DispatchAsync(measurement).ForAwait(); }
/// <summary> /// Dispatches the specified entity /// </summary> /// <param name="dispatcher">The dispatcher in use</param> /// <param name="entity">The entity to dispatch</param> /// <param name="id">The id to use for the message</param> /// <returns>A task that completes when the message has been acknowledged by the receiver</returns> public static Task DispatchAsync <T>(this IDispatcher <T> dispatcher, T entity, string id) { if (string.IsNullOrWhiteSpace(id)) { Throw.ArgumentNullException(nameof(id)); } var message = new ExtendedMessage <T> { Value = entity, Id = id }; return(dispatcher.DispatchAsync(message, default)); }
/// <summary> /// Dispatches the specified entity /// </summary> /// <param name="dispatcher">The dispatcher in use</param> /// <param name="entity">The entity to dispatch</param> /// <param name="attributes">The attributes to send along with the message</param> /// <param name="id">The id to use for the message</param> /// <returns>A task that completes when the message has been acknowledged by the receiver</returns> public static Task DispatchAsync <T>(this IDispatcher <T> dispatcher, T entity, IEnumerable <KeyValuePair <string, string> > attributes, string id) { if (string.IsNullOrWhiteSpace(id)) { Throw.ArgumentNullException(nameof(id)); } var message = new ExtendedMessage <T> { Value = entity, Properties = attributes ?? Enumerable.Empty <KeyValuePair <string, string> >(), Id = id }; return(dispatcher.DispatchAsync(message, default)); }
public HttpResponseMessage Post(SampleMeasurementRequest request) { _logger.Debug("Recieved SampleMeasurementRequest"); var point = new MeasurementPoint(request.Name) .AddTag("host", request.MachineName ?? Environment.MachineName) .AddField("value", request.Value) .AddTimeStamp(SysTime.Now()); var measurement = new WebHookMeasurement(point); _dispatcher.DispatchAsync(measurement); return(Request.CreateResponse(HttpStatusCode.Created)); }
public async Task ProcessRequest(RpcContext context) { var filterContext = _pool.Rent(); filterContext.Init(context); try { await _dispatcher.DispatchAsync(context.Request.Path, filterContext); } catch (Exception ex) { _logger.Error(ex); } finally { _pool.Recycle(filterContext); } //if (next != null) // await next(context); }
protected override async Task OnCollectAsync(IDispatcher dispatcher) { if (!_serviceNames.Any()) { return; } var services = _searcher.Get(); foreach (var service in services.Cast <ManagementObject>()) { var svcName = (string)service.GetPropertyValue("Name"); if (!_serviceNames.Contains(svcName)) { continue; } var state = service.GetPropertyValue("State") as string; var point = new MeasurementPoint(Name) .AddTag("host", _host) .AddTag("svcName", svcName) .AddTag("displayName", (string)service.GetPropertyValue("DisplayName")) .AddField("state", state) .AddField("isRunning", state != null && state.ToLower() == "running") .AddTimeStamp(SysTime.Now()); if (_includeProcessInfo) { AppendProcessInfo(service, point); } var measurement = new WinServiceStatusMeasurement(point); await dispatcher.DispatchAsync(measurement).ForAwait(); } }
public Task Update([FromBody] Update _) => dispatcher.DispatchAsync();
/// <summary> /// Dispatches the specified entity /// </summary> /// <param name="dispatcher">The dispatcher in use</param> /// <param name="message">The message to dispatch</param> /// <returns>A task that completes when the message has been acknowledged by the receiver</returns> public static Task DispatchAsync <T>(this IDispatcher <T> dispatcher, Message <T> message) => dispatcher.DispatchAsync(message, default);
/// <summary> /// Dispatches the specified entity /// </summary> /// <param name="dispatcher">The dispatcher in use</param> /// <param name="entity">The entity to dispatch</param> /// <returns>A task that completes when the message has been acknowledged by the receiver</returns> public static Task DispatchAsync <T>(this IDispatcher <T> dispatcher, T entity) => dispatcher.DispatchAsync(entity, default);
/// <summary> /// Sends the message. /// </summary> /// <param name="message">The message.</param> /// <param name="cancellationToken">The cancellation token.</param> public Task SendMessageAsync(object message, CancellationToken cancellationToken) => _dispatcher.DispatchAsync(_serviceProvider, message, cancellationToken);
public static Task DispatchAsync(this IDispatcher dispatcher, Func <Task> funcTask) => dispatcher.DispatchAsync(async() => { await funcTask().ConfigureAwait(false); return(true); });
public static Task DispatchAsync(this IDispatcher dispatcher, Action action) => dispatcher.DispatchAsync(() => { action(); return(true); });
public async Task <IHttpActionResult> Post([FromBody] DataSetRequest request) { return(Ok(await _dispatcher.DispatchAsync(request))); }
protected async Task DispatchAsync <T>(T command) where T : ICommand { await _dispatcher.DispatchAsync(command); }
public Task DispatchAsync <TAction>(TAction action, CancellationToken cancellationToken = default) where TAction : IAction { return(_dispatcher.DispatchAsync(action, cancellationToken)); }
protected async Task <Result> CommandAsync(ICommand command) { return(await _dispatcher.DispatchAsync(command)); }
public async Task DispatcherWithExecutorDispatchAsync() { var request = new AwesomeRequest(); var response = await _dispatcherWithExecutor.DispatchAsync(request, default); }
public async Task DynamicDispatcherDispatchAsync() { var request = new AwesomeRequest(); var response = await _dynamicDispatcher.DispatchAsync(request, default); }
public override Task InvokeAsync(Action workItem) { return(_dispatcher.DispatchAsync(workItem)); }
public async Task <IEnumerable <string> > GetAsync([FromQuery] TestCommand command) { return(await _dispatcher.DispatchAsync(command, HttpContext.RequestAborted)); }
public Task Update([FromBody] Update update) => dispatcher.DispatchAsync(update);