WJb Docs - Basic
Start here with installation, quick starts, and core concepts.
π Start Here
β¨ First Steps
β Next Steps
π¦ First Job
A Job is a request to execute an Action.
You create a Job by enqueueing it.
Enqueue a Job
await wjb.EnqueueAsync("greet", "Alice");
What this does
"greet"β the action key we registered earlier"Alice"β the input that will be passed to the Action
Run the Job
await wjb.ExecuteOnceAsync();
This tells the worker to:
1. Take the next available job 2. Execute the corresponding Action 3. Save the result
Full example
using WJb;
public sealed class GreetAction : JobAction<string>
{
public override Task<IActionResult> ExecuteAsync(
string name, CancellationToken ct)
{
Console.WriteLine($"Hello, {name}!");
return CompleteAsync();
}
}
var store = new InMemoryStore();
var wjb = WJbBuilder.Create(store, cfg =>
{
cfg.AddAction<GreetAction>("greet");
})
.Build(store);
// Create the job
await wjb.EnqueueAsync("greet", "Alice");
// Execute it
await wjb.ExecuteOnceAsync();
What just happened?
1. We created a Job for the greet Action.
2. We passed "Alice" as input.
3. The worker executed the Action.
4. The Action printed the message and completed.