Delaying and scheduling workflows
Corteza workflow allows you to schedule or delay its execution. This can be a powerful tool when working with external services that throttle their API usage or when we want to perform some task in an interval, such as monthly subscription renewal.
To achieve this, we provide a delay step and a deferred trigger .
Delaying execution
The delay step allows you to explicitly pause the workflows' execution for a set period of time.
This type of delaying is common when working with APIs that throttle their access. To examplify; let’s say that the API allows 10 calls per minute and we wish to fetch 100 items. We could do something like the following:
If you want to wait for an action performed by a user (such as a confirmation), use a prompt step instead. |
Scheduling execution
Execution scheduling is performed by configuring the trigger to run in an interval or at a specific timestamp.
Performing a task in an interval can be a powerful tool as it allows you to define an interval in which the workflow executes. A good example is a subscription service where it is necessary to renew the subscriptions of the clients once a month. We define an interval that would execute the workflow each day, determine what clients need to be renewed that day and renew them.
An interval is defined by specifying the resource as a system, and the event as an interval in the trigger configuration (click on the configuration icon ). The interval is defined as a chron expression and can be as flexible as you could ever want it to be. You can also use this amazing tool to verify that your expressions are valid. Common cron examples:
|
|||||
Performing a task at a specific date and time can be another powerful tool in your toolbox as it allows you to define exactly when an action should be performed. To illustrate; we’ve just received a new client that requested a series of deadlines where they would like to see the current progress. We could define a scheduled workflow that is executed at each one of the timestamps. The workflow would aggregate all of the completed tickets into an email and send it off to the client.
Timestamps are defined in the ISO 8601,
|
Execution timeout
Corteza workflows' execution does not timeout by default (the workflow can run indefinitely).
If your use-case requires you to define a timeout, you can implement this manually.
-
Schedule a timeout after 10sec of execution,
-
Repeat the iterator indefinitely.