Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/brthor/gofer.net
Easy C# API for Distributed Background Tasks/Jobs for .NET Core.
https://github.com/brthor/gofer.net
aspnet background-jobs csharp distributed-systems dotnet dotnet-core netcore netstandard
Last synced: 3 days ago
JSON representation
Easy C# API for Distributed Background Tasks/Jobs for .NET Core.
- Host: GitHub
- URL: https://github.com/brthor/gofer.net
- Owner: brthor
- License: mit
- Created: 2017-10-20T01:08:38.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2022-12-08T00:57:54.000Z (about 2 years ago)
- Last Synced: 2024-10-28T11:55:59.227Z (4 months ago)
- Topics: aspnet, background-jobs, csharp, distributed-systems, dotnet, dotnet-core, netcore, netstandard
- Language: C#
- Homepage:
- Size: 230 KB
- Stars: 540
- Watchers: 22
- Forks: 44
- Open Issues: 16
-
Metadata Files:
- Readme: README.MD
- License: LICENSE
Awesome Lists containing this project
README
# Gofer.NET: Easy distributed tasks/jobs for .NET Core
[](https://travis-ci.org/brthor/Gofer.NET)
[](https://www.nuget.org/packages/Gofer.NET)
[](https://gitter.im/Gofer-NET/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)## Documentation
[Read the Docs](https://brthor.github.io/Gofer.NET/)
## What is this?
This is a distributed job runner for .NET Standard 2.0 Applications.
Inspired by Celery for Python, it allows you to quickly queue code execution on a worker pool.
- Use natural expression syntax to queue jobs for execution.
- Queued jobs are persisted, and automatically run by the first available worker.
- Scale your worker pool by simply adding new nodes.
- Backed by Redis, all tasks are persistent.
## Getting Started
### Install the dotnet cli.
We recommend using the [dotnet cli](https://dotnet.microsoft.com/download) to get started, but it's not a necessity.
The dotnet cli is part of the [.NET Core SDK](https://dotnet.microsoft.com/download).
### Start a Redis instance.
We recommend using [docker](https://docs.docker.com/install/) to start a local Redis instance for testing. Setting up a production-level Redis instance is out of the scope of this documentation.
```bash
$ docker run -d -p 127.0.0.1:6379:6379 redis:4-alpine
```### Create a project.
Open up a terminal and create a new console project to get started.
```bash
$ mkdir myProject && cd myProject
$ dotnet new console
```### Add the Gofer.NET NuGet package.
```bash
$ dotnet add package Gofer.NET --version 1.0.0-*
```### Queue up some jobs.
This example `Program.cs` shows how to queue jobs for the worker pool to process, then start a worker to go and run them.
Some important notes:
- Workers would usually be on a separate machine from the code queueing the jobs, this is purely to give an example.- More workers can be added at any time, and will start picking up jobs off the queue immediately.
```c#
public class Program
{
public static async Task Main(string[] args)
{
var redisConnectionString = "127.0.0.1:6379";
// Create a Task Client connected to Redis
var taskClient = new TaskClient(TaskQueue.Redis(redisConnectionString));
// Queue up a Sample Job
await taskClient.TaskQueue.Enqueue(() => SampleJobFunction("Hello World!"));
// Start the task listener, effectively turning this process into a worker.
// NOTE: This will loop endlessly waiting for new tasks.
await taskClient.Listen();
}
private static void SampleJobFunction(object value)
{
Console.WriteLine(value.ToString());
}
}
```[Read the Docs](https://brthor.github.io/Gofer.NET/) for more details.