-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathProgram.cs
More file actions
59 lines (49 loc) · 1.65 KB
/
Copy pathProgram.cs
File metadata and controls
59 lines (49 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
using BufferQueue;
using BufferQueue.Memory;
using WebAPI;
using WebApp;
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
// Configure the BufferQueue
builder.Services.AddBufferQueue(bufferOptionsBuilder =>
{
bufferOptionsBuilder
.UseMemory(memoryBufferOptionsBuilder =>
{
memoryBufferOptionsBuilder
.AddTopic<Foo>(options =>
{
options.TopicName = "topic-foo1";
options.PartitionNumber = 6;
// Route the same Foo.Id to the same partition.
options.UsePartitionKey(foo => foo.Id);
})
.AddTopic<Foo>(options =>
{
options.TopicName = "topic-foo2";
options.PartitionNumber = 4;
})
.AddTopic<Bar>(options =>
{
options.TopicName = "topic-bar";
options.PartitionNumber = 8;
options.BoundedCapacity = 100_000;
options.FullMode = BufferQueueFullMode.Wait;
});
})
.AddPushCustomers(typeof(Program).Assembly);
});
builder.Services.AddHostedService<Foo1PullConsumerHostService>();
var app = builder.Build();
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}
app.MapControllers();
app.Run();