All Projects → FrodaSE → Minion

FrodaSE / Minion

Licence: mit
Background job system for .NET applications

Programming Languages

processing
702 projects

Projects that are alternatives of or similar to Minion

Efcore
EF Core is a modern object-database mapper for .NET. It supports LINQ queries, change tracking, updates, and schema migrations.
Stars: ✭ 10,838 (+11429.79%)
Mutual labels:  dotnet-standard, dotnet-framework, dotnet-core
Tweetinvi
Tweetinvi, an intuitive Twitter C# library for the REST and Stream API. It supports .NET, .NETCore, UAP (Xamarin)...
Stars: ✭ 812 (+763.83%)
Mutual labels:  dotnet-standard, dotnet-framework, dotnet-core
Theraot
Backporting .NET and more: LINQ expressions in .net 2.0 - nuget Theraot.Core available.
Stars: ✭ 112 (+19.15%)
Mutual labels:  dotnet-standard, dotnet-framework, dotnet-core
Appmetrics
App Metrics is an open-source and cross-platform .NET library used to record and report metrics within an application.
Stars: ✭ 1,986 (+2012.77%)
Mutual labels:  dotnet-standard, dotnet-framework, dotnet-core
Hangfire
An easy way to perform background job processing in your .NET and .NET Core applications. No Windows Service or separate process required
Stars: ✭ 7,126 (+7480.85%)
Mutual labels:  background-jobs, scheduled-jobs, dotnet-core
Mockqueryable
Moking Entity Framework Core operations such ToListAsync, FirstOrDefaultAsync etc
Stars: ✭ 281 (+198.94%)
Mutual labels:  dotnet-standard, dotnet-framework, dotnet-core
Entityframeworkcore.cacheable
EntityFrameworkCore second level cache
Stars: ✭ 138 (+46.81%)
Mutual labels:  dotnet-standard, dotnet-framework, dotnet-core
Dotnet Etcd
A C# .NET (dotnet) GRPC client for etcd v3 +
Stars: ✭ 157 (+67.02%)
Mutual labels:  dotnet-standard, dotnet-framework, dotnet-core
Sharpsnmplib
Sharp SNMP Library- Open Source SNMP for .NET and Mono
Stars: ✭ 247 (+162.77%)
Mutual labels:  dotnet-standard, dotnet-framework, dotnet-core
Coravel
Near-zero config .NET Core micro-framework that makes advanced application features like Task Scheduling, Caching, Queuing, Event Broadcasting, and more a breeze!
Stars: ✭ 1,989 (+2015.96%)
Mutual labels:  background-jobs, scheduled-jobs, dotnet-core
Linqtotwitter
LINQ Provider for the Twitter API (C# Twitter Library)
Stars: ✭ 401 (+326.6%)
Mutual labels:  dotnet-standard, dotnet-framework, dotnet-core
Stryker Net
Mutation testing for .NET core and .NET framework!
Stars: ✭ 491 (+422.34%)
Mutual labels:  dotnet-framework, dotnet-core
Dotnet Webassembly
Create, read, modify, write and execute WebAssembly (WASM) files from .NET-based applications.
Stars: ✭ 535 (+469.15%)
Mutual labels:  dotnet-standard, dotnet-core
Dnsserver
Technitium DNS Server
Stars: ✭ 603 (+541.49%)
Mutual labels:  dotnet-standard, dotnet-core
Mathparser.org Mxparser
Math Parser Java Android C# .NET/MONO (.NET Framework, .NET Core, .NET Standard, .NET PCL, Xamarin.Android, Xamarin.iOS) CLS Library - a super easy, rich and flexible mathematical expression parser (expression evaluator, expression provided as plain text / strings) for JAVA and C#. Main features: rich built-in library of operators, constants, math functions, user defined: arguments, functions, recursive functions and general recursion (direct / indirect). Additionally parser provides grammar and internal syntax checking.
Stars: ✭ 624 (+563.83%)
Mutual labels:  dotnet-standard, dotnet-core
Netfabric.hyperlinq
High performance LINQ implementation with minimal heap allocations. Supports enumerables, async enumerables, arrays and Span<T>.
Stars: ✭ 479 (+409.57%)
Mutual labels:  dotnet-standard, dotnet-core
Steeltoe
Steeltoe .NET Core Components: CircuitBreaker, Configuration, Connectors, Discovery, Logging, Management, and Security
Stars: ✭ 612 (+551.06%)
Mutual labels:  dotnet-standard, dotnet-core
Featuretoggle
Simple, reliable feature toggles in .NET
Stars: ✭ 641 (+581.91%)
Mutual labels:  dotnet-standard, dotnet-core
Dotnet Win32 Service
Helper classes to set up and run as windows services directly on .net core. A ServiceBase alternative.
Stars: ✭ 425 (+352.13%)
Mutual labels:  dotnet-standard, dotnet-core
Electron.net
Build cross platform desktop apps with ASP.NET Core (Razor Pages, MVC, Blazor).
Stars: ✭ 6,074 (+6361.7%)
Mutual labels:  dotnet-standard, dotnet-core

Minion

Minion is a modern, testable background job scheduler for .NET applications. Minion will handle running your background job in a reliable way with SQL Server backed storage.

Example of scenarios when you can use Minion:

  • Fire web hooks
  • Database cleanup
  • Creating recurring automated reports
  • Batch sending emails
  • ... and more

Built with dotnet

Installation

Minion is available as a NuGet package. You can install it using the NuGet Package Console windows in Visual Studio:

PM> Install-Package Froda.Minion

Usage

To run the server, add the following lines of code:

MinionConfiguration.Configuration.UseSqlStorage("<connection string>");

using (var engine = new BatchEngine())
{
    Console.WriteLine("Starting ...");

    engine.Start();

    Console.ReadKey();
}

All jobs need to inherit from Job or Job<TInput>:

public class SimpleJob : Job
{
    public override async Task<JobResult> ExecuteAsync()
    {
        Console.WriteLine("Hello from simple job");

        return Finished();
    }
}

public class JobWithInput : Job<JobWithInput.Input>
{
    public class Input
    {
        public string Text { get; set; }
    }

    public override async Task<JobResult> ExecuteAsync(Input input)
    {
        Console.WriteLine("Hello from job with input: " + input.Text);

        return Finished();
    }
}

To schedule jobs you first need an instance of JobScheduler:

var scheduler = new JobScheduler();

Fire-and-forget

The job will be executed as soon as possible.

await scheduler.QueueAsync<SimpleJob>();

var input = new JobWithInput.Input { Text = "This is awesome" };
await scheduler.QueueAsync<JobWithInput, JobWithInput.Input>(input);

Scheduled job

The job will execute at the given time.

var date = new Date(2019, 04, 20);

await scheduler.QueueAsync<SimpleJob>(date);

var input = new JobWithInput.Input { Text = "This is awesome" };
await scheduler.QueueAsync<JobWithInput, JobWithInput.Input>(input, date);

Recurring jobs

Recurring jobs are scheduled as normal jobs, but need to return a new DueTime:

public class RecurringJob : Job
{
    private readonly IDateService _dateService;

    public RecurringJob(IDateService dateService) {
        _dateService = dateService;
    }

    public override async Task<JobResult> ExecuteAsync()
    {
        Console.WriteLine("Hello from recurring job, I will execute every 2 seconds");

        return Reschedule(_dateService.GetNow().AddSeconds(2));
    }
}

Sequence

This will force the jobs to run in sequnce:

var sequence = new Sequence();

sequence.Add<FirstJob>(); //This will run first
sequence.Add<SecondJob>(); //When the FirstJob is finished this will run

await scheduler.QueueAsync(sequence);

Set

These jobs will run in parallel if possible:

var set = new Set();

set.Add<FirstJob>();
set.Add<SecondJob>();

await scheduler.QueueAsync(set);

More advanced jobs

You can run a set in a sequence, and a sequence in a set:

var sequence = new Sequence();

sequence.Add<FirstJob>(); //This will run first

var set = new Set();

//Second and third job will run in parallel if possible
set.Add<SecondJob>(); 
set.Add<ThirdJob>(); 

sequence.Add(set);

sequence.Add<FourthJob>(); //Only when both second and third job is finished, this will run

await scheduler.QueueAsync(sequence);

Testing

With the TestingBatchEngine you can simulate your jobs with the ability to time travel.

For an example, if you schedule a job to send an email two days from now, you can fast forward and the batch engine will act as if two days have passed.

[Fact]
public async Task Can_Send_Email() {

    //Setup
    ...

    var startDate = new DateTime(2018, 04, 20);
    var dateSimulationService = new SimpleDateSimulationService(startDate);
    var store = new InMemoryStorage(dateSimulationService);

    var eninge = new TestingBatchEngine(store, dateSimulationService);
    var scheduler = new JobScheduler(store, dateSimulationService)

    await scheduler.QueueAsync<SendEmailJob>(startDate.AddDays(2)); //Schedule job to two days from now

    await engine.AdvanceToDateAsync(startDate.AddDays(2)); //Fast forward to two days from now

    //Assert
    ...
}

Dependency Injection

To hook up your IoC container to, you need to create a class that inherits from IDependencyResolver:

public class CustomDependencyResolver : IDependencyResolver 
{
    private readonly IContainer _container;

    public CustomDependencyResolver(IContainer container) 
    {
        _container = container;
    }

    public bool Resolve(Type type, out object resolvedType)
    {
        resolvedType = _container.Resolve(type);

        if(resolvedType == null)
        {
            return false;    
        }

        return true;
    }
}

Then you need to pass your resolver to the batch engine:

...
var container = new Container();
var resolver = new CustomDependencyResolver(container);

using(var engine = new BatchEngine(store, resolver)) {

    engine.Start();

    Console.ReadKey();

}

License

Minion goes under The MIT License (MIT).

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].