-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathProgram.cs
More file actions
66 lines (46 loc) · 1.74 KB
/
Program.cs
File metadata and controls
66 lines (46 loc) · 1.74 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
60
61
62
63
64
65
66
using Microsoft.EntityFrameworkCore;
using Scalar.AspNetCore;
using TickerQ.Dashboard.DependencyInjection;
using TickerQ.DependencyInjection;
using TickerQ.EntityFrameworkCore.DependencyInjection;
using TickerQExample.WebAPI.Data;
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.AddNpgsqlDbContext<TestDbContext>(connectionName: "Database");
builder.Services.AddTickerQ(opt =>
{
// Set your class that implements ITickerExceptionHandler.
// opt.SetExceptionHandler<MyExceptionHandlerClass>();
// Set the max thread concurrency for Ticker (default: Environment.ProcessorCount).
opt.SetMaxConcurrency(4);
opt.SetInstanceIdentifier(builder.Configuration.GetValue<string>("InstanceIdentifier"));
opt.AddDashboard(basePath: "/tickerq-dashboard");
opt.AddDashboardBasicAuth();
opt.AddOperationalStore<TestDbContext>(efOpt =>
{
efOpt.UseModelCustomizerForMigrations(); // Applies custom model customization only during EF Core migrations
efOpt.CancelMissedTickersOnApplicationRestart(); // Useful in distributed mode
});
});
builder.Services.AddControllers();
builder.AddServiceDefaults();
// Learn more about configuring OpenAPI at https://aka.ms/aspnet/openapi
builder.Services.AddOpenApi();
var app = builder.Build();
using (var scope = app.Services.CreateScope())
{
var dbcontext = scope.ServiceProvider.GetService<TestDbContext>();
await dbcontext.Database.MigrateAsync();
}
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.MapOpenApi();
app.MapScalarApiReference();
}
app.UseHttpsRedirection();
app.UseAuthorization();
app.UseTickerQ();
app.MapControllers();
app.MapDefaultEndpoints();
app.Run();