FractalDataWorks.Services.Scheduling.Abstractions
0.9.0-alpha.1011.ged0a6c6e98
dotnet add package FractalDataWorks.Services.Scheduling.Abstractions --version 0.9.0-alpha.1011.ged0a6c6e98
NuGet\Install-Package FractalDataWorks.Services.Scheduling.Abstractions -Version 0.9.0-alpha.1011.ged0a6c6e98
<PackageReference Include="FractalDataWorks.Services.Scheduling.Abstractions" Version="0.9.0-alpha.1011.ged0a6c6e98" />
<PackageVersion Include="FractalDataWorks.Services.Scheduling.Abstractions" Version="0.9.0-alpha.1011.ged0a6c6e98" />
<PackageReference Include="FractalDataWorks.Services.Scheduling.Abstractions" />
paket add FractalDataWorks.Services.Scheduling.Abstractions --version 0.9.0-alpha.1011.ged0a6c6e98
#r "nuget: FractalDataWorks.Services.Scheduling.Abstractions, 0.9.0-alpha.1011.ged0a6c6e98"
#:package FractalDataWorks.Services.Scheduling.Abstractions@0.9.0-alpha.1011.ged0a6c6e98
#addin nuget:?package=FractalDataWorks.Services.Scheduling.Abstractions&version=0.9.0-alpha.1011.ged0a6c6e98&prerelease
#tool nuget:?package=FractalDataWorks.Services.Scheduling.Abstractions&version=0.9.0-alpha.1011.ged0a6c6e98&prerelease
FractalDataWorks.Services.Scheduling.Abstractions
Comprehensive scheduling abstractions and interfaces for the FractalDataWorks platform, providing cron-based scheduling capabilities with flexible trigger types and execution management.
Overview
This project defines the core abstractions for the FractalDataWorks scheduling system, implementing a clean separation between scheduling (WHEN) and execution (HOW). It provides comprehensive scheduling capabilities including cron expressions, timezone handling, trigger management, and execution tracking.
Key Components
Core Interfaces
IFractalSchedulingService
- Purpose: Main service interface for scheduling operations that applications use
- Features:
- Create, update, and delete schedules
- Pause and resume schedule execution
- Trigger immediate execution
- Query schedules and execution history
- Access to underlying scheduler
IFractalScheduler
- Purpose: Core scheduling engine that manages WHEN to trigger process execution
- Features:
- Schedule registration and management
- Timing and trigger monitoring
- Bridge to execution handlers
- Schedule state management (active/paused)
IFractalSchedule
- Purpose: Interface defining a schedule that specifies WHEN and HOW a process should execute
- Properties:
ScheduleId,ScheduleName- IdentityProcessId- Reference to process for executionCronExpression- Timing specificationNextExecution- Calculated next run timeIsActive- Schedule statusTimeZoneId- Timezone for cron calculationMetadata- Extensible metadata
IFractalTrigger
- Purpose: Defines when a schedule should trigger execution
- Features: Configuration-based trigger definitions with extensible trigger types
Enhanced Enum Types
TriggerTypeBase
- Type:
abstract class - Purpose: Base class for all trigger type implementations
- Properties: ID, Name, RequiresSchedule, IsImmediate
- Methods:
CalculateNextExecution(),ValidateTrigger()
Trigger Type Implementations
Cron
- Type:
sealed classwith[EnumOption("Cron")] - Purpose: Cron expression-based scheduling with timezone support
- Features:
- Uses Cronos library for cron parsing and calculation
- Timezone-aware execution with DST handling
- Supports standard and extended cron formats
- Validates cron expressions and timezones
- Configuration keys:
CronExpression,TimeZoneId
Interval
- Type:
sealed classwith[EnumOption("Interval")] - Purpose: Fixed interval-based scheduling
- Features: Regular interval-based execution (not immediately implemented)
Once
- Type:
sealed classwith[EnumOption("Once")] - Purpose: Single execution at specified time
- Features: One-time scheduled execution
Manual
- Type:
sealed classwith[EnumOption("Manual")] - Purpose: Manual trigger only (no automatic scheduling)
- Features: Execution only through explicit triggering
Model Classes
Schedule
- Type:
sealed class - Interfaces:
IFractalSchedule - Purpose: Default implementation of schedule with comprehensive validation and state management
- Features:
- Factory methods (
CreateNew(),Create()) - Comprehensive validation logic
- State management (active status, next execution updates)
- Metadata support with dictionary backing
- Cron expression and timezone extraction from triggers
- Timestamp tracking (created/updated)
- Factory methods (
Trigger
- Type: Implementation class (referenced but not provided)
- Interfaces:
IFractalTrigger - Purpose: Default trigger implementation with configuration management
Messages
Scheduling Messages (using Message Source Generators)
JobCompletedMessage- Job completion notificationJobFailedMessage- Job failure notificationJobScheduledMessage- Job scheduling notificationSchedulingMessage- Base message typeSchedulingMessageCollectionBase- Message collection
Service Types
SchedulingServiceType and SchedulingServiceTypes
- Purpose: Service type definitions for scheduling implementations
- Features: Enhanced enum pattern for service type management
Dependencies
Package References
Cronos- Cron expression parsing and calculationMicrosoft.Extensions.DependencyInjection.Abstractions- DI supportMicrosoft.Extensions.Logging.Abstractions- Logging contracts
Project References
FractalDataWorks.Services.Execution.Abstractions- Process execution contractsFractalDataWorks.EnhancedEnums- Enhanced enum supportFractalDataWorks.Messages- Messaging infrastructureFractalDataWorks.Results- Result pattern implementationFractalDataWorks.Services- Base service implementationsFractalDataWorks.Services.Abstractions- Service abstractionsFractalDataWorks.EnhancedEnums.SourceGenerators- Build-time enum generationFractalDataWorks.Messages.SourceGenerators- Build-time message generation
Usage Patterns
Creating and Managing Schedules
// Create a daily backup schedule
var cronTrigger = Trigger.CreateCron(
name: "Daily Backup Trigger",
cronExpression: "0 2 * * *", // 2 AM daily
timeZoneId: "America/New_York"
);
var schedule = Schedule.CreateNew(
name: "Daily Database Backup",
processType: "DatabaseBackup",
processConfiguration: backupConfig,
trigger: cronTrigger,
description: "Automated daily backup of production database"
);
// Validate the schedule
var validationResult = schedule.Validate();
if (validationResult.IsSuccess)
{
// Create the schedule in the service
await schedulingService.CreateScheduleAsync(schedule, cancellationToken);
}
Using the Scheduling Service
// Inject the scheduling service
public class BackupController
{
private readonly IFractalSchedulingService _schedulingService;
public BackupController(IFractalSchedulingService schedulingService)
{
_schedulingService = schedulingService;
}
public async Task<IActionResult> ManageBackupSchedule()
{
// Get existing schedule
var scheduleResult = await _schedulingService.GetScheduleAsync(
"daily-backup",
cancellationToken
);
if (scheduleResult.IsSuccess && scheduleResult.Value != null)
{
// Pause temporarily
await _schedulingService.PauseScheduleAsync(
"daily-backup",
cancellationToken
);
// Trigger immediate execution
await _schedulingService.TriggerScheduleAsync(
"daily-backup",
cancellationToken
);
// Resume normal schedule
await _schedulingService.ResumeScheduleAsync(
"daily-backup",
cancellationToken
);
}
return Ok();
}
}
Cron Trigger Configuration
// Various cron expression examples
var dailyTrigger = new Dictionary<string, object>
{
["CronExpression"] = "0 9 * * *", // Daily at 9 AM
["TimeZoneId"] = "America/New_York"
};
var weekdayTrigger = new Dictionary<string, object>
{
["CronExpression"] = "0 9 * * MON-FRI", // Weekdays at 9 AM
["TimeZoneId"] = "UTC"
};
var hourlyTrigger = new Dictionary<string, object>
{
["CronExpression"] = "0 */1 * * *", // Every hour
["TimeZoneId"] = "UTC"
};
var monthlyTrigger = new Dictionary<string, object>
{
["CronExpression"] = "0 0 1 * *", // First of month at midnight
["TimeZoneId"] = "Europe/London"
};
Architecture Notes
Separation of Concerns
The scheduling system follows clear separation:
- Scheduling (WHEN): Handled by
IFractalSchedulerand trigger types - Execution (HOW): Handled by
IFractalScheduledExecutionHandler - Service Layer:
IFractalSchedulingServiceprovides 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
- Comprehensive validation and error reporting
Enhanced Enum Pattern
Trigger types use the enhanced enum pattern for:
- Type-safe trigger type definitions
- Extensible trigger implementations
- Source-generated collections and lookups
- Compile-time validation
Code Coverage Exclusions
The following should be excluded from coverage testing:
Helper Methods
Schedule.ExtractCronExpression()-[ExcludeFromCodeCoverage]- Helper method tested through factory methodsSchedule.ExtractTimeZoneId()-[ExcludeFromCodeCoverage]- Helper method tested through factory methodsSchedule.ValidateTriggerConfiguration()-[ExcludeFromCodeCoverage]- Complex trigger validation tested in trigger type tests
Infrastructure Code
- Source-generated message classes and collections - No business logic to test
- Enhanced enum infrastructure - Framework-level code
Validation and Error Handling
Schedule Validation
The Schedule.Validate() method performs comprehensive validation:
- Identity validation (IDs and names present)
- Process validation (type and configuration valid)
- Trigger validation (delegates to trigger type)
- Timestamp validation (logical consistency)
Cron Trigger Validation
The Cron.ValidateTrigger() method validates:
- Cron expression format using Cronos library
- Timezone identifier existence
- Configuration completeness
- Future execution possibility (expression not expired)
Error Result Patterns
All operations use IGenericResult for consistent error handling:
- Success/failure indication
- Detailed error messages
- Exception wrapping where appropriate
- Validation error aggregation
Integration Points
Execution Handler Integration
Schedulers work with IFractalScheduledExecutionHandler to:
- Execute scheduled processes when triggers fire
- Handle execution context and metadata
- Track execution results and history
Service Factory Integration
Service types support factory patterns for:
- Dynamic service creation
- Configuration-driven service selection
- Dependency injection integration
Extension Points
Custom Trigger Types
New trigger types can be created by:
- Extending
TriggerTypeBase - Implementing
CalculateNextExecution()andValidateTrigger() - Adding
[EnumOption]attribute - Registering with enhanced enum system
Custom Schedule Properties
Schedules support extensible metadata through:
Metadatadictionary property- Type-safe configuration objects
- Custom validation logic in derived classes
Performance Considerations
- Cron calculations use efficient Cronos library
- Timezone conversions handled by .NET TimeZoneInfo
- Enhanced enums provide compile-time optimization
- Source generators eliminate runtime reflection
- Immutable schedule data reduces memory pressure
| 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.Messages (>= 0.9.0-alpha.1011.ged0a6c6e98)
- FractalDataWorks.Results (>= 0.9.0-alpha.1011.ged0a6c6e98)
- FractalDataWorks.Services.Abstractions (>= 0.9.0-alpha.1011.ged0a6c6e98)
- FractalDataWorks.Services.Execution.Abstractions (>= 0.9.0-alpha.1011.ged0a6c6e98)
- FractalDataWorks.Services.SecretManagers.Abstractions (>= 0.9.0-alpha.1011.ged0a6c6e98)
- FractalDataWorks.ServiceTypes (>= 0.9.0-alpha.1011.ged0a6c6e98)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.0-rc.2.25502.107)
- Microsoft.Extensions.Diagnostics.HealthChecks (>= 10.0.0-rc.2.25502.107)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.0-rc.2.25502.107)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on FractalDataWorks.Services.Scheduling.Abstractions:
| Package | Downloads |
|---|---|
|
FractalDataWorks.Etl.Scheduling.Abstractions
Development tools and utilities for the FractalDataWorks ecosystem. Build: |
|
|
FractalDataWorks.Services.Scheduling
Development tools and utilities for the FractalDataWorks ecosystem. Build: |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.9.0-alpha.1011.ged0a6c6e98 | 42 | 11/18/2025 |
| 0.9.0-alpha.1010.gecd88aac50 | 42 | 11/18/2025 |
| 0.9.0-alpha.1009.g7f6817e985 | 37 | 11/18/2025 |
| 0.9.0-alpha.1006.gf287016c0c | 40 | 11/18/2025 |
| 0.8.0-alpha.1011 | 37 | 11/18/2025 |
| 0.7.0-alpha.1022 | 135 | 11/3/2025 |
| 0.7.0-alpha.1021 | 133 | 11/3/2025 |
| 0.7.0-alpha.1008 | 99 | 11/2/2025 |
| 0.7.0-alpha.1006 | 127 | 10/30/2025 |
| 0.7.0-alpha.1005 | 128 | 10/30/2025 |
| 0.7.0-alpha.1004 | 127 | 10/30/2025 |
| 0.7.0-alpha.1001 | 126 | 10/29/2025 |
| 0.6.0-alpha.1006 | 134 | 10/29/2025 |
| 0.6.0-alpha.1005 | 133 | 10/28/2025 |
| 0.6.0-alpha.1004 | 127 | 10/28/2025 |