Skip to content

Instantly share code, notes, and snippets.

@dcomartin
Created December 14, 2017 02:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dcomartin/9a806abaeb5f1e500e15eafa27dffcb5 to your computer and use it in GitHub Desktop.
Save dcomartin/9a806abaeb5f1e500e15eafa27dffcb5 to your computer and use it in GitHub Desktop.
using System;
using Botwin;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Orleans;
using Orleans.Runtime.Configuration;
using Polly;
namespace Web
{
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
services.AddBotwin();
services.AddSingleton(provider =>
{
return Policy<IClusterClient>
.Handle<Exception>()
.WaitAndRetry(new[]
{
TimeSpan.FromSeconds(1),
TimeSpan.FromSeconds(2),
TimeSpan.FromSeconds(3)
})
.Execute(() =>
{
var config = ClientConfiguration.LocalhostSilo(30000);
var client = ClientBuilder.CreateDefault()
.UseConfiguration(config)
.Build();
client.Connect().Wait();
return client;
});
});
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseBotwin();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment