Beispiel #1
0
        public async Task SendAsync(Message message, CancellationToken cancellationToken = default)
        {
            var model = new MessageModel(message);

            await _sqs.SendMessageAsync(new SendMessageRequest
            {
                QueueUrl    = await _routerQueueUrl.Value,
                MessageBody = JsonConvert.SerializeObject(model)
            }, cancellationToken);
        }
Beispiel #2
0
        public async Task <Message> CallAsync(Message request, CancellationToken cancellationToken = default)
        {
            var requestModel = new MessageModel(request);

            var route = await GetRouteAsync(requestModel, cancellationToken);

            var response = await _lambda.InvokeAsync(new InvokeRequest
            {
                FunctionName   = route.Target,
                InvocationType = InvocationType.RequestResponse,
                Payload        = JsonConvert.SerializeObject(request)
            }, cancellationToken);

            var responseModel = DeserializeStream <MessageModel>(response.Payload);

            return(responseModel.ToMessage());
        }