private static BackgroundTask NewTask(BackgroundTaskOptions options, IBackgroundTaskSerializer serializer, Type type, object userData) { var handlerInfo = new HandlerInfo(type.Namespace, type.Name); var task = new BackgroundTask { Handler = serializer?.Serialize(handlerInfo), Data = userData == null ? null : JsonSerializer.Serialize(userData) }; options.ProvisionTask(task); return(task); }
private static void MigrateToLatest(BackgroundTaskOptions taskOptions, DocumentDbOptions dbOptions) { var runner = new DocumentDbMigrationRunner(dbOptions); if (taskOptions.Store.CreateIfNotExists) { runner.CreateDatabaseIfNotExistsAsync().GetAwaiter().GetResult(); } if (taskOptions.Store.MigrateOnStartup) { runner.CreateCollectionIfNotExistsAsync().GetAwaiter().GetResult(); } }
private BackgroundTask CreateNewTask() { var task = new BackgroundTask(); var options = new BackgroundTaskOptions(); // these values are required and must be set by implementation task.Handler = "{}"; task.MaximumAttempts = options.MaximumAttempts; task.MaximumRuntime = TimeSpan.FromSeconds(options.MaximumRuntimeSeconds); task.DeleteOnError = options.DeleteOnError; task.DeleteOnFailure = options.DeleteOnFailure; task.DeleteOnSuccess = options.DeleteOnSuccess; task.RunAt = Store.GetTaskTimestamp(); return(task); }
private void OnSettingsChanged(BackgroundTaskOptions changed) { _logger.Info(() => "Background task options changed, recycling the host."); Stop(); Start(); }
private static void MigrateToLatest(string connectionString, BackgroundTaskOptions options) { var runner = new SqliteMigrationRunner(connectionString, new SqliteConnectionOptions(options.Store)); runner.OnStartAsync <CreateBackgroundTasksSchema>().GetAwaiter().GetResult(); }