ChronosCore is a high-performance, distributed, and highly available task scheduler built with C# and .NET 10. It is designed to handle millions of tasks with exactly-once delivery guarantees, automatic failover, and a custom Raft-based consensus protocol.
- Distributed Architecture: Horizontally scalable worker nodes with transparent leader election via Raft.
- Exactly-Once Guarantees: Robust idempotency handling and fencing tokens prevent duplicate task execution.
- Priority Queuing: Supports 10 levels of task priority with a built-in aging mechanism to prevent task starvation.
- Cron Schedules: Submit recurring tasks with standard Unix cron expressions.
- Pluggable Infrastructure:
- PostgreSQL: Durable persistence for tasks, schedules, and outbox messages using Entity Framework Core.
- Redis: High-speed priority queues, distributed locking (Redlock), and idempotency storage.
- RabbitMQ: Message brokering and event distribution powered by MassTransit.
- Observability: Integrated OpenTelemetry metrics, Serilog structured logging, and health checks.
- Clean Architecture: Strictly layered design (Domain, Application, Infrastructure, API, Worker).
- Dual API: Exposes both REST and gRPC endpoints for maximum interoperability.
ChronosCore enforces a strict Clean Architecture:
- Domain: Core entities (
ScheduledTask,TaskSchedule,ClusterNode), Value Objects (TaskId,FencingToken,IdempotencyKey), and Domain Events. - Application: CQRS implementation (Commands & Queries) using MediatR, Validation (FluentValidation), and pipeline behaviors (Logging, Performance, Transactions).
- Infrastructure: Implementation details (EF Core repositories, Redis queues, RabbitMQ publishers, Raft Consensus, OpenTelemetry).
- Worker: Background services (
TaskPollingService,ScheduleEvaluatorService,PriorityAgingWorker,TimeoutMonitorService). - API: REST endpoints, gRPC services, API Gateway/Middleware.
- .NET 10 / C# 14
- PostgreSQL (Relational & Outbox DB)
- Redis (Queues, Locks, Caching)
- RabbitMQ & MassTransit (Messaging)
- MediatR (CQRS)
- Entity Framework Core (ORM)
- OpenTelemetry & Prometheus / Grafana (Observability)
- Serilog & Seq (Logging)
- Docker & Docker Compose
The easiest way to get everything running locally is through Docker Compose. This will spin up the API, Worker, PostgreSQL, Redis, RabbitMQ, Seq, Prometheus, and Grafana.
-
Clone the repository:
git clone https://github.com/DAMMAK/ChronosCore.git cd ChronosCore -
Start the infrastructure and application services:
docker-compose up -d --build
-
Access the services:
- API Swagger UI:
http://localhost:5000/swagger - Seq Logging:
http://localhost:5341 - RabbitMQ Management:
http://localhost:15672(guest / guest) - Prometheus:
http://localhost:9090 - Grafana:
http://localhost:3000(admin / admin)
- API Swagger UI:
To build the solution locally using the .NET CLI:
dotnet restore ChronosCore.slnx
dotnet build ChronosCore.slnxThe solution includes comprehensive Unit, Integration, and Chaos tests.
dotnet test ChronosCore.slnx(Note: Integration tests may require Testcontainers, meaning Docker must be running on your machine).
POST /api/tasks
Content-Type: application/json
{
"tenantId": "customer-1",
"taskType": "SendEmail",
"payload": "{\"to\": \"user@example.com\", \"subject\": \"Hello!\"}",
"priority": 5,
"maxRetries": 3,
"timeoutSeconds": 300
}POST /api/schedules
Content-Type: application/json
{
"tenantId": "customer-1",
"taskType": "DailyReport",
"payload": "{}",
"cronExpression": "0 0 * * *"
}This project is licensed under the MIT License.