Exemple #1
0
		private static string hidePassword(StoredConfiguration x)
		{
			const string hiddenPassword = "******";
			return x.ConnectionString.ToDbVendorSelector().SelectDialect(
				() => new SqlConnectionStringBuilder(x.ConnectionString).Password == string.Empty ? x.ConnectionString : new SqlConnectionStringBuilder(x.ConnectionString) {Password = hiddenPassword}.ToString(),
				() =>
				{
					var parsed = NpgsqlConnectionStringBuilderWorkaround.Parse(x.ConnectionString);
					if (parsed.Password == null)
						return x.ConnectionString;
					parsed.Password = hiddenPassword;
					return parsed.ToString();
				},
				() =>
				{
#if Redis
					var parsed = StackExchange.Redis.ConfigurationOptions.Parse(x.ConnectionString);
					if (parsed.Password != null)
						parsed.Password = hiddenPassword;
					return parsed.ToString();
#else
					return x.ConnectionString;
#endif
				});
		}
Exemple #2
0
        internal int DetermineWorkerCount(IMonitoringApi monitor,
                                          StoredConfiguration configuration,
                                          WorkerDeterminerOptions options)
        {
            var goal = configuration.GoalWorkerCount ?? options.DefaultGoalWorkerCount;

            if (goal > options.MaximumGoalWorkerCount)
            {
                goal = options.MaximumGoalWorkerCount;
            }

            var serverCount = _serverCountDeterminer.DetermineServerCount(monitor, options);

            var workerCount = Convert.ToInt32(Math.Ceiling(goal / (decimal)serverCount));

            if (configuration.MaxWorkersPerServer.HasValue)
            {
                if (workerCount > configuration.MaxWorkersPerServer.Value)
                {
                    workerCount = configuration.MaxWorkersPerServer.Value;
                }
            }

            if (workerCount < options.MinimumWorkerCount)
            {
                workerCount = options.MinimumWorkerCount;
            }

            return(workerCount);
        }
Exemple #3
0
        private static bool isMarked(StoredConfiguration configuration)
        {
            var applicationName = configuration.ConnectionString.ApplicationName();

            if (applicationName == null)
            {
                return(false);
            }
            return(applicationName.EndsWith(".AutoUpdate"));
        }
Exemple #4
0
 public ConfigurationState(
     StoredConfiguration configuration,
     Func <JobStorage> jobStorageCreator
     )
 {
     Configuration        = configuration;
     _jobStorage          = new Lazy <JobStorage>(jobStorageCreator, LazyThreadSafetyMode.ExecutionAndPublication);
     _backgroundJobClient = new Lazy <IBackgroundJobClient>(() => new BackgroundJobClient(JobStorage), LazyThreadSafetyMode.ExecutionAndPublication);
     _recurringJobManager = new Lazy <IRecurringJobManager>(() => new RecurringJobManager(JobStorage), LazyThreadSafetyMode.ExecutionAndPublication);
     _monitoringApi       = new Lazy <IMonitoringApi>(() => JobStorage.GetMonitoringApi(), LazyThreadSafetyMode.ExecutionAndPublication);
 }
        public void ShouldBuildWithDefaultSchemaNameForRedis()
        {
            var system = new SystemUnderTest();
            var storedConfiguration = new StoredConfiguration
            {
                ConnectionString = "redis-roger",
                SchemaName       = null
            };

            system.ConfigurationStorage.Has(storedConfiguration);

            var result = system.ViewModelBuilder.BuildServerConfigurations();

            Assert.AreEqual(DefaultSchemaName.Redis(), result.Single().SchemaName);
        }
        private StoredConfiguration matchingConfiguration(int?configurationId)
        {
            var configurations = _storage.ReadConfigurations();
            var configuration  = new StoredConfiguration();

            if (configurations.Any())
            {
                if (configurationId != null)
                {
                    configuration = configurations.FirstOrDefault(x => x.Id == configurationId);
                }
                else
                {
                    configuration = configurations.FirstOrDefault(x => x.Active.GetValueOrDefault());
                }

                if (configuration == null)
                {
                    configuration = configurations.First();
                }
            }

            return(configuration);
        }
 public void WriteConfiguration(StoredConfiguration configuration) =>
 _storage.WriteConfiguration(configuration);
Exemple #8
0
 private static bool sameConfiguration(UpdateStorageConfiguration received, StoredConfiguration stored) =>
 stored.Name == received.Name &&
 stored.SchemaName == received.SchemaName &&
 received.ConnectionString?.Replace(".AutoUpdate", "") == stored.ConnectionString?.Replace(".AutoUpdate", "");
Exemple #9
0
 private static bool isLegacy(StoredConfiguration configuration) =>
 configuration.ConnectionString == null;
Exemple #10
0
 public SystemUnderTest WithConfiguration(StoredConfiguration configurations)
 {
     ConfigurationStorage.Has(configurations);
     return(this);
 }