예제 #1
0
        /// <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
        public LdClient(Configuration config, IEventProcessor eventProcessor)
        {
            Log.InfoFormat("Starting LaunchDarkly Client {0}",
                           ServerSideClientEnvironment.Instance.Version);

            _configuration = config;

            if (eventProcessor == null)
            {
                _eventProcessor = (_configuration.EventProcessorFactory ??
                                   Components.DefaultEventProcessor).CreateEventProcessor(_configuration);
                _shouldDisposeEventProcessor = true;
            }
            else
            {
                _eventProcessor = eventProcessor;
                // The following line is for backward compatibility with the obsolete mechanism by which the
                // caller could pass in an IStoreEvents implementation instance that we did not create.  We
                // were not disposing of that instance when the client was closed, so we should continue not
                // doing so until the next major version eliminates that mechanism.  We will always dispose
                // of instances that we created ourselves from a factory.
                _shouldDisposeEventProcessor = false;
            }

            if (_configuration.FeatureStore == null)
            {
                _featureStore = (_configuration.FeatureStoreFactory ??
                                 Components.InMemoryFeatureStore).CreateFeatureStore();
                _shouldDisposeFeatureStore = true;
            }
            else
            {
                _featureStore = _configuration.FeatureStore;
                _shouldDisposeFeatureStore = false; // see previous comment
            }

            _updateProcessor = (_configuration.UpdateProcessorFactory ??
                                Components.DefaultUpdateProcessor).CreateUpdateProcessor(_configuration, _featureStore);

            var initTask = _updateProcessor.Start();

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

            try
            {
                var unused = initTask.Wait(_configuration.StartWaitTime);
            }
            catch (AggregateException)
            {
                // StreamProcessor may throw an exception if initialization fails, because we want that behavior
                // in the Xamarin client. However, for backward compatibility we do not want to throw exceptions
                // from the LdClient constructor in the .NET client, so we'll just swallow this.
            }
        }
예제 #3
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);
        }