Exemplo n.º 1
0
        private async Task SendBatchToStream(BatchRequest request)
        {
            var items = GenerateRecords(request);
            var skip  = 0;

            for (var i = 0; i < items.Count; i += BatchSize)
            {
                var chunk        = items.Skip(skip).Take(BatchSize).ToList();
                var batchRequest = new PutRecordsRequest
                {
                    StreamName = StreamName,
                    Records    = GetStreamRecords(chunk)
                };
                var result = await _stream.PutRecordsAsync(batchRequest);

                if (result.FailedRecordCount > 0)
                {
                    LogInfo($"Failed Items: {result.FailedRecordCount}");
                }
            }

            LogInfo($"Completed. {DateTime.UtcNow}");
        }
Exemplo n.º 2
0
 public async Task FunctionHandler(BatchRequest request, ILambdaContext context)
 {
     await ComputeShards();
     await SendBatchToStream(request);
 }