-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathVisualsUploadedConsumer.cs
24 lines (19 loc) · 1.08 KB
/
VisualsUploadedConsumer.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
namespace ConfigSample;
internal class VisualsUploadedConsumer(ILogger<VisualsUploadedConsumer> logger) : IEventConsumer<ImageUploaded>, IEventConsumer<VideoUploaded>
{
private static readonly TimeSpan SimulationDuration = TimeSpan.FromSeconds(1.3f);
public async Task ConsumeAsync(EventContext<ImageUploaded> context, CancellationToken cancellationToken)
{
var id = context.Event.ImageId;
var thumbnailUrl = $"https://localhost:8080/thumbnails/{id}.jpg";
await Task.Delay(SimulationDuration, cancellationToken);
logger.LogInformation("Generated thumbnail from image '{ImageId}' at '{ThumbnailUrl}'.", id, thumbnailUrl);
}
public async Task ConsumeAsync(EventContext<VideoUploaded> context, CancellationToken cancellationToken = default)
{
var id = context.Event.VideoId;
var thumbnailUrl = $"https://localhost:8080/thumbnails/{id}.jpg";
await Task.Delay(SimulationDuration, cancellationToken);
logger.LogInformation("Generated thumbnail from video '{VideoId}' at '{ThumbnailUrl}'.", id, thumbnailUrl);
}
}