function
NewTask
Define a compiled typed durable task.
Example
var RebuildSearch = ridu.NewTask(
"rebuild-search",
func(
ctx ridu.TaskContext,
input RebuildInput,
) (RebuildOutput, error) {
// compiled application work
return RebuildOutput{}, nil
},
ridu.TaskQueue("maintenance"),
ridu.TaskRetries(
3,
time.Second,
time.Minute,
ridu.TaskBackoffExponential,
),
)Arguments
| Argument | Type | Description |
|---|---|---|
slug | string | The slug value. |
handler | TaskHandler[Input, | The handler value. |
options | []TaskOption | The options value. |
Returns
The declared result.
TypedTask[Input, Output]How it works
Add the returned definition to Config.Tasks. Input and output use strict JSON contracts, are capped by MaxTaskPayloadBytes, and never select executable code from serialized data. The backing store must implement store.TaskStore.
Full signature
func NewTask[Input, Output any](
slug string,
handler TaskHandler[Input, Output],
options ...TaskOption,
) TypedTask[Input, Output]Related types
TaskHandlerA compiled typed durable task function.
TaskOptionOne typed task policy option.
TypedTaskA registered typed handle for durable admission, status, and cancellation.