forked from dotnet/orleans
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
34 lines (31 loc) · 1.09 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
using Orleans;
using Orleans.Hosting;
using VotingData;
await Host.CreateDefaultBuilder(args)
.UseOrleans((ctx, builder) =>
{
if (ctx.HostingEnvironment.IsDevelopment())
{
builder.UseLocalhostClustering();
builder.AddMemoryGrainStorage("votes");
}
else
{
// In Kubernetes, we use environment variables and the pod manifest
builder.UseKubernetesHosting();
// Use Redis for clustering & persistence
var redisAddress = $"{Environment.GetEnvironmentVariable("REDIS")}:6379";
builder.UseRedisClustering(options => options.ConnectionString = redisAddress);
builder.AddRedisGrainStorage("votes", options => options.ConnectionString = redisAddress);
}
builder.UseDashboard(options =>
{
options.Port = 8888;
})
.ConfigureApplicationParts(parts => parts.AddApplicationPart(typeof(VoteGrain).Assembly));
})
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
})
.RunConsoleAsync();