コード例 #1
0
ファイル: LdClient.cs プロジェクト: mikaelkrief/.net-client
        /// <summary>
        /// Creates a new client to connect to LaunchDarkly with a custom configuration, and a custom
        /// implementation of the analytics event processor. This constructor should only be used if you are
        /// overriding the default event-sending behavior.
        /// </summary>
        /// <param name="config">a client configuration object</param>
        /// <param name="eventStore">an event processor</param>
        public LdClient(Configuration config, IStoreEvents eventStore)
        {
            Log.InfoFormat("Starting LaunchDarkly Client {0}",
                           Configuration.Version);

            _configuration = config;
            _eventStore    = eventStore;
            _featureStore  = _configuration.FeatureStore;

            if (_configuration.Offline)
            {
                Log.Info("Starting Launchdarkly client in offline mode.");
                return;
            }

            var featureRequestor = new FeatureRequestor(config);

            if (_configuration.IsStreamingEnabled)
            {
                _updateProcessor = new StreamProcessor(config, featureRequestor, _featureStore);
            }
            else
            {
                Log.Warn("You should only disable the streaming API if instructed to do so by LaunchDarkly support");
                _updateProcessor = new PollingProcessor(config, featureRequestor, _featureStore);
            }
            var initTask = _updateProcessor.Start();

            Log.InfoFormat("Waiting up to {0} milliseconds for LaunchDarkly client to start..",
                           _configuration.StartWaitTime.TotalMilliseconds);

            var unused = initTask.Wait(_configuration.StartWaitTime);
        }
コード例 #2
0
 IUpdateProcessor IUpdateProcessorFactory.CreateUpdateProcessor(Configuration config, IFeatureStore featureStore)
 {
     if (config.Offline)
     {
         Log.Info("Starting Launchdarkly client in offline mode.");
         return(new NullUpdateProcessor());
     }
     else if (config.UseLdd)
     {
         Log.Info("Starting LaunchDarkly in LDD mode. Skipping direct feature retrieval.");
         return(new NullUpdateProcessor());
     }
     else
     {
         FeatureRequestor requestor = new FeatureRequestor(config);
         if (config.IsStreamingEnabled)
         {
             return(new StreamProcessor(config, requestor, featureStore, null));
         }
         else
         {
             Log.Warn("You should only disable the streaming API if instructed to do so by LaunchDarkly support");
             return(new PollingProcessor(config, requestor, featureStore));
         }
     }
 }
コード例 #3
0
ファイル: PollingProcessor.cs プロジェクト: oduma/.net-client
 internal PollingProcessor(Configuration config, FeatureRequestor featureRequestor, IFeatureStore featureStore)
 {
     _config           = config;
     _featureRequestor = featureRequestor;
     _featureStore     = featureStore;
     _initTask         = new TaskCompletionSource <bool>();
 }
コード例 #4
0
        public LdClient(Configuration config, IStoreEvents eventStore)
        {
            Logger.LogInformation("Starting LaunchDarkly Client " + Configuration.Version);
            _configuration = config;
            _eventStore    = eventStore;
            _featureStore  = config.FeatureStore;

            if (_configuration.Offline)
            {
                Logger.LogInformation("Starting Launchdarkly client in offline mode.");
                return;
            }

            var featureRequestor = new FeatureRequestor(config);

            _updateProcessor = new PollingProcessor(config, featureRequestor, _featureStore);
            var initTask = _updateProcessor.Start();

            Logger.LogInformation("Waiting up to " + _configuration.StartWaitTime.TotalMilliseconds +
                                  " milliseconds for LaunchDarkly client to start..");
            var unused = initTask.Task.Wait(_configuration.StartWaitTime);
        }