Ejemplo n.º 1
0
 public GlobalController(IFileConfigurationRepository repo, IFileConfigurationSetter setter, IServiceProvider provider, ILogger <GlobalController> logger)
 {
     _repo     = repo;
     _setter   = setter;
     _provider = provider;
     _logger   = logger;
 }
Ejemplo n.º 2
0
        private static async Task SetFileConfig(IFileConfigurationSetter fileConfigSetter, IOptionsMonitor <FileConfiguration> fileConfig)
        {
            var response = await fileConfigSetter.Set(fileConfig.CurrentValue);

            if (IsError(response))
            {
                ThrowToStopOcelotStarting(response);
            }
        }
        private static async Task SetFileConfig(IFileConfigurationSetter fileConfigSetter, FileConfiguration fileConfig)
        {
            var response = await fileConfigSetter.Set(fileConfig);

            if (IsError(response))
            {
                ThrowToStopOcelotStarting(response);
            }
        }
Ejemplo n.º 4
0
 public ConfigurationController(
     IFileConfigurationRepository configDbRepo,
     IInternalConfigurationRepository configUsingRepo,
     IFileConfigurationSetter setter)
 {
     _logger          = LogManager.GetLogger("apigatewayadmin");
     _setter          = setter;
     _configRepo      = configDbRepo;
     _configUsingRepo = configUsingRepo;
 }
Ejemplo n.º 5
0
        public ConsulFileConfigurationPoller(IOcelotLoggerFactory factory, IFileConfigurationRepository repo, IFileConfigurationSetter setter)
        {
            _setter         = setter;
            _logger         = factory.CreateLogger <ConsulFileConfigurationPoller>();
            _repo           = repo;
            _previousAsJson = "";
            _timer          = new Timer(async x =>
            {
                if (_polling)
                {
                    return;
                }

                _polling = true;
                await Poll();
                _polling = false;
            }, null, 0, 1000);
        }
Ejemplo n.º 6
0
 public FileConfigurationController(IFileConfigurationRepository repo, IFileConfigurationSetter setter, IServiceProvider provider)
 {
     _repo     = repo;
     _setter   = setter;
     _provider = provider;
 }
Ejemplo n.º 7
0
 public ConfigController(IFileConfigurationRepository repo,
                         IFileConfigurationSetter setter)
 {
 }
Ejemplo n.º 8
0
 public OcelotFiniteStateMachine(IFileConfigurationSetter setter)
 {
     _setter = setter;
 }
 public FileConfigurationController(IFileConfigurationProvider getFileConfig, IFileConfigurationSetter configSetter, IServiceProvider serviceProvider)
 {
     _configGetter    = getFileConfig;
     _configSetter    = configSetter;
     _serviceProvider = serviceProvider;
 }
 public EditorController(IFileConfigurationRepository fileConfigurationRepository, IFileConfigurationSetter configSetter)
 {
     _fileConfigRepo = fileConfigurationRepository;
     _configSetter   = configSetter;
 }
Ejemplo n.º 11
0
 public ReloadService(IFileConfigurationSetter configSetter, IFileConfigurationRepository fileConfigRepo)
 {
     _configSetter   = configSetter;
     _fileConfigRepo = fileConfigRepo;
 }
Ejemplo n.º 12
0
        private static async Task <Response> SetUpConfigFromConsul(IApplicationBuilder builder, IFileConfigurationRepository consulFileConfigRepo, IFileConfigurationSetter setter, IOptions <FileConfiguration> fileConfig)
        {
            Response config = null;

            var ocelotConfigurationRepository =
                (IOcelotConfigurationRepository)builder.ApplicationServices.GetService(
                    typeof(IOcelotConfigurationRepository));
            var ocelotConfigurationCreator =
                (IOcelotConfigurationCreator)builder.ApplicationServices.GetService(
                    typeof(IOcelotConfigurationCreator));

            var fileConfigFromConsul = await consulFileConfigRepo.Get();

            if (fileConfigFromConsul.Data == null)
            {
                config = await setter.Set(fileConfig.Value);
            }
            else
            {
                var ocelotConfig = await ocelotConfigurationCreator.Create(fileConfigFromConsul.Data);

                if (ocelotConfig.IsError)
                {
                    return(new ErrorResponse(ocelotConfig.Errors));
                }
                config = await ocelotConfigurationRepository.AddOrReplace(ocelotConfig.Data);

                //todo - this starts the poller if it has been registered...please this is so bad.
                var hack = builder.ApplicationServices.GetService(typeof(ConsulFileConfigurationPoller));
            }

            return(new OkResponse());
        }
Ejemplo n.º 13
0
        private static async Task <Response> SetConfig(IApplicationBuilder builder, IOptions <FileConfiguration> fileConfiguration, IFileConfigurationSetter setter, IOcelotConfigurationProvider provider, IFileConfigurationRepository repo)
        {
            if (UsingConsul(repo))
            {
                return(await SetUpConfigFromConsul(builder, repo, setter, fileConfiguration));
            }

            return(await setter.Set(fileConfiguration.Value));
        }
Ejemplo n.º 14
0
 public GatewayServices(IServiceProvider serviceProvider)
 {
     _repo   = serviceProvider.GetService <IFileConfigurationRepository>();
     _setter = serviceProvider.GetService <IFileConfigurationSetter>();
 }