private FeatureflowClient(string apiKey, IEnumerable <Feature> defaultFeatures, FeatureflowConfig config)
        {
            _config = config ?? new FeatureflowConfig();
            _featureControlCache = new SimpleMemoryFeatureCache();

            InitializeDefaultFeatures(defaultFeatures);

            if (!_config.Offline)
            {
                var restConfig = new RestConfig
                {
                    SdkVersion = ((AssemblyInformationalVersionAttribute)typeof(FeatureflowClient)
                                  .GetTypeInfo().Assembly.GetCustomAttribute(typeof(AssemblyInformationalVersionAttribute))).InformationalVersion
                };

                _restClient   = new RestClient(apiKey, _config, restConfig);
                _eventsClient = new FeatureflowEventsClient(_restClient, _config);

                switch (_config.GetFeaturesMethod)
                {
                case GetFeaturesMethod.Polling:
                    _pollingClient = new PollingClient(_config, _featureControlCache, _restClient);
                    _pollingClient.FeatureUpdated += OnFeatureUpdated;
                    _pollingClient.FeatureDeleted += OnFeatureDeleted;
                    break;

                case GetFeaturesMethod.Sse:
                    _streamClient = new FeatureflowStreamClient(_config, _featureControlCache, _restClient);
                    _streamClient.FeatureUpdated += OnFeatureUpdated;
                    _streamClient.FeatureDeleted += OnFeatureDeleted;
                    break;
                }
            }
        }
示例#2
0
        public FeatureflowClient(string apiKey, List <Feature> features, FeatureflowConfig config)
        {
            Logger.LogInformation("Initialising Featureflow...");
            features?.ForEach(feature => _featureDefaults[feature.Key] = feature);
            _featureControlCache = new SimpleMemoryFeatureCache();

            if (config.Offline)
            {
                Logger.LogWarning("Featureflow is in Offline mode. Registered defaults will be used.");
                return;
            }

            var restConfig = new RestConfig
            {
                sdkVersion = ((AssemblyInformationalVersionAttribute)typeof(FeatureflowClient)
                              .GetTypeInfo().Assembly.GetCustomAttribute(typeof(AssemblyInformationalVersionAttribute))).InformationalVersion
            };


            _restClient = new RestClient(apiKey, config, restConfig);
            //register feature coded failover values

            //start the featureControl Client
            _featureControlClient = new PollingClient(config, _featureControlCache, _restClient);

            var initTask = _featureControlClient.Init(); //initialise
            var unused   = initTask.Task.Wait(300000);   //wait
        }
        public RestClient(string apiKey, FeatureflowConfig config, RestConfig restConfig)

        {
            _apiKey     = apiKey;
            _config     = config;
            _restConfig = restConfig;
            _httpClient = CreateHttpClient();
        }
示例#4
0
 internal RestClient(string apiKey, FeatureflowConfig config, RestConfig restConfig)
 {
     _apiKey     = apiKey;
     _config     = config;
     _restConfig = restConfig;
 }