Skip to content

pauldotknopf/sharp-jobs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SharpJobs

A very simple low-friction approach to procesing jobs.

SharpJobs SharpJobs.OrmLite

Why

Many of the job processers do way more than I need, adding too much risk to my projects. All I need is the ability to store jobs with metadata, and processes them, in code-first way.

Example

Defining your job:

public class MyJob : AbstractJob<MyJobData>
{
    public override Task Run(MyJobData data)
    {
        Console.WriteLine($"Hello {data.Name}, you are {data.Age} years old.");
        return Task.CompletedTask;
    }
}

public class MyJobData
{
    public string Name { get; set; }
    
    public int Age { get; set; }
}

Storing and processing your jobs:

IJobStorage jobStorage = /**/;
IJobProcessor jobProcessor = /**/;

// Add a job to be ran.
await jobStorage.Enqueue<MyJob, MyJobData>(new MyJobData
{
    Name = "Paul",
    Age = 30
});

// Wire this up however you'd like.
// It's a long running method that looks for and processes jobs.
var cancelToken = new CancellationTokenSource();
jobProcessor.Process(cancelToken.Token);

About

A simple low-friction job processor.

Resources

Stars

Watchers

Forks

Packages

No packages published