Skip to content

[Feature]: Deferred / Scheduled Command Execution #228

@eneshoxha

Description

@eneshoxha

Title: Add deferred and scheduled command execution support

Labels: enhancement, mediator, new-package

Body:

Problem

Some commands need to execute in the future (e.g., send a reminder email in 24 hours, retry a failed payment in 5 minutes). Currently, consumers must implement their own scheduling infrastructure.

Proposed Solution

Create a Cortex.Mediator.Scheduling package:

  • ICommandScheduler interface:
public interface ICommandScheduler
{
    Task<string> ScheduleAsync<TCommand>(TCommand command, TimeSpan delay, CancellationToken ct = default)
        where TCommand : ICommand;
    Task<string> ScheduleAsync<TCommand>(TCommand command, DateTimeOffset executeAt, CancellationToken ct = default)
        where TCommand : ICommand;
    Task CancelAsync(string scheduleId, CancellationToken ct = default);
}
  • In-memory implementation for development/testing
  • Persistent implementation using a database table
  • ScheduledCommandProcessor -- IHostedService that polls and dispatches due commands
  • Optional integration hooks for Hangfire / Quartz.NET

Metadata

Metadata

Assignees

Labels

enhancementNew feature or requestfeatureThis label is in use for minor version increments

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions