function
NewTask
func NewTask[Input, Output any](
slug string,
handler TaskHandler[Input, Output],
options ...TaskOption,
) TypedTask[Input, Output]Define a compiled typed durable task.
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.
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,
),
)Related types
TaskHandlerA compiled typed durable task function.
TaskOptionOne typed task policy option.
TypedTaskA registered typed handle for durable admission, status, and cancellation.