WJb Docs - Basic
Start here with installation, quick starts, and core concepts.
π Start Here
β¨ First Steps
β Next Steps
β‘ First Action
An Action is the basic unit of work in WJb.
It receives input, does something useful, and returns a Result.
Create an Action
using WJb;
public sealed class GreetAction : JobAction<string>
{
public override Task<IActionResult> ExecuteAsync(
string name, CancellationToken ct)
{
Console.WriteLine($"Hello, {name}!");
return CompleteAsync();
}
}
What this code does
- Inherits from
JobAction - Receives a
stringas input - Prints a greeting
- Completes the workflow
Register the Action
var store = new InMemoryStore();
var wjb = WJbBuilder.Create(store, cfg =>
{
cfg.AddAction<GreetAction>("greet");
})
.Build(store);
The string "greet" is the action key.
You will use this key when enqueueing jobs.
Key points
- One Action = one clear responsibility
- Actions are normal C# classes
- Input is strongly typed
- The Result decides what happens next