public static IMultiClientBuilder AddClient(this IMultiClientBuilder builder, Action <OrleansClientOptions> startup) { OrleansClientOptions options = new OrleansClientOptions(); startup.Invoke(options); return(builder.AddClient(options)); }
public GrainRouteValues Resolve(HttpContext context) { var data = context.GetRouteData(); string siloName = (string)data.Values["siloName"]; string serviceName = (string)data.Values["serviceName"]; string grainId = (string)data.Values["grainId"]; string grainMethod = (string)data.Values["grainMethod"]; Type type = _GrainTypeCache.GetOrAdd($"{siloName}.{serviceName}", (key) => { //Get client option based on serviceName if (!options.Clients.ContainsKey(siloName)) { throw new ArgumentNullException(nameof(OrleansClientOptions)); } OrleansClientOptions option = options.Clients[siloName]; string grainInterface = option.InterfaceTemplate.Replace("{ServiceName}", serviceName); return(option.Assembly.ExportedTypes .Where(f => typeof(IGrain).IsAssignableFrom(f) && f.Name.Equals(grainInterface, StringComparison.OrdinalIgnoreCase)) .FirstOrDefault()); }); if (type == null) { throw new ArgumentNullException("Grain Type Not null"); } return(new GrainRouteValues(context, siloName, serviceName, grainMethod, grainId, type)); }
public IOrleansClientBuilder AddClient(Action <OrleansClientOptions> options, Action <IClientBuilder> builder = null) { this.services.AddOptions().Configure(options); var opt = new OrleansClientOptions(); options.Invoke(opt); return(this.AddClient(opt, builder)); }
public IOrleansClientBuilder AddClient(OrleansClientOptions options, Action <IClientBuilder> builder = null) { this.services.AddTransientNamedService(options.ServiceId, (service, key) => { if (options == null) { throw new ArgumentNullException("OrleansClientOptions Cannot be NULL"); } if (string.IsNullOrEmpty(options.ServiceId)) { throw new ArgumentNullException("ServiceId Can not be empty"); } var build = new ClientBuilder() .Configure <ClusterOptions>(opt => { opt.ServiceId = options.ServiceId; if (!string.IsNullOrEmpty(options.ClusterId)) { opt.ClusterId = options.ClusterId; } else { opt.ClusterId = options.ServiceId; } }); builder?.Invoke(build); //配置本地集群 if (options.IsLocalHost) { build.UseLocalhostClustering(); } //配置静态网关 else if (options.StaticGatewayList.Count > 0) { build.UseStaticClustering((StaticGatewayListProviderOptions opt) => { foreach (var gateway in options.StaticGatewayList) { opt.Gateways.Add(gateway); } }); } return(build); }); return(this); }
public static IMultiClientBuilder AddClient(this IMultiClientBuilder builder, OrleansClientOptions options) { if (options.Configure == null) { options.Configure = builder.OrleansConfigure; } foreach (var serviceName in options.ServiceList) { if (!options.ExistAssembly(serviceName)) { throw new ArgumentNullException($"{serviceName} service does not exist in the assembly"); } builder.Services.AddSingletonNamedService <IClusterClientBuilder>(serviceName.ToLower(), (sp, key) => { return(new ClusterClientBuilder(sp, options, key)); }); } return(builder); }
public static IMultiClientBuilder AddClient(this IMultiClientBuilder builder, OrleansClientOptions options) { builder.ClientOptions.Add(options); return(builder); }