public RabbitMqStreamProviderOptions(IProviderConfiguration config) { if (config == null) { throw new ArgumentNullException(nameof(config)); } if (!config.Properties.ContainsKey(nameof(UserName))) { throw new ArgumentException("Missing required parameter!", nameof(UserName)); } if (!config.Properties.ContainsKey(nameof(Password))) { throw new ArgumentException("Missing required parameter!", nameof(Password)); } if (!config.Properties.ContainsKey(nameof(QueueNamePrefix))) { throw new ArgumentException("Missing required parameter!", nameof(QueueNamePrefix)); } HostName = config.GetProperty(nameof(HostName), DefaultHostName); VirtualHost = config.GetProperty(nameof(VirtualHost), DefaultVirtualHost); Port = config.GetIntProperty(nameof(Port), DefaultPort); UserName = config.GetProperty(nameof(UserName), string.Empty); Password = config.GetProperty(nameof(Password), string.Empty); CacheSize = config.GetIntProperty(nameof(CacheSize), DefaultCacheSize); CacheFillingTimeout = config.GetTimeSpanProperty(nameof(CacheFillingTimeout), DefaultCacheFillingTimeout); QueueNamePrefix = config.GetProperty(nameof(QueueNamePrefix), string.Empty); NumberOfQueues = config.GetIntProperty(nameof(NumberOfQueues), DefaultNumberOfQueues); }
/// <summary> Init the factory.</summary> public virtual void Init(IProviderConfiguration config, string providerName, Logger logger, IServiceProvider serviceProvider) { if (config == null) { throw new ArgumentNullException("config"); } if (!config.Properties.TryGetValue(DataConnectionStringPropertyName, out dataConnectionString)) { throw new ArgumentException(string.Format("{0} property not set", DataConnectionStringPropertyName)); } if (!config.Properties.TryGetValue(DeploymentIdPropertyName, out deploymentId)) { throw new ArgumentException(string.Format("{0} property not set", DeploymentIdPropertyName)); } cacheSize = SimpleQueueAdapterCache.ParseSize(config, CacheSizeDefaultValue); numQueues = config.GetIntProperty(NumQueuesPropertyName, NumQueuesDefaultValue); this.providerName = providerName; streamQueueMapper = new HashRingBasedStreamQueueMapper(numQueues, providerName); adapterCache = new SimpleQueueAdapterCache(cacheSize, logger); if (StreamFailureHandlerFactory == null) { StreamFailureHandlerFactory = qid => Task.FromResult <IStreamFailureHandler>(new NoOpStreamDeliveryFailureHandler(false)); } }
/// <summary> /// Read settings from provider configuration. /// </summary> /// <param name="providerConfiguration"></param> public void PopulateFromProviderConfig(IProviderConfiguration providerConfiguration) { EventHubSettingsType = providerConfiguration.GetTypeProperty(EventHubConfigTypeName, null); CheckpointerSettingsType = providerConfiguration.GetTypeProperty(CheckpointerSettingsTypeName, null); if (string.IsNullOrWhiteSpace(StreamProviderName)) { throw new ArgumentOutOfRangeException(nameof(providerConfiguration), "StreamProviderName not set."); } CacheSizeMb = providerConfiguration.GetIntProperty(CacheSizeMbName, DefaultCacheSizeMb); DataMinTimeInCache = providerConfiguration.GetTimeSpanProperty(DataMinTimeInCacheName, DefaultDataMinTimeInCache); DataMaxAgeInCache = providerConfiguration.GetTimeSpanProperty(DataMaxAgeInCacheName, DefaultDataMaxAgeInCache); double flowControlThreshold = 0; if (providerConfiguration.TryGetDoubleProperty(SlowConsumingMonitorFlowControlThresholdName, out flowControlThreshold)) { this.SlowConsumingMonitorFlowControlThreshold = flowControlThreshold; } TimeSpan pressureWindowSize = TimeSpan.Zero; if (providerConfiguration.TryGetTimeSpanProperty(SlowConsumingMonitorPressureWindowSizeName, out pressureWindowSize)) { this.SlowConsumingMonitorPressureWindowSize = pressureWindowSize; } if (providerConfiguration.TryGetDoubleProperty(AveragingCachePressureMonitorFlowControlThresholdName, out flowControlThreshold)) { if (flowControlThreshold >= CachePressureMonitorOffThreshold) this.AveragingCachePressureMonitorFlowControlThreshold = null; else this.AveragingCachePressureMonitorFlowControlThreshold = flowControlThreshold; } }
public virtual void PopulateFromProviderConfig(IProviderConfiguration providerConfiguration) { EventHubSettingsType = providerConfiguration.GetTypeProperty(EventHubConfigTypeName, null); if (string.IsNullOrWhiteSpace(StreamProviderName)) { throw new ArgumentOutOfRangeException("providerConfiguration", "StreamProviderName not set."); } CacheSizeMb = providerConfiguration.GetIntProperty(CacheSizeMbName, DefaultCacheSizeMb); }
/// <summary> /// Utility function to populate config from provider config /// </summary> /// <param name="providerConfiguration"></param> public virtual void PopulateFromProviderConfig(IProviderConfiguration providerConfiguration) { GeneratorConfigType = providerConfiguration.GetTypeProperty(GeneratorConfigTypeName, null); if (string.IsNullOrWhiteSpace(StreamProviderName)) { throw new ArgumentOutOfRangeException("providerConfiguration", "StreamProviderName not set."); } TotalQueueCount = providerConfiguration.GetIntProperty(TotalQueueCountName, TotalQueueCountDefault); }
/// <summary> /// Read settings from provider configuration. /// </summary> /// <param name="providerConfiguration"></param> public void PopulateFromProviderConfig(IProviderConfiguration providerConfiguration) { EventHubSettingsType = providerConfiguration.GetTypeProperty(EventHubConfigTypeName, null); CheckpointerSettingsType = providerConfiguration.GetTypeProperty(CheckpointerSettingsTypeName, null); if (string.IsNullOrWhiteSpace(StreamProviderName)) { throw new ArgumentOutOfRangeException("providerConfiguration", "StreamProviderName not set."); } CacheSizeMb = providerConfiguration.GetIntProperty(CacheSizeMbName, DefaultCacheSizeMb); DataMinTimeInCache = providerConfiguration.GetTimeSpanProperty(DataMinTimeInCacheName, DefaultDataMinTimeInCache); DataMaxAgeInCache = providerConfiguration.GetTimeSpanProperty(DataMaxAgeInCacheName, DefaultDataMaxAgeInCache); }
public RabbitMQStreamProviderConfig(IProviderConfiguration config) { NumQueues = GetOptionalIntProperty(config, "NumQueues", 8); HostName = config.Properties["HostName"]; Port = config.GetIntProperty("Port", 5671); VirtualHost = config.Properties["VirtualHost"]; Exchange = config.Properties["Exchange"]; ExchangeType = config.GetProperty("ExchangeType", "Direct").ToLowerInvariant(); ExchangeDurable = config.GetBoolProperty("ExchangeDurable", false); AutoDelete = config.GetBoolProperty("AutoDelete", false); Queue = config.Properties["Queue"]; QueueDurable = config.GetBoolProperty("QueueDurable", false); Namespace = config.Properties["Namespace"]; RoutingKey = config.Properties["RoutingKey"]; Username = config.Properties["Username"]; Password = config.Properties["Password"]; }
public RabbitMQStreamProviderConfiguration(IProviderConfiguration config) { string deployementId; if (!config.Properties.TryGetValue("DeploymentId", out deployementId)) { throw new ArgumentException("DeploymentId property not set"); } DeployementId = deployementId; NumQueues = config.GetIntProperty("NumQueues", 8); Exchange = config.Properties["Exchange"]; ExchangeType = config.GetProperty("ExchangeType", "Direct").ToLowerInvariant(); ExchangeDurable = config.GetBoolProperty("ExchangeDurable", false); AutoDelete = config.GetBoolProperty("AutoDelete", false); Queue = config.Properties["Queue"]; QueueDurable = config.GetBoolProperty("QueueDurable", false); RoutingKey = config.Properties["RoutingKey"]; QueueOperationTimeout = config.GetTimeSpanProperty("QueueOperationTimeout", TimeSpan.FromSeconds(15)); DataConnectionString = config.GetProperty("DataConnectionString", null); }
/// <summary> Init the factory.</summary> public virtual void Init(IProviderConfiguration config, string providerName, Logger logger, IServiceProvider serviceProvider) { if (config == null) throw new ArgumentNullException("config"); if (!config.Properties.TryGetValue(DataConnectionStringPropertyName, out dataConnectionString)) throw new ArgumentException(string.Format("{0} property not set", DataConnectionStringPropertyName)); if (!config.Properties.TryGetValue(DeploymentIdPropertyName, out deploymentId)) throw new ArgumentException(string.Format("{0} property not set", DeploymentIdPropertyName)); cacheSize = SimpleQueueAdapterCache.ParseSize(config, CacheSizeDefaultValue); numQueues = config.GetIntProperty(NumQueuesPropertyName, NumQueuesDefaultValue); this.providerName = providerName; streamQueueMapper = new HashRingBasedStreamQueueMapper(numQueues, providerName); adapterCache = new SimpleQueueAdapterCache(cacheSize, logger); if (StreamFailureHandlerFactory == null) { StreamFailureHandlerFactory = qid => Task.FromResult<IStreamFailureHandler>(new NoOpStreamDeliveryFailureHandler(false)); } }
/// <summary> /// Utility function to populate config from provider config /// </summary> /// <param name="providerConfiguration"></param> public virtual void PopulateFromProviderConfig(IProviderConfiguration providerConfiguration) { ConnectionString = providerConfiguration.GetProperty(ConnectionStringName, null); if (string.IsNullOrWhiteSpace(ConnectionString)) { throw new ArgumentOutOfRangeException("providerConfiguration", ConnectionStringName + " not set."); } ConsumerGroup = providerConfiguration.GetProperty(ConsumerGroupName, null); if (string.IsNullOrWhiteSpace(ConsumerGroup)) { throw new ArgumentOutOfRangeException("providerConfiguration", ConsumerGroupName + " not set."); } Path = providerConfiguration.GetProperty(PathName, null); if (string.IsNullOrWhiteSpace(Path)) { throw new ArgumentOutOfRangeException("providerConfiguration", PathName + " not set."); } PrefetchCount = providerConfiguration.GetIntProperty(PrefetchCountName, InvalidPrefetchCount); if (PrefetchCount == InvalidPrefetchCount) { PrefetchCount = null; } }
/// <summary> /// Utility function to populate config from provider config /// </summary> /// <param name="providerConfiguration"></param> public void PopulateFromProviderConfig(IProviderConfiguration providerConfiguration) { EventsInStream = providerConfiguration.GetIntProperty(EventsInStreamName, EventsInStreamDefault); StreamNamespace = providerConfiguration.GetProperty(StreamNamespaceName, null); }
public static int ParseSize(IProviderConfiguration config, int defaultSize) { return config.GetIntProperty(CACHE_SIZE_PARAM, defaultSize); }
public static int ParseSize(IProviderConfiguration config, int defaultSize) { return config.GetIntProperty(CacheSizePropertyName, defaultSize); }
/// <summary> /// Utility function to populate config from provider config /// </summary> /// <param name="providerConfiguration"></param> public void PopulateFromProviderConfig(IProviderConfiguration providerConfiguration) { TotalQueueCount = providerConfiguration.GetIntProperty(TotalQueueCountName, TotalQueueCountDefault); }
/// <summary> /// Populate data generating config from provider config /// </summary> /// <param name="providerConfiguration"></param> public void PopulateDataGeneratingConfigFromProviderConfig(IProviderConfiguration providerConfiguration) { this.streamDataGeneratorType = providerConfiguration.GetTypeProperty(StreamDataGeneratorTypeName, DefaultStreamDataGeneratorType); this.EventHubPartitionCount = providerConfiguration.GetIntProperty(EventHubPartitionCountName, DefaultEventHubPartitionCount); }
/// <summary> /// Parse the size property from configuration /// </summary> /// <param name="config"></param> /// <param name="defaultSize"></param> /// <returns></returns> public static int ParseSize(IProviderConfiguration config, int defaultSize) { return(config.GetIntProperty(CacheSizePropertyName, defaultSize)); }
/// <summary> /// Read settings from provider configuration. /// </summary> /// <param name="providerConfiguration"></param> public void PopulateFromProviderConfig(IProviderConfiguration providerConfiguration) { EventHubSettingsType = providerConfiguration.GetTypeProperty(EventHubConfigTypeName, null); CheckpointerSettingsType = providerConfiguration.GetTypeProperty(CheckpointerSettingsTypeName, null); if (string.IsNullOrWhiteSpace(StreamProviderName)) { throw new ArgumentOutOfRangeException(nameof(providerConfiguration), "StreamProviderName not set."); } CacheSizeMb = providerConfiguration.GetIntProperty(CacheSizeMbName, DefaultCacheSizeMb); DataMinTimeInCache = providerConfiguration.GetTimeSpanProperty(DataMinTimeInCacheName, DefaultDataMinTimeInCache); DataMaxAgeInCache = providerConfiguration.GetTimeSpanProperty(DataMaxAgeInCacheName, DefaultDataMaxAgeInCache); }
public static int ParseSize(IProviderConfiguration config, int defaultSize) { return(config.GetIntProperty(CACHE_SIZE_PARAM, defaultSize)); }