-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathProgram.cs
53 lines (41 loc) · 1.7 KB
/
Program.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
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
using Cleipnir.Flows.AspNet;
using Cleipnir.Flows.PostgresSql;
using Cleipnir.Flows.Sample.Clients;
using Cleipnir.ResilientFunctions.PostgreSQL;
using Serilog;
namespace Cleipnir.Flows.Sample;
internal static class Program
{
private static async Task Main(string[] args)
{
Log.Logger = new LoggerConfiguration()
.WriteTo.Console()
.CreateLogger();
var builder = WebApplication.CreateBuilder(args);
builder.Host.UseSerilog();
builder.Services.AddSingleton<IEmailClient, EmailClientStub>();
builder.Services.AddSingleton<ILogisticsClient, LogisticsClientStub>();
builder.Services.AddSingleton<IPaymentProviderClient, PaymentProviderClientStub>();
const string connectionString = "Server=localhost;Port=5432;Userid=postgres;Password=Pa55word!;Database=flows;";
await DatabaseHelper.CreateDatabaseIfNotExists(connectionString); //use to create db initially or clean existing state in database
builder.Services.AddFlows(c => c
.UsePostgresStore(connectionString)
.WithOptions(new Options(leaseLength: TimeSpan.FromSeconds(5)))
.RegisterFlowsAutomatically()
);
// Add services to the container.
builder.Services.AddControllers();
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
var app = builder.Build();
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}
app.UseAuthorization();
app.MapControllers();
await app.RunAsync();
}
}