FractalDataWorks.Services.Scheduling.Abstractions
0.4.0-preview.6
dotnet add package FractalDataWorks.Services.Scheduling.Abstractions --version 0.4.0-preview.6
NuGet\Install-Package FractalDataWorks.Services.Scheduling.Abstractions -Version 0.4.0-preview.6
<PackageReference Include="FractalDataWorks.Services.Scheduling.Abstractions" Version="0.4.0-preview.6" />
<PackageVersion Include="FractalDataWorks.Services.Scheduling.Abstractions" Version="0.4.0-preview.6" />
<PackageReference Include="FractalDataWorks.Services.Scheduling.Abstractions" />
paket add FractalDataWorks.Services.Scheduling.Abstractions --version 0.4.0-preview.6
#r "nuget: FractalDataWorks.Services.Scheduling.Abstractions, 0.4.0-preview.6"
#:package FractalDataWorks.Services.Scheduling.Abstractions@0.4.0-preview.6
#addin nuget:?package=FractalDataWorks.Services.Scheduling.Abstractions&version=0.4.0-preview.6&prerelease
#tool nuget:?package=FractalDataWorks.Services.Scheduling.Abstractions&version=0.4.0-preview.6&prerelease
FractalDataWorks.Services.Scheduling.Abstractions
Core abstractions and interfaces for the FractalDataWorks scheduling system, providing cron-based scheduling capabilities with flexible trigger types and execution management.
Overview
This package defines the abstractions for the FractalDataWorks scheduling system, implementing a separation between scheduling (WHEN) and execution (HOW). It provides scheduling capabilities including cron expressions, timezone handling, trigger management, and execution tracking.
Installation
<PackageReference Include="FractalDataWorks.Services.Scheduling.Abstractions" Version="x.x.x" />
Target Framework: netstandard2.0
Key Components
Core Interfaces
IGenericSchedulingService
Main service interface for scheduling operations that applications use. Defined in IGenericSchedulingService.cs.
From IGenericSchedulingService.cs:65-66:
public interface IGenericSchedulingService : IGenericService
{
Key methods include:
CreateSchedule- Create and register a new scheduleUpdateSchedule- Update an existing scheduleDeleteSchedule- Remove a schedule from the systemPauseSchedule/ResumeSchedule- Control schedule executionTriggerSchedule- Trigger immediate executionGetSchedule/GetSchedules- Query schedulesGetScheduleHistory- Retrieve execution history
IGenericScheduler
Core scheduling engine that manages WHEN to trigger process execution. Defined in IGenericScheduler.cs.
From IGenericScheduler.cs:19:
public interface IGenericScheduler : IDisposable, IGenericServiceBase
IGenericSchedule
Interface defining a schedule that specifies WHEN a process should execute. Defined in IGenericSchedule.cs.
From IGenericSchedule.cs:15-64:
public interface IGenericSchedule
{
string ScheduleId { get; }
string ScheduleName { get; }
string ProcessId { get; }
string CronExpression { get; }
DateTime? NextExecution { get; }
bool IsActive { get; }
string TimeZoneId { get; }
IReadOnlyDictionary<string, object>? Metadata { get; }
}
IGenericTrigger
Defines trigger configuration for when a schedule should execute. Defined in IGenericTrigger.cs.
From IGenericTrigger.cs:14-68:
public interface IGenericTrigger
{
string TriggerId { get; }
string TriggerName { get; }
string TriggerType { get; }
IReadOnlyDictionary<string, object> Configuration { get; }
bool IsEnabled { get; }
DateTime CreatedUtc { get; }
DateTime ModifiedUtc { get; }
IReadOnlyDictionary<string, object>? Metadata { get; }
}
TypeCollection: Trigger Types
Trigger types use the TypeCollection pattern for extensible, type-safe trigger implementations.
TriggerTypeBase
Abstract base class for all trigger type implementations. Defined in TriggerTypeBase.cs.
From TriggerTypeBase.cs:11:
public abstract class TriggerTypeBase : TypeOptionBase<int, TriggerTypeBase>, ITypeOption<int, TriggerTypeBase>, ITriggerType
Key members:
RequiresSchedule- Whether this trigger type needs schedule persistenceIsImmediate- Whether this trigger executes immediately upon creationCalculateNextExecution()- Calculate the next execution timeValidateTrigger()- Validate trigger configuration
TriggerTypes Collection
Source-generated TypeCollection for trigger types. Defined in TriggerTypes.cs.
From TriggerTypes.cs:11-12:
[TypeCollection(typeof(TriggerTypeBase), typeof(ITriggerType), typeof(TriggerTypes))]
public abstract partial class TriggerTypes : TypeCollectionBase<TriggerTypeBase, ITriggerType>
Trigger Type Implementations
Cron Trigger
Cron expression-based scheduling with timezone support. Defined in Cron.cs.
From Cron.cs:45-46:
[TypeOption(typeof(TriggerTypes), "Cron")]
public sealed class Cron : TriggerTypeBase
Configuration keys:
CronExpression- The cron expression (e.g., "0 9 * * *")TimeZoneId- Optional timezone identifier (defaults to UTC)
Interval Trigger
Fixed interval-based scheduling. Defined in Interval.cs.
From Interval.cs:52-53:
[TypeOption(typeof(TriggerTypes), "Interval")]
public sealed class Interval : TriggerTypeBase
Configuration keys:
IntervalMinutes- Interval between executions in minutesStartTime- Optional start time for first executionTimeZoneId- Optional timezone identifier
Once Trigger
Single execution at a specified time. Defined in Once.cs.
From Once.cs:52-53:
[TypeOption(typeof(TriggerTypes), "Once")]
public sealed class Once : TriggerTypeBase
Configuration keys:
StartTime- The specific date/time to executeTimeZoneId- Optional timezone identifier
Manual Trigger
Manual trigger only (no automatic scheduling). Defined in Manual.cs.
From Manual.cs:52-53:
[TypeOption(typeof(TriggerTypes), "Manual")]
public sealed class Manual : TriggerTypeBase
Configuration keys:
Description- Optional descriptionRequiredRole- Optional role requirementAllowConcurrent- Whether concurrent executions are allowed
Model Classes
Schedule
Default implementation of IGenericSchedule with validation and state management. Defined in Schedule.cs.
From Schedule.cs:58:
public sealed class Schedule : IGenericSchedule
Factory methods from Schedule.cs:252-260:
public static Schedule CreateNew(
string name,
string processType,
object processConfiguration,
IGenericTrigger trigger,
string? description = null,
bool isActive = true,
IReadOnlyDictionary<string, object>? metadata = null)
And from Schedule.cs:336-348:
public static Schedule Create(
string id,
string name,
string processType,
object processConfiguration,
IGenericTrigger trigger,
DateTime createdAt,
DateTime updatedAt,
string? description = null,
bool isActive = true,
string? processId = null,
DateTime? nextExecution = null,
IReadOnlyDictionary<string, object>? metadata = null)
Trigger
Default implementation of IGenericTrigger with factory methods for each trigger type. Defined in Trigger.cs.
From Trigger.cs:57:
public sealed class Trigger : IGenericTrigger
Factory methods:
From Trigger.cs:243-250:
public static Trigger CreateCron(
string name,
string cronExpression,
string? timeZoneId = null,
string? description = null,
bool isEnabled = true,
IReadOnlyDictionary<string, object>? metadata = null)
From Trigger.cs:332-339:
public static Trigger CreateInterval(
string name,
int intervalMinutes,
int startDelayMinutes = 0,
string? description = null,
bool isEnabled = true,
IReadOnlyDictionary<string, object>? metadata = null)
From Trigger.cs:425-431:
public static Trigger CreateOnce(
string name,
DateTime executeAtUtc,
string? description = null,
bool isEnabled = true,
IReadOnlyDictionary<string, object>? metadata = null)
From Trigger.cs:507-514:
public static Trigger CreateManual(
string name,
string? description = null,
string? requiredRole = null,
bool allowConcurrent = true,
bool isEnabled = true,
IReadOnlyDictionary<string, object>? metadata = null)
Dependencies
Package References
Cronos- Cron expression parsing and calculationMicrosoft.Extensions.DependencyInjection.Abstractions- DI supportMicrosoft.Extensions.Diagnostics.HealthChecks- Health check integrationMicrosoft.Extensions.Logging.Abstractions- Logging contracts
Project References
FractalDataWorks.Configuration.Abstractions- Configuration contractsFractalDataWorks.Configuration- Configuration implementationFractalDataWorks.Services.Execution.Abstractions- Process execution contractsFractalDataWorks.Messages- Messaging infrastructureFractalDataWorks.Results- Result pattern implementationFractalDataWorks.Services.Abstractions- Service abstractionsFractalDataWorks.Services.Abstractions- ServiceType infrastructureFractalDataWorks.Services.SecretManagers.Abstractions- Secret managementFractalDataWorks.MessageLogging.SourceGenerators- Build-time message logging
Usage Examples
Creating a Cron Trigger
From Trigger.cs:243-285 (factory method usage):
// Create a daily backup trigger at 2 AM Eastern Time
var cronTrigger = Trigger.CreateCron(
name: "Daily Backup Trigger",
cronExpression: "0 2 * * *",
timeZoneId: "America/New_York",
description: "Automated daily backup trigger"
);
Creating a Schedule
From Schedule.cs:252-292 (factory method usage):
// Create a new schedule with a cron trigger
var schedule = Schedule.CreateNew(
name: "Daily Database Backup",
processType: "DatabaseBackup",
processConfiguration: new { DatabaseName = "Production" },
trigger: cronTrigger,
description: "Automated daily backup of production database"
);
// Validate the schedule
var validationResult = schedule.Validate();
if (validationResult.Error)
{
// Handle validation errors
}
Creating Other Trigger Types
From Trigger.cs:332-380 (interval trigger):
// Every 30 minutes
var intervalTrigger = Trigger.CreateInterval(
name: "Health Check",
intervalMinutes: 30,
description: "Regular health check every 30 minutes"
);
From Trigger.cs:425-461 (once trigger):
// One-time execution
var onceTrigger = Trigger.CreateOnce(
name: "Maintenance Window",
executeAtUtc: DateTime.UtcNow.AddHours(24),
description: "Scheduled maintenance"
);
From Trigger.cs:507-549 (manual trigger):
// Manual execution only
var manualTrigger = Trigger.CreateManual(
name: "Manual Backup",
description: "On-demand database backup",
requiredRole: "Administrator",
allowConcurrent: false
);
Validating Triggers
From Trigger.cs:593-623:
var trigger = Trigger.CreateCron("Daily Report", "0 9 * * *", "UTC");
var validationResult = trigger.Validate();
if (validationResult.Error)
{
// Handle validation errors
}
Architecture Notes
Separation of Concerns
The scheduling system follows clear separation:
- Scheduling (WHEN): Handled by
IGenericSchedulerand trigger types - Execution (HOW): Handled by
IGenericScheduledExecutionHandler - Service Layer:
IGenericSchedulingServiceprovides application-facing API
Cron Expression Features
Using the Cronos library, the system supports:
- Standard 5-field cron expressions (minute precision)
- Extended 6-field cron expressions (second precision)
- Cron descriptors (
@yearly,@monthly,@daily,@hourly) - Timezone-aware calculations with DST handling
TypeCollection Pattern
Trigger types use the TypeCollection pattern for:
- Type-safe trigger type definitions
- Extensible trigger implementations
- Source-generated collections and lookups
- Compile-time validation
Related Packages
- FractalDataWorks.Results - Result pattern
- FractalDataWorks.Services.Abstractions - Service contracts
- FractalDataWorks.Services.Execution.Abstractions - Execution contracts
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Cronos (>= 0.11.1)
- FractalDataWorks.Collections (>= 0.4.0-preview.6)
- FractalDataWorks.Configuration.Abstractions (>= 0.4.0-preview.6)
- FractalDataWorks.Messages (>= 0.4.0-preview.6)
- FractalDataWorks.Results (>= 0.4.0-preview.6)
- FractalDataWorks.Services.Abstractions (>= 0.4.0-preview.6)
- FractalDataWorks.Services.Execution.Abstractions (>= 0.4.0-preview.6)
- FractalDataWorks.Services.SecretManagers.Abstractions (>= 0.4.0-preview.6)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.1)
- Microsoft.Extensions.Diagnostics.HealthChecks (>= 10.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.1)
- System.Collections.Immutable (>= 10.0.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|