ericqzhao
ericqzhao

Reputation: 21

What is a good use case for a delay task in Uber Cadence?

I want to implement a delay task and found a cadence cron example, how to use cadence to implement a delay task?

Upvotes: 1

Views: 637

Answers (2)

Ender
Ender

Reputation: 196

Cadence supports both activity and workflow delaying.

Activity delay can be achieved with Workflow.Sleep API

Workflow delay can be achieved with DelayStart option. See https://github.com/uber-go/cadence-client/blob/e66e2d4da8def80e7a5730b824a2de7a28f5c050/internal/client.go#L415

  • For regular workflows, this will delay execution that many seconds, then start.
  • For cron workflows, this will delay ONLY the FIRST execution. For example you want to set up an hourly cron workflow but you want it to start running from next week on Monday at 9AM. You can pass delayStart seconds option to delay till that Monday between 8AM and 9AM so it will start at 9AM since it's the next schedule.

Upvotes: 1

Maxim Fateev
Maxim Fateev

Reputation: 6890

Cron is for periodic execution of some functionality.

If you need to delay a task you can call sleep and the beginning of the workflow and then call an activity that executes the task.

Upvotes: 2

Related Questions