mirror of
https://github.com/hatchet-dev/hatchet.git
synced 2026-04-30 06:30:12 -05:00
8e80faf2d6
* api changes * doc changes * move docs * generated * generate * pkg * backmerge main * revert to main * revert main * race? * remove go tests
45 lines
961 B
Go
45 lines
961 B
Go
package v1_workflows
|
|
|
|
import (
|
|
"strings"
|
|
"time"
|
|
|
|
"github.com/hatchet-dev/hatchet/pkg/client/create"
|
|
v1 "github.com/hatchet-dev/hatchet/pkg/v1"
|
|
"github.com/hatchet-dev/hatchet/pkg/v1/factory"
|
|
"github.com/hatchet-dev/hatchet/pkg/v1/workflow"
|
|
"github.com/hatchet-dev/hatchet/pkg/worker"
|
|
)
|
|
|
|
type DurableSleepInput struct {
|
|
Message string
|
|
}
|
|
|
|
type DurableSleepOutput struct {
|
|
TransformedMessage string
|
|
}
|
|
|
|
func DurableSleep(hatchet v1.HatchetClient) workflow.WorkflowDeclaration[DurableSleepInput, DurableSleepOutput] {
|
|
// > Durable Sleep
|
|
simple := factory.NewDurableTask(
|
|
create.StandaloneTask{
|
|
Name: "durable-sleep",
|
|
},
|
|
func(ctx worker.DurableHatchetContext, input DurableSleepInput) (*DurableSleepOutput, error) {
|
|
_, err := ctx.SleepFor(10 * time.Second)
|
|
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return &DurableSleepOutput{
|
|
TransformedMessage: strings.ToLower(input.Message),
|
|
}, nil
|
|
},
|
|
hatchet,
|
|
)
|
|
// !!
|
|
|
|
return simple
|
|
}
|