public RedisInternalConfigurationRepository(CusOcelotConfiguration options, IFileConfigurationRepository fileConfigurationRepository, IInternalConfigurationCreator internalConfigurationCreator, IOcelotCache <InternalConfiguration> ocelotCache) { _fileConfigurationRepository = fileConfigurationRepository; _internalConfigurationCreator = internalConfigurationCreator; _options = options; _ocelotCache = ocelotCache; }
public InternalConfigurationSetter( IInternalConfigurationRepository configRepo, IInternalConfigurationCreator configCreator) { _internalConfigRepo = configRepo; _configCreator = configCreator; _logger = LogManager.GetCurrentClassLogger(); }
public FileAndInternalConfigurationSetter( IInternalConfigurationRepository configRepo, IInternalConfigurationCreator configCreator, IFileConfigurationRepository repo) { internalConfigRepo = configRepo; _configCreator = configCreator; _repo = repo; }
public ErrorHandlingMiddleware(RequestDelegate next, ILoggerFactory loggerFactory, IHostingEnvironment env, IInternalConfigurationCreator configCreator) { _next = next; _loggerFactory = loggerFactory; _env = env; }
public OcelotConfigurationChangedEventHandler( IFileConfigurationRepository fileConfigRepo, IInternalConfigurationRepository internalConfigRepo, IInternalConfigurationCreator internalConfigCreator, ILogger <OcelotConfigurationChangedEventHandler> logger) { _fileConfigRepo = fileConfigRepo; _internalConfigRepo = internalConfigRepo; _internalConfigCreator = internalConfigCreator; _logger = logger; }
public DBConfigurationPoller(IOcelotLoggerFactory ocelotLoggerFactory, IFileConfigurationRepository fileConfigurationRepository, IInternalConfigurationRepository internalConfigurationRepository, IInternalConfigurationCreator internalConfigurationCreator, GatewayConfiguration gatewayConfiguration) { _internalConfigRepo = internalConfigurationRepository; _internalConfigCreator = internalConfigurationCreator; _logger = ocelotLoggerFactory.CreateLogger <DBConfigurationPoller>(); _repo = fileConfigurationRepository; _option = gatewayConfiguration; }
public DbConfigurationPoller(IOcelotLoggerFactory factory, IFileConfigurationRepository repo, IInternalConfigurationRepository internalConfigRepo, IInternalConfigurationCreator internalConfigCreator, AhphOcelotConfiguration option) { _internalConfigRepo = internalConfigRepo; _internalConfigCreator = internalConfigCreator; _logger = factory.CreateLogger <DbConfigurationPoller>(); _repo = repo; _option = option; }
public FileConfigurationPoller( IOcelotLoggerFactory factory, IFileConfigurationRepository repo, IFileConfigurationPollerOptions options, IInternalConfigurationRepository internalConfigRepo, IInternalConfigurationCreator internalConfigCreator) { _internalConfigRepo = internalConfigRepo; _internalConfigCreator = internalConfigCreator; _options = options; _logger = factory.CreateLogger <FileConfigurationPoller>(); _repo = repo; _previousAsJson = ""; }
public UpdateFileConfigurationEventHandler(ConfigCacheOptions option, IFileConfigurationRepository fileConfigurationRepository, IAbpFileConfigurationRepository abpFileConfigurationRepository, IInternalConfigurationRepository internalConfigRepo, IInternalConfigurationCreator internalConfigCreator, ILogger <UpdateFileConfigurationEventHandler> logger) { _option = option; _fileConfigurationRepository = fileConfigurationRepository; _abpFileConfigurationRepository = abpFileConfigurationRepository; _internalConfigRepo = internalConfigRepo; _internalConfigCreator = internalConfigCreator; _logger = logger; }
public ApigatewayConfigChangeEventHandler( IOptions <ApiGatewayOptions> options, IFileConfigurationRepository fileConfigRepo, IInternalConfigurationRepository internalConfigRepo, IInternalConfigurationCreator internalConfigCreator, ILogger <ApigatewayConfigChangeEventHandler> logger) { _fileConfigRepo = fileConfigRepo; _internalConfigRepo = internalConfigRepo; _internalConfigCreator = internalConfigCreator; _logger = logger; Options = options.Value; }
public CzarCacheController(IClientAuthenticationRepository clientAuthenticationRepository, CzarOcelotConfiguration options, IFileConfigurationRepository fileConfigurationRepository, IInternalConfigurationCreator internalConfigurationCreator, IClientRateLimitRepository clientRateLimitRepository, IRpcRepository rpcRepository, IMemoryCache cache) { _clientAuthenticationRepository = clientAuthenticationRepository; _options = options; _fileConfigurationRepository = fileConfigurationRepository; _internalConfigurationCreator = internalConfigurationCreator; _clientRateLimitRepository = clientRateLimitRepository; _rpcRepository = rpcRepository; _cache = cache; }
private static async Task SetFileConfigInConsul(IApplicationBuilder builder, IFileConfigurationRepository fileConfigRepo, IOptions <FileConfiguration> fileConfig, IInternalConfigurationCreator internalConfigCreator, IInternalConfigurationRepository internalConfigRepo) { // get the config from consul. var fileConfigFromConsul = await fileConfigRepo.Get(); if (IsError(fileConfigFromConsul)) { ThrowToStopOcelotStarting(fileConfigFromConsul); } else if (ConfigNotStoredInConsul(fileConfigFromConsul)) { //there was no config in consul set the file in config in consul await fileConfigRepo.Set(fileConfig.Value); } else { // create the internal config from consul data var internalConfig = await internalConfigCreator.Create(fileConfigFromConsul.Data); if (IsError(internalConfig)) { ThrowToStopOcelotStarting(internalConfig); } else { // add the internal config to the internal repo var response = internalConfigRepo.AddOrReplace(internalConfig.Data); if (IsError(response)) { ThrowToStopOcelotStarting(response); } } if (IsError(internalConfig)) { ThrowToStopOcelotStarting(internalConfig); } } //todo - this starts the poller if it has been registered...please this is so bad. var hack = builder.ApplicationServices.GetService(typeof(ConsulFileConfigurationPoller)); }
private static async Task <IInternalConfiguration> CreateConfiguration(IApplicationBuilder builder) { var fileConfigRepo = builder.ApplicationServices.GetRequiredService <IFileConfigurationRepository>(); var fileConfig = await fileConfigRepo.Get(); // IOptionsMonitor<FileConfiguration> fileConfig = builder.ApplicationServices.GetService<IOptionsMonitor<FileConfiguration>>(); IInternalConfigurationCreator internalConfigCreator = builder.ApplicationServices.GetService <IInternalConfigurationCreator>(); Response <IInternalConfiguration> response = await internalConfigCreator.Create(fileConfig.Data); if (response.IsError) { ThrowToStopOcelotStarting(response); } IInternalConfigurationRepository internalConfigRepo = builder.ApplicationServices.GetService <IInternalConfigurationRepository>(); internalConfigRepo.AddOrReplace(response.Data); return(GetOcelotConfigAndReturn(internalConfigRepo)); }
private static async Task SetFileConfigInDataBase(IApplicationBuilder builder, IFileConfigurationRepository fileConfigRepo, IOptionsMonitor <FileConfiguration> fileConfig, IInternalConfigurationCreator internalConfigCreator, IInternalConfigurationRepository internalConfigRepo) { // get the config from consul. var fileConfigFromDataBase = await fileConfigRepo.Get(); if (IsError(fileConfigFromDataBase)) { ThrowToStopOcelotStarting(fileConfigFromDataBase); } //else if (ConfigNotStoredInDataBase(fileConfigFromDataBase)) //{ // //there was no config in consul set the file in config in consul // await fileConfigRepo.Set(fileConfig.CurrentValue); //} else { await fileConfigRepo.Set(fileConfigFromDataBase.Data); // create the internal config from consul data var internalConfig = await internalConfigCreator.Create(fileConfigFromDataBase.Data); if (IsError(internalConfig)) { ThrowToStopOcelotStarting(internalConfig); } else { // add the internal config to the internal repo var response = internalConfigRepo.AddOrReplace(internalConfig.Data); if (IsError(response)) { ThrowToStopOcelotStarting(response); } } if (IsError(internalConfig)) { ThrowToStopOcelotStarting(internalConfig); } } }
public RedisInternalConfigurationRepository(CzarOcelotConfiguration options, IFileConfigurationRepository fileConfigurationRepository, IInternalConfigurationCreator internalConfigurationCreator) { _fileConfigurationRepository = fileConfigurationRepository; _internalConfigurationCreator = internalConfigurationCreator; _options = options; CSRedis.CSRedisClient csredis; if (options.RedisConnectionStrings.Count == 1) { //普通模式 csredis = new CSRedis.CSRedisClient(options.RedisConnectionStrings[0]); } else { //集群模式 //实现思路:根据key.GetHashCode() % 节点总数量,确定连向的节点 //也可以自定义规则(第一个参数设置) csredis = new CSRedis.CSRedisClient(null, options.RedisConnectionStrings.ToArray()); } //初始化 RedisHelper RedisHelper.Initialization(csredis); }
/// <summary> /// 设置存储配置信息 /// </summary> /// <param name="builder"></param> /// <param name="fileConfigRepo"></param> /// <param name="internalConfigCreator"></param> /// <param name="internalConfigRepo"></param> /// <returns></returns> private static async Task SetFileConfigInDataBase(IApplicationBuilder builder, IFileConfigurationRepository fileConfigRepo, IInternalConfigurationCreator internalConfigCreator, IInternalConfigurationRepository internalConfigRepo) { // 从redis中获取数据 var fileConfigFromDataBase = await fileConfigRepo.Get(); if (IsError(fileConfigFromDataBase)) { ThrowToStopOcelotStarting(fileConfigFromDataBase); } else { //设置存储 await fileConfigRepo.Set(fileConfigFromDataBase.Data); // create the internal config from consul data var internalConfig = await internalConfigCreator.Create(fileConfigFromDataBase.Data); if (IsError(internalConfig)) { ThrowToStopOcelotStarting(internalConfig); } else { // var response = internalConfigRepo.AddOrReplace(internalConfig.Data); if (IsError(response)) { ThrowToStopOcelotStarting(response); } } if (IsError(internalConfig)) { ThrowToStopOcelotStarting(internalConfig); } } }
private static async Task SetFileConfigInSqlServer(IApplicationBuilder builder, IFileConfigurationRepository fileConfigRepo, IOptionsMonitor <FileConfiguration> fileConfig, IInternalConfigurationCreator internalConfigCreator, IInternalConfigurationRepository internalConfigRepo) { var fileConfigFromSqlServer = await fileConfigRepo.Get(); if (IsError(fileConfigFromSqlServer)) { ThrowToStopOcelotStarting(fileConfigFromSqlServer); } else if (ConfigNotStoredInConsul(fileConfigFromSqlServer)) { await fileConfigRepo.Set(fileConfig.CurrentValue); } else { var internalConfig = await internalConfigCreator.Create(fileConfigFromSqlServer.Data); if (IsError(internalConfig)) { ThrowToStopOcelotStarting(internalConfig); } else { var response = internalConfigRepo.AddOrReplace(internalConfig.Data); if (IsError(response)) { ThrowToStopOcelotStarting(response); } } if (IsError(internalConfig)) { ThrowToStopOcelotStarting(internalConfig); } } }
private static async Task <IInternalConfiguration> CreateConfiguration(IApplicationBuilder builder) { /* 因为ABP框架中,Abp.HttpClient这个模块里面 * RemoteServiceOptions 是用的IOptionsSnapshot注入的,这里会出现一个异常 * 每个RemoteService服务必须在一个请求范围内 * 解决方案为重写DynamicHttpProxyInterceptor类,替换IOptions<RemoteServiceOptions> * 网关不需要实现网关后台服务地址的实时更新 */ var fileConfigRepo = builder.ApplicationServices.GetRequiredService <IFileConfigurationRepository>(); var fileConfig = await fileConfigRepo.Get(); // IOptionsMonitor<FileConfiguration> fileConfig = builder.ApplicationServices.GetService<IOptionsMonitor<FileConfiguration>>(); IInternalConfigurationCreator internalConfigCreator = builder.ApplicationServices.GetService <IInternalConfigurationCreator>(); Response <IInternalConfiguration> response = await internalConfigCreator.Create(fileConfig.Data); if (response.IsError) { ThrowToStopOcelotStarting(response); } IInternalConfigurationRepository internalConfigRepo = builder.ApplicationServices.GetService <IInternalConfigurationRepository>(); internalConfigRepo.AddOrReplace(response.Data); return(GetOcelotConfigAndReturn(internalConfigRepo)); }
/// <summary> /// /// </summary> /// <param name="serv"></param> /// <param name="configClient"></param> /// <param name="serviceProvider"></param> /// <param name="_internalConfigurationRepo"></param> /// <param name="_internalConfigurationCreator"></param> public OcelotConfigurationTask(INacosNamingService serv, INacosConfigService configClient, IServiceProvider serviceProvider, IInternalConfigurationRepository _internalConfigurationRepo, IInternalConfigurationCreator _internalConfigurationCreator) { _configClient = configClient; _servClient = serv; nacosConfigListener.internalConfigurationRepo = _internalConfigurationRepo; nacosConfigListener.internalConfigurationCreator = _internalConfigurationCreator; OcelotConfig = Appsettings.GetValue("ApiGateWay:OcelotConfig"); OcelotConfigGroup = Appsettings.GetValue("ApiGateWay:OcelotConfigGroup"); AppConfig = Appsettings.GetValue("ApiGateWay:AppConfig"); AppConfigGroup = Appsettings.GetValue("ApiGateWay:AppConfigGroup"); string OcelotCfg = configClient.GetConfig(OcelotConfig, OcelotConfigGroup, 10000).GetAwaiter().GetResult(); nacosConfigListener.ReceiveConfigInfo(OcelotCfg); string AppCfg = configClient.GetConfig(AppConfig, AppConfigGroup, 10000).GetAwaiter().GetResult(); AppConfigListener.ReceiveConfigInfo(AppCfg); //string sss = serv.Cof_NaoceGet("fld-cloud-datax", "DEFAULT_GROUP", "/api/base/deviceList?limit=10&page=1").GetAwaiter().GetResult(); }