private void Initialize(IEnvironmentVariableReader reader, Lazy <IPluginDiscoverer> pluginDiscoverer, Func <TimeSpan, IPluginFactory> pluginFactoryCreator, Lazy <string> pluginsCacheDirectoryPath) { EnvironmentVariableReader = reader ?? throw new ArgumentNullException(nameof(reader)); _discoverer = pluginDiscoverer ?? throw new ArgumentNullException(nameof(pluginDiscoverer)); _pluginsCacheDirectoryPath = pluginsCacheDirectoryPath ?? throw new ArgumentNullException(nameof(pluginsCacheDirectoryPath)); if (pluginFactoryCreator == null) { throw new ArgumentNullException(nameof(pluginFactoryCreator)); } #if IS_DESKTOP _rawPluginPaths = reader.GetEnvironmentVariable(EnvironmentVariableConstants.DesktopPluginPaths); #else _rawPluginPaths = reader.GetEnvironmentVariable(EnvironmentVariableConstants.CorePluginPaths); #endif if (string.IsNullOrEmpty(_rawPluginPaths)) { _rawPluginPaths = reader.GetEnvironmentVariable(EnvironmentVariableConstants.PluginPaths); } _connectionOptions = ConnectionOptions.CreateDefault(reader); var idleTimeoutInSeconds = EnvironmentVariableReader.GetEnvironmentVariable(EnvironmentVariableConstants.IdleTimeout); var idleTimeout = TimeoutUtilities.GetTimeout(idleTimeoutInSeconds, PluginConstants.IdleTimeout); _pluginFactory = pluginFactoryCreator(idleTimeout); _pluginOperationClaims = new ConcurrentDictionary <PluginRequestKey, Lazy <Task <IReadOnlyList <OperationClaim> > > >(); _pluginUtilities = new ConcurrentDictionary <string, Lazy <IPluginMulticlientUtilities> >( StringComparer.OrdinalIgnoreCase); }
/// <summary> /// Instantiates a <see cref="ConnectionOptions" /> class with default values. /// </summary> /// <param name="reader">An environment variable reader.</param> /// <returns>A <see cref="ConnectionOptions" />.</returns> public static ConnectionOptions CreateDefault(IEnvironmentVariableReader reader = null) { reader = reader ?? new EnvironmentVariableWrapper(); var handshakeTimeoutInSeconds = reader.GetEnvironmentVariable(EnvironmentVariableConstants.HandshakeTimeout); var requestTimeoutInSeconds = reader.GetEnvironmentVariable(EnvironmentVariableConstants.RequestTimeout); var handshakeTimeout = TimeoutUtilities.GetTimeout(handshakeTimeoutInSeconds, ProtocolConstants.HandshakeTimeout); var requestTimeout = TimeoutUtilities.GetTimeout(requestTimeoutInSeconds, ProtocolConstants.RequestTimeout); return(new ConnectionOptions( protocolVersion: ProtocolConstants.CurrentVersion, minimumProtocolVersion: ProtocolConstants.Version100, handshakeTimeout: handshakeTimeout, requestTimeout: requestTimeout)); }