SqlOrchestrationService GetOrchestrationService() { if (this.service == null) { SqlOrchestrationServiceSettings settings = this.GetOrchestrationServiceSettings(); this.service = new SqlOrchestrationService(settings); } return(this.service); }
IOrchestrationService CreateServiceWithTestDb(TestDatabase testDb) { var options = new SqlOrchestrationServiceSettings(testDb.ConnectionString) { LoggerFactory = LoggerFactory.Create(builder => { builder.SetMinimumLevel(LogLevel.Trace); builder.AddProvider(this.logProvider); }), }; return(new SqlOrchestrationService(options)); }
internal SqlOrchestrationServiceSettings GetOrchestrationServiceSettings( DurableTaskOptions extensionOptions, IConnectionStringResolver connectionStringResolver) { if (connectionStringResolver == null) { throw new ArgumentNullException(nameof(connectionStringResolver)); } string?connectionString = connectionStringResolver.Resolve(this.ConnectionStringName); if (string.IsNullOrEmpty(connectionString)) { throw new InvalidOperationException( $"No SQL connection string configuration was found for the app setting or environment variable named '{this.ConnectionStringName}'."); } // Validate the connection string try { new SqlConnectionStringBuilder(connectionString); } catch (ArgumentException e) { throw new ArgumentException("The provided connection string is invalid.", e); } var settings = new SqlOrchestrationServiceSettings(connectionString, this.TaskHubName) { CreateDatabaseIfNotExists = this.CreateDatabaseIfNotExists, LoggerFactory = this.LoggerFactory, WorkItemBatchSize = this.TaskEventBatchSize, WorkItemLockTimeout = this.TaskEventLockTimeout, }; if (extensionOptions.MaxConcurrentActivityFunctions.HasValue) { settings.MaxConcurrentActivities = extensionOptions.MaxConcurrentActivityFunctions.Value; } if (extensionOptions.MaxConcurrentOrchestratorFunctions.HasValue) { settings.MaxActiveOrchestrations = extensionOptions.MaxConcurrentOrchestratorFunctions.Value; } return(settings); }
public static async Task InitializeDatabaseAsync() { var options = new SqlOrchestrationServiceSettings(GetDefaultConnectionString()); var service = new SqlOrchestrationService(options); await service.CreateIfNotExistsAsync(); }