Skip to content

Commit e1095d9

Browse files
committed
test
1 parent 734e961 commit e1095d9

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
// See the LICENSE file in the project root for more information
44

55
using System.Text.Json.Serialization;
6-
using Amazon.Lambda.S3Events;
76
using Amazon.Lambda.SQSEvents;
7+
using Amazon.S3.Util;
88

99
namespace Elastic.Documentation.Lambda.LinkIndexUploader;
1010

1111
[JsonSerializable(typeof(SQSEvent))]
12-
[JsonSerializable(typeof(S3Event))]
12+
[JsonSerializable(typeof(S3EventNotification))]
1313
[JsonSerializable(typeof(SQSBatchResponse))]
1414
public partial class LinkIndexUpdaterSerializerContext : JsonSerializerContext;
1515

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

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
using System.Text.Json;
77
using Amazon.Lambda.Core;
88
using Amazon.Lambda.RuntimeSupport;
9-
using Amazon.Lambda.S3Events;
109
using Amazon.Lambda.Serialization.SystemTextJson;
1110
using Amazon.Lambda.SQSEvents;
1211
using Amazon.S3;
1312
using Amazon.S3.Model;
13+
using Amazon.S3.Util;
1414
using Elastic.Documentation.Lambda.LinkIndexUploader;
1515
using Elastic.Markdown.IO.State;
1616
using Elastic.Markdown.Links.CrossLinks;
@@ -107,18 +107,17 @@ static async Task<SQSBatchResponse> Handler(SQSEvent ev, ILambdaContext context)
107107
}
108108
}
109109

110-
static async Task<IReadOnlyCollection<(S3Event.S3EventNotificationRecord, LinkReference)>> GetLinkReferences(IAmazonS3 s3Client, SQSEvent.SQSMessage message, ILambdaContext context)
110+
static async Task<IReadOnlyCollection<(S3EventNotification.S3EventNotificationRecord, LinkReference)>> GetLinkReferences(IAmazonS3 s3Client, SQSEvent.SQSMessage message, ILambdaContext context)
111111
{
112112
if (string.IsNullOrEmpty(message.Body))
113113
throw new Exception("No Body in SQS Message.");
114114
context.Logger.LogDebug("Received message {messageBody}", message.Body);
115-
var s3Event = JsonSerializer.Deserialize<S3Event>(message.Body, LinkIndexUpdaterSerializerContext.Default.S3Event);
115+
var s3Event = S3EventNotification.ParseJson(message.Body);
116116
if (s3Event?.Records == null || s3Event.Records.Count == 0)
117117
throw new Exception("Invalid S3 event message format");
118-
var linkReferences = new ConcurrentBag<(S3Event.S3EventNotificationRecord, LinkReference)>();
118+
var linkReferences = new ConcurrentBag<(S3EventNotification.S3EventNotificationRecord, LinkReference)>();
119119
await Parallel.ForEachAsync(s3Event.Records, async (record, ctx) =>
120120
{
121-
context.Logger.LogInformation(JsonSerializer.Serialize(record, LinkIndexUpdaterSerializerContext.Default.S3Event));
122121
var s3Bucket = record.S3.Bucket;
123122
var s3Object = record.S3.Object;
124123
context.Logger.LogInformation("Get object {key} from bucket {bucketName}", s3Object.Key, s3Bucket.Name);
@@ -132,7 +131,7 @@ await Parallel.ForEachAsync(s3Event.Records, async (record, ctx) =>
132131
return linkReferences;
133132
}
134133

135-
static void UpdateLinkIndex(LinkIndex linkIndex, LinkReference linkReference, S3Event.S3EventNotificationRecord s3EventRecord, ILambdaContext context)
134+
static void UpdateLinkIndex(LinkIndex linkIndex, LinkReference linkReference, S3EventNotification.S3EventNotificationRecord s3EventRecord, ILambdaContext context)
136135
{
137136
var s3Object = s3EventRecord.S3.Object;
138137
var keyTokens = s3Object.Key.Split('/');

0 commit comments

Comments
 (0)