1717const string bucketName = "elastic-docs-link-index" ;
1818const string indexFile = "link-index-test.json" ;
1919
20- await LambdaBootstrapBuilder . Create < SQSEvent > ( Handler , new SourceGeneratorLambdaJsonSerializer < LinkIndexUpdaterSerializerContext > ( ) )
20+ await LambdaBootstrapBuilder . Create < SQSEvent , SQSBatchResponse > ( Handler , new SourceGeneratorLambdaJsonSerializer < LinkIndexUpdaterSerializerContext > ( ) )
2121 . Build ( )
2222 . RunAsync ( ) ;
2323
2424return ;
2525
26- // This function should return SQSBatchResponse but for some reason
27- // it's not working as expected.
28- // The partial batch response might not be serialized correctly.
29- // However, serializing the response to JSON and returning it as string works.
30- static async Task < string > Handler ( SQSEvent ev , ILambdaContext context )
26+ static async Task < SQSBatchResponse > Handler ( SQSEvent ev , ILambdaContext context )
3127{
3228 var s3Client = new AmazonS3Client ( ) ;
3329 var batchItemFailures = new List < SQSBatchResponse . BatchItemFailure > ( ) ;
@@ -87,7 +83,8 @@ static async Task<string> Handler(SQSEvent ev, ILambdaContext context)
8783 context . Logger . LogInformation ( $ "Failed to process { batchItemFailures . Count } messages. Returning them to the queue.") ;
8884 context . Logger . LogInformation ( jsonString ) ;
8985 }
90- return jsonString ;
86+
87+ return response ;
9188 }
9289 catch ( Exception ex )
9390 {
@@ -105,7 +102,7 @@ static async Task<string> Handler(SQSEvent ev, ILambdaContext context)
105102 } ) . ToList ( ) ) ;
106103 var jsonString = JsonSerializer . Serialize ( response , LinkIndexUpdaterSerializerContext . Default . SQSBatchResponse ) ;
107104 context . Logger . LogInformation ( jsonString ) ;
108- return jsonString ;
105+ return response ;
109106 }
110107}
111108
0 commit comments