public ConfigurationBuilder(Configuration copyFrom) { _allAttributesPrivate = copyFrom.AllAttributesPrivate; _baseUri = copyFrom.BaseUri; _diagnosticOptOut = copyFrom.DiagnosticOptOut; _diagnosticRecordingInterval = copyFrom.DiagnosticRecordingInterval; _eventCapacity = copyFrom.EventCapacity; _eventFlushInterval = copyFrom.EventFlushInterval; _eventProcessorFactory = copyFrom.EventProcessorFactory; #pragma warning disable 618 _eventSamplingInterval = copyFrom.EventSamplingInterval; #pragma warning restore 618 _eventsUri = copyFrom.EventsUri; _featureStore = copyFrom.FeatureStore; _featureStoreFactory = copyFrom.FeatureStoreFactory; _httpClientHandler = copyFrom.HttpClientHandler; _httpClientTimeout = copyFrom.HttpClientTimeout; _inlineUsersInEvents = copyFrom.InlineUsersInEvents; _isStreamingEnabled = copyFrom.IsStreamingEnabled; _offline = copyFrom.Offline; _pollingInterval = copyFrom.PollingInterval; _privateAttributeNames = copyFrom.PrivateAttributeNames is null ? null : new HashSet <string>(copyFrom.PrivateAttributeNames); _readTimeout = copyFrom.ReadTimeout; _reconnectTime = copyFrom.ReconnectTime; _sdkKey = copyFrom.SdkKey; _startWaitTime = copyFrom.StartWaitTime; _streamUri = copyFrom.StreamUri; _updateProcessorFactory = copyFrom.UpdateProcessorFactory; _useLdd = copyFrom.UseLdd; _userKeysCapacity = copyFrom.UserKeysCapacity; _userKeysFlushInterval = copyFrom.UserKeysFlushInterval; _wrapperName = copyFrom.WrapperName; _wrapperVersion = copyFrom.WrapperVersion; }
/// <summary> /// Sets the implementation of <see cref="IUpdateProcessor"/> to be used for receiving feature flag data, /// using a factory object. The default is <see cref="Components.DefaultUpdateProcessor"/>, but /// you may choose to use a custom implementation (for instance, a test fixture). /// </summary> /// <param name="configuration">the configuration</param> /// <param name="factory">the factory object</param> /// <returns>the same <c>Configuration</c> instance</returns> public static Configuration WithUpdateProcessorFactory(this Configuration configuration, IUpdateProcessorFactory factory) { configuration.UpdateProcessorFactory = factory; return(configuration); }
public LdClient(Configuration config, IEventProcessor eventProcessor) { Log.InfoFormat("Starting LaunchDarkly Client {0}", ServerSideClientEnvironment.Instance.Version); _configuration = config; ServerDiagnosticStore diagnosticStore = null; if (!_configuration.DiagnosticOptOut) { diagnosticStore = new ServerDiagnosticStore(_configuration); } if (eventProcessor == null) { IEventProcessorFactory eventProcessorFactory = _configuration.EventProcessorFactory ?? Components.DefaultEventProcessor; if (eventProcessorFactory is IEventProcessorFactoryWithDiagnostics epfwd) { _eventProcessor = epfwd.CreateEventProcessor(_configuration, diagnosticStore); } else { _eventProcessor = eventProcessorFactory.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; } IFeatureStore store; if (_configuration.FeatureStore == null) { store = (_configuration.FeatureStoreFactory ?? Components.InMemoryFeatureStore).CreateFeatureStore(); _shouldDisposeFeatureStore = true; } else { store = _configuration.FeatureStore; _shouldDisposeFeatureStore = false; // see previous comment } _featureStore = new FeatureStoreClientWrapper(store); IUpdateProcessorFactory updateProcessorFactory = _configuration.UpdateProcessorFactory ?? Components.DefaultUpdateProcessor; if (updateProcessorFactory is IUpdateProcessorFactoryWithDiagnostics upfwd) { _updateProcessor = upfwd.CreateUpdateProcessor(_configuration, _featureStore, diagnosticStore); } else { _updateProcessor = updateProcessorFactory.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. } }
public IConfigurationBuilder UpdateProcessorFactory(IUpdateProcessorFactory updateProcessorFactory) { _updateProcessorFactory = updateProcessorFactory; return(this); }