public void DefaultValues()
        {
            var config = new FunctionResultAggregatorConfiguration();

            Assert.Equal(TimeSpan.FromSeconds(30), config.FlushTimeout);
            Assert.Equal(1000, config.BatchSize);
            Assert.Equal(true, config.IsEnabled);
        }
示例#2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="JobHostConfiguration"/> class, using the
        /// specified connection string for both reading and writing data as well as Dashboard logging.
        /// </summary>
        /// <param name="dashboardAndStorageConnectionString">The Azure Storage connection string to use.
        /// <param name="configuration">A configuration object that will be used as the source of application settings.</param>
        /// </param>
        public JobHostConfiguration(string dashboardAndStorageConnectionString, IConfiguration configuration)
        {
            if (configuration != null)
            {
                ConfigurationUtility.SetConfigurationFactory(() => configuration);
            }

            if (!string.IsNullOrEmpty(dashboardAndStorageConnectionString))
            {
                _storageAccountProvider = new DefaultStorageAccountProvider(this, dashboardAndStorageConnectionString);
            }
            else
            {
                _storageAccountProvider = new DefaultStorageAccountProvider(this);
            }

            var sasBlobContainer = _storageAccountProvider.InternalSasStorage;

            if (sasBlobContainer != null)
            {
                var uri          = new Uri(sasBlobContainer);
                var sdkContainer = new CloudBlobContainer(uri);

                this.InternalStorageConfiguration = new JobHostInternalStorageConfiguration
                {
                    InternalContainer = sdkContainer
                };
            }

            Singleton  = new SingletonConfiguration();
            Aggregator = new FunctionResultAggregatorConfiguration();

            // add our built in services here
            IExtensionRegistry       extensions       = new DefaultExtensionRegistry();
            ITypeLocator             typeLocator      = new DefaultTypeLocator(ConsoleProvider.Out, extensions);
            IConverterManager        converterManager = new ConverterManager();
            IWebJobsExceptionHandler exceptionHandler = new WebJobsExceptionHandler();

            AddService <IQueueConfiguration>(_queueConfiguration);
            AddService <IConsoleProvider>(ConsoleProvider);
            AddService <ILoggerFactory>(new LoggerFactory());
            AddService <IStorageAccountProvider>(_storageAccountProvider);
            AddService <IExtensionRegistry>(extensions);
            AddService <StorageClientFactory>(new StorageClientFactory());
            AddService <INameResolver>(new DefaultNameResolver());
            AddService <IJobActivator>(DefaultJobActivator.Instance);
            AddService <ITypeLocator>(typeLocator);
            AddService <IConverterManager>(converterManager);
            AddService <IWebJobsExceptionHandler>(exceptionHandler);
            AddService <IFunctionResultAggregatorFactory>(new FunctionResultAggregatorFactory());

            string value = ConfigurationUtility.GetSetting(Host.Constants.EnvironmentSettingName);

            IsDevelopment = string.Compare(Host.Constants.DevelopmentEnvironmentValue, value, StringComparison.OrdinalIgnoreCase) == 0;
        }
        public void FlushTimeout_Limits(TimeSpan flushTimeout, bool throws)
        {
            var config = new FunctionResultAggregatorConfiguration();
            ArgumentOutOfRangeException caughtEx = null;

            try
            {
                config.FlushTimeout = flushTimeout;
            }
            catch (ArgumentOutOfRangeException ex)
            {
                caughtEx = ex;
            }

            Assert.Equal(throws, caughtEx != null);
        }
        public void BatchSize_Limits(int batchSize, bool throws)
        {
            var config = new FunctionResultAggregatorConfiguration();
            ArgumentOutOfRangeException caughtEx = null;

            try
            {
                config.BatchSize = batchSize;
            }
            catch (ArgumentOutOfRangeException ex)
            {
                caughtEx = ex;
            }

            Assert.Equal(throws, caughtEx != null);
        }
示例#5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="JobHostConfiguration"/> class, using the
        /// specified connection string for both reading and writing data as well as Dashboard logging.
        /// </summary>
        /// <param name="dashboardAndStorageConnectionString">The Azure Storage connection string to use.
        /// </param>
        public JobHostConfiguration(string dashboardAndStorageConnectionString)
        {
            if (!string.IsNullOrEmpty(dashboardAndStorageConnectionString))
            {
                _storageAccountProvider = new DefaultStorageAccountProvider(this, dashboardAndStorageConnectionString);
            }
            else
            {
                _storageAccountProvider = new DefaultStorageAccountProvider(this);
            }

            Singleton  = new SingletonConfiguration();
            Aggregator = new FunctionResultAggregatorConfiguration();

            // add our built in services here
            _tooling = new JobHostMetadataProvider(this);
            IExtensionRegistry       extensions       = new DefaultExtensionRegistry(_tooling);
            ITypeLocator             typeLocator      = new DefaultTypeLocator(ConsoleProvider.Out, extensions);
            IConverterManager        converterManager = new ConverterManager();
            IWebJobsExceptionHandler exceptionHandler = new WebJobsExceptionHandler();

            AddService <IQueueConfiguration>(_queueConfiguration);
            AddService <IConsoleProvider>(ConsoleProvider);
            AddService <IStorageAccountProvider>(_storageAccountProvider);
            AddService <IExtensionRegistry>(extensions);
            AddService <StorageClientFactory>(new StorageClientFactory());
            AddService <INameResolver>(new DefaultNameResolver());
            AddService <IJobActivator>(DefaultJobActivator.Instance);
            AddService <ITypeLocator>(typeLocator);
            AddService <IConverterManager>(converterManager);
            AddService <IWebJobsExceptionHandler>(exceptionHandler);
            AddService <IFunctionResultAggregatorFactory>(new FunctionResultAggregatorFactory());

            string value = ConfigurationUtility.GetSettingFromConfigOrEnvironment(Host.Constants.EnvironmentSettingName);

            IsDevelopment = string.Compare(Host.Constants.DevelopmentEnvironmentValue, value, StringComparison.OrdinalIgnoreCase) == 0;
        }