Skip to content

GiampaoloGabba/EverTask

Repository files navigation

EverTask Logo

Build NuGet NuGet NuGet NuGet NuGet NuGet NuGet NuGet

Overview

EverTask is a high-performance .NET library for background task execution. It handles everything from simple fire-and-forget operations to complex recurring schedules, with persistence that survives application restarts.

Supports CPU-intensive, I/O-bound, long-running and short-running tasks. No external schedulers or Windows Services required β€” everything runs in-process with your application.

EverTask doesn't continuously poll the database: it uses a lightweight and optimized in-memory scheduler, coupled with channels and strategic persistence.

If you've used MediatR, you'll feel right at home with the request/handler pattern β€” but with built-in persistence, multi-queue isolation, and the ability to scale to high load.

Works great with ASP.NET Core, Windows Services, or any .NET project that needs reliable background processing.

Key Features

Core Execution

  • Background Execution β€” Fire-and-forget, scheduled, and recurring tasks with elegant API
  • Zero Database Polling β€” Smart scheduler with in-memory channels and persistence, no continuous database polling
  • Smart Persistence β€” Tasks resume after application restarts (SQL Server, SQLite, In-Memory)
  • Fluent Scheduling API β€” Intuitive recurring task configuration (every minute, hour, day, week, month, cron)
  • Idempotent Task Registration β€” Prevent duplicate recurring tasks with unique keys

Performance & Scalability

  • Multi-Queue Support β€” Isolate workloads by priority, resource type, or business domain
  • High-Performance Scheduler β€” Minimal lock contention and zero CPU when idle
  • High Load Support β€” Optional sharded scheduler for high-loading scheduling scenarios
  • Optimized Performance β€” Reflection caching, lazy serialization, optimized database operations

Monitoring & Observability

  • Web Dashboard + REST API β€” Embedded React UI for monitoring, analytics, and observability
  • Real-Time Updates β€” SignalR live monitoring with event-driven cache invalidation
  • Task Execution Log Capture β€” Proxy logger with optional database persistence for audit trails
  • Configurable Audit Levels β€” Control database bloat with granular audit trail settings

Resilience & Error Handling

  • Powerful Retry Policies β€” Built-in linear retry, custom policies, Polly integration, exception filtering
  • Timeout Management β€” Global and per-task timeout configuration

Developer Experience

  • Extensible Architecture β€” Custom storage, retry policies, and schedulers
  • Serilog Integration β€” Detailed structured logging
  • Async All The Way β€” Fully asynchronous for maximum scalability

Task Details

Quick Start

Installation

dotnet add package EverTask
dotnet add package EverTask.Storage.SqlServer  # Or EverTask.Storage.Sqlite

Configuration

// Register EverTask with SQL Server storage
builder.Services.AddEverTask(opt =>
{
    opt.RegisterTasksFromAssembly(typeof(Program).Assembly);
})
.AddSqlServerStorage(builder.Configuration.GetConnectionString("EverTaskDb"));

Create Your First Task

Define a task request:

public record SendWelcomeEmailTask(string UserEmail, string UserName) : IEverTask;

Create a handler:

public class SendWelcomeEmailHandler : EverTaskHandler<SendWelcomeEmailTask>
{
    private readonly IEmailService _emailService;

    public SendWelcomeEmailHandler(IEmailService emailService)
    {
        _emailService = emailService;
    }

    public override async Task Handle(SendWelcomeEmailTask task, CancellationToken cancellationToken)
    {
        Logger.LogInformation("Sending welcome email to {Email}", task.UserEmail);

        await _emailService.SendWelcomeEmailAsync(
            task.UserEmail,
            task.UserName,
            cancellationToken);
    }
}

Dispatch the task:

// Send welcome email in background
await _dispatcher.Dispatch(new SendWelcomeEmailTask(dto.Email, dto.Name));

Documentation

πŸ“š Full Documentation - Complete guides, tutorials, and API reference

Quick Links

Showcase: Powerful Features

Fluent Recurring Scheduler

Schedule recurring tasks with an intuitive, type-safe API:

// Run every day at 3 AM
await dispatcher.Dispatch(
    new DailyCleanupTask(),
    builder => builder.Schedule().EveryDay().AtTime(new TimeOnly(3, 0)));

// Run every Monday, Wednesday, Friday at 9 AM
var days = new[] { DayOfWeek.Monday, DayOfWeek.Wednesday, DayOfWeek.Friday };
await dispatcher.Dispatch(
    new BackupTask(),
    builder => builder.Schedule().EveryWeek().OnDays(days).AtTime(new TimeOnly(9, 0)))).RunUntil(DateTimeOffset.UtcNow.AddDays(30)));

Multi-Queue Workload Isolation

Keep critical tasks separate from heavy background work:

// High-priority queue for critical operations
.AddQueue("critical", q => q
    .SetMaxDegreeOfParallelism(20)
    .SetChannelCapacity(500)
    .SetDefaultTimeout(TimeSpan.FromMinutes(2)))

Smart Retry Policies with Exception Filtering

Control which exceptions trigger retries to fail-fast on permanent errors:

// Predefined sets for common scenarios
RetryPolicy => new LinearRetryPolicy(5, TimeSpan.FromSeconds(2)).HandleTransientDatabaseErrors();

// Whitelist: Only retry specific exceptions (you can also use DoNotHandle for blacklist)
RetryPolicy = new LinearRetryPolicy(3, TimeSpan.FromSeconds(1)).Handle<DbException>().Handle<HttpRequestException>();

// Predicate: Custom logic (e.g., HTTP 5xx only)
RetryPolicy = new LinearRetryPolicy(3, TimeSpan.FromSeconds(1)).HandleWhen(ex => ex is HttpRequestException httpEx && httpEx.StatusCode >= 500);

Idempotent Task Registration

Use unique keys to safely register recurring tasks at startup without creating duplicates:

// Register recurring tasks - safe to call on every startup
    await _dispatcher.Dispatch(
        new DailyCleanupTask(),
        r => r.Schedule().EveryDay().AtTime(new TimeOnly(3, 0)),
        taskKey: "daily-cleanup"); // Won't create duplicates

Monitoring Dashboard

Monitor your tasks with a feature-complete web dashboard providing real-time insights, comprehensive analytics, and detailed observability:

Dashboard Preview:

Dashboard Overview
Dashboard Overview
Task List
Task List with Filters
Task Details
Task Details & History
Execution Logs
Execution Logs Viewer
Execution Logs
Realtime flow

πŸ“Έ View all 10 screenshots in the documentation

Task Execution Log Capture

Capture all logs written during task execution and persist them to the database for debugging and auditing:

Task Details


View logs in dashboard or retrieve via storage

View Complete Changelog

Quick Links

Roadmap

We have some exciting features in the pipeline:

  • Task Management API: REST endpoints for stopping, restarting, and canceling tasks via the dashboard
  • Distributed Clustering: Multi-server task distribution with leader election and automatic failover
  • Advanced Throttling: Rate limiting and adaptive throttling based on system resources
  • Workflow Orchestration: Complex workflow and saga orchestration with fluent API
  • Additional Monitoring: Sentry Crons, Application Insights, OpenTelemetry support
  • More Storage Options: PostgreSQL, MySQL, Redis, Cosmos DB

Contributing

Contributions are welcome! Bug reports, feature requests, and pull requests all help make EverTask better.

License

EverTask is licensed under the Apache License 2.0.

See ATTRIBUTION.md for acknowledgements and attributions.


Developed with ❀️ by Giampaolo Gabba

About

Easy background task with persistence, parallelism, resilience and realtime monitoring for .NET

Topics

Resources

License

Stars

Watchers

Forks

Contributors 2

  •  
  •  

Languages