public override Task <BindingEventResponse> OnBindingEvent(BindingEventRequest request, ServerCallContext context) { //Message on azure storage queue might be utf8 or base64 encoded var dataUtf8 = request.Data.ToStringUtf8(); int byteswritten = 0; Span <byte> bytes = new Span <byte>(new byte[(3 * (dataUtf8.Length / 4)) - dataUtf8.Count(w => w == '=')]); Convert.TryFromBase64String(dataUtf8, bytes, out byteswritten); var fromBase64 = Encoding.UTF8.GetString(bytes); _logger.LogInformation($"Binding {request.Name} Received {dataUtf8} ({fromBase64})"); return(Task.FromResult(new BindingEventResponse())); }
public async override Task <BindingEventResponse> OnBindingEvent(BindingEventRequest request, Grpc.Core.ServerCallContext context) { if (!WorkflowExists(request.Name)) { throw new RpcException(new Status(StatusCode.InvalidArgument, $"Worflow with name {request.Name} was not found")); } var response = await ExecuteWorkflow(request.Name, request.Data); Console.WriteLine(response.Value.ToStringUtf8()); return(new BindingEventResponse() { Data = response.Value }); }
// FYI Here is the top level handler for incoming Binding Events from Dapr Binding and Trigger Components. public override Task <BindingEventResponse> OnBindingEvent(BindingEventRequest request, ServerCallContext context) { return(base.OnBindingEvent(request, context)); }