public DefaultOrleansClient(IClusterClientFactory clusterClientFactory, IHttpContextAccessor httpContextAccessor, IOptions <OrleansRoutingOptions> options) { this._clusterClientFactory = clusterClientFactory; this._httpContextAccessor = httpContextAccessor; this._options = options.Value; }
public async Task InitializeAsync() { SiloNameA = new Faker().Random.String2(5); _siloHostA = Host.CreateDefaultBuilder() .UseOrleans((ctx, sb) => { sb.ConfigureCluster(ctx.Configuration.GetSection("Orleans:ClusterFactoryA")); sb.ConfigureEndpoints(ctx.Configuration.GetSection("Orleans:ClusterFactoryA:Silo")); sb.ConfigureConsulClustering(ctx.Configuration.GetSection("Orleans:ConsulMembershipProvider")); sb.AddAssemblies(typeof(ClusterClientFactoryTestGrain)); sb.Configure <SiloOptions>(options => options.SiloName = SiloNameA); }) .Build(); await _siloHostA.StartAsync(); SiloNameB = new Faker().Random.String2(5); _siloHostB = Host.CreateDefaultBuilder() .UseOrleans((ctx, sb) => { sb.ConfigureCluster(ctx.Configuration.GetSection("Orleans:ClusterFactoryB")); sb.ConfigureEndpoints(ctx.Configuration.GetSection("Orleans:ClusterFactoryB:Silo")); sb.ConfigureConsulClustering(ctx.Configuration.GetSection("Orleans:ConsulMembershipProvider")); sb.AddAssemblies(typeof(ClusterClientFactoryTestGrain)); sb.Configure <SiloOptions>(options => options.SiloName = SiloNameB); }) .Build(); await _siloHostB.StartAsync(); var clientHost = Host.CreateDefaultBuilder() .ConfigureServices((ctx, services) => { services.AddHttpClient(); services.AddClusterClientFactory() .AddClusterClient("ClusterA", () => { return(services.CreateClusterClient(builder => { builder.ConfigureCluster(ctx.Configuration.GetSection("Orleans:ClusterFactoryA")); builder.ConfigureConsulClustering(ctx.Configuration.GetSection("Orleans:ConsulMembershipProvider")); builder.AddAssemblies(typeof(IClusterClientFactoryTestGrain)); })); }) .AddClusterClient("ClusterB", () => { return(services.CreateClusterClient(builder => { builder.ConfigureCluster(ctx.Configuration.GetSection("Orleans:ClusterFactoryB")); builder.ConfigureConsulClustering(ctx.Configuration.GetSection("Orleans:ConsulMembershipProvider")); builder.AddAssemblies(typeof(IClusterClientFactoryTestGrain)); })); }); }) .Build(); ClientServiceProvider = clientHost.Services; OrleansClusterClientFactory = ClientServiceProvider.GetRequiredService <IClusterClientFactory>(); }
public OrleansClient(IServiceProvider serviceProvider, IClusterClientFactory clusterClientFactory) { _serviceProvider = serviceProvider; _clusterClientFactory = clusterClientFactory; }