/// <summary> /// 添加负载均衡器 /// </summary> /// <param name="services"></param> /// <param name="configAction"></param> /// <returns></returns> public static SparkBuilder AddLoadBalancer(this SparkBuilder builder) { builder.Services.AddSingleton <ILoadBalancerFactory, LoadBalancerFactory>(); builder.Services.AddSingleton <ILoadBalancerHouse, LoadBalancerHouse>(); return(builder); }
public static SparkBuilder AddLog(this SparkBuilder builder, Action <LogOptions> action) { var options = new LogOptions(); action?.Invoke(options); foreach (var serviceExtension in options.Extensions) { serviceExtension.AddServices(builder.Services); } return(builder); }
public static SparkBuilder AddSmartSql(this SparkBuilder builder, params string[] repositoryAssembly) { builder.Services.AddSmartSql(); builder.Services.AddRepositoryFactory(); foreach (var para in repositoryAssembly) { builder.Services.AddRepositoryFromAssembly((options) => { options.AssemblyString = para; }); } return(builder); }
/// <summary> /// 添加SmartSql支持。从配置中心读取配置 /// </summary> /// <param name="builder"></param> /// <param name="configurationSection"></param> /// <param name="repositoryAssembly">仓库程序集名</param> /// <returns></returns> public static SparkBuilder AddSmartSql(this SparkBuilder builder, IConfigurationSection configurationSection, params string[] repositoryAssembly) { builder.Services.Configure <SmartSqlDbConfigOptions>(configurationSection); builder.Services.AddSmartSql(sp => new SmartSqlOptions().UseOptions(sp)); builder.Services.AddRepositoryFactory(); foreach (var para in repositoryAssembly) { builder.Services.AddRepositoryFromAssembly((options) => { options.AssemblyString = para; }); } return(builder); }
/// <summary> /// 服务发现 /// </summary> /// <param name="builder"></param> /// <param name="configAction"></param> /// <returns></returns> public static SparkBuilder AddServiceDiscovery(this SparkBuilder builder, Action <ServiceDiscoveryOptions> configAction) { if (configAction == null) { throw new ArgumentNullException(nameof(configAction)); } var options = new ServiceDiscoveryOptions(); configAction?.Invoke(options); foreach (var serviceExtension in options.Extensions) { serviceExtension.AddServices(builder.Services); } return(builder); }
/// <summary> /// 事件驱动 /// </summary> /// <param name="builder"></param> /// <param name="configAction"></param> /// <returns></returns> public static SparkBuilder AddEventBus(this SparkBuilder builder, Action <EventBusOptions> configAction) { if (configAction == null) { throw new ArgumentNullException(nameof(configAction)); } var options = new EventBusOptions(); configAction?.Invoke(options); builder.Services.AddSingleton <IEventBusSubscriptionsManager, InMemoryEventBusSubscriptionsManager>(); foreach (var serviceExtension in options.Extensions) { serviceExtension.AddServices(builder.Services); } return(builder); }