Skip to content

Commit 951fada

Browse files
committed
what
1 parent 979c293 commit 951fada

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

src/infra/docs-lambda-index-publisher/Models.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
namespace Elastic.Documentation.Lambda.LinkIndexUploader;
1010

1111
[JsonSerializable(typeof(SQSEvent))]
12+
[JsonSerializable(typeof(Amazon.Lambda.S3Events.S3Event))]
1213
[JsonSerializable(typeof(S3EventNotification))]
1314
[JsonSerializable(typeof(SQSBatchResponse))]
1415
public partial class LinkIndexUpdaterSerializerContext : JsonSerializerContext;

src/infra/docs-lambda-index-publisher/Program.cs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
return;
2525

26-
static async Task<SQSBatchResponse> Handler(SQSEvent ev, ILambdaContext context)
26+
static async Task<string> Handler(SQSEvent ev, ILambdaContext context)
2727
{
2828
var s3Client = new AmazonS3Client();
2929
var batchItemFailures = new List<SQSBatchResponse.BatchItemFailure>();
@@ -77,12 +77,13 @@ static async Task<SQSBatchResponse> Handler(SQSEvent ev, ILambdaContext context)
7777
context.Logger.LogInformation($"Successfully updated {bucketName}/{indexFile}.");
7878
context.Logger.LogInformation($"Processed {processedMessageCount} messages.");
7979
var response = new SQSBatchResponse(batchItemFailures);
80+
var jsonString = JsonSerializer.Serialize(response, LinkIndexUpdaterSerializerContext.Default.SQSBatchResponse);
8081
if (batchItemFailures.Count > 0)
8182
{
8283
context.Logger.LogInformation($"Failed to process {batchItemFailures.Count} messages. Returning them to the queue.");
83-
context.Logger.LogInformation(JsonSerializer.Serialize(response, LinkIndexUpdaterSerializerContext.Default.SQSBatchResponse));
84+
context.Logger.LogInformation(jsonString);
8485
}
85-
return response;
86+
return jsonString;
8687
}
8788
catch (Exception ex)
8889
{
@@ -98,8 +99,9 @@ static async Task<SQSBatchResponse> Handler(SQSEvent ev, ILambdaContext context)
9899
{
99100
ItemIdentifier = r.MessageId
100101
}).ToList());
101-
context.Logger.LogInformation(JsonSerializer.Serialize(response, LinkIndexUpdaterSerializerContext.Default.SQSBatchResponse));
102-
return response;
102+
var jsonString = JsonSerializer.Serialize(response, LinkIndexUpdaterSerializerContext.Default.SQSBatchResponse);
103+
context.Logger.LogInformation(jsonString);
104+
return jsonString;
103105
}
104106
}
105107

0 commit comments

Comments
 (0)