Skip to content

Commit 816bad9

Browse files
committed
dynamic skip
1 parent 592ab0d commit 816bad9

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed
33.9 KB
Loading

docs/core_concepts/1_scheduling/index.mdx

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,52 @@ You can pick the Slack or Microsoft Teams pre-set schedule recovery handler.
269269

270270
![Schedule Recovery Handler](./15_schedule_recovery_handler.png.webp)
271271

272+
### Dynamic skip validation
273+
274+
Schedules can use a validation script to determine whether a scheduled run should execute. The validator receives the scheduled datetime and returns a boolean indicating whether to proceed.
275+
276+
The dynamic skip handler is useful for:
277+
- Skipping runs on weekends, holidays, or specific dates
278+
- Checking external conditions before execution (e.g., API availability, data freshness)
279+
- Implementing custom scheduling logic beyond standard cron expressions
280+
281+
#### How it works
282+
283+
1. Configure a schedule with a dynamic skip handler script
284+
2. Before the scheduled job executes, Windmill runs the handler script
285+
3. The handler receives `scheduled_for` (ISO 8601 datetime string) as a parameter
286+
4. If the handler returns `true`, the scheduled job executes normally
287+
5. If the handler returns any other value, the job is skipped (marked as success with `skipped` flag)
288+
6. If the handler throws an exception, normal error handling applies and the job fails
289+
290+
#### Example handler
291+
292+
```typescript
293+
export async function main(scheduled_for: string): Promise<boolean> {
294+
const date = new Date(scheduled_for);
295+
const dayOfWeek = date.getUTCDay();
296+
297+
// Skip on weekends (0 = Sunday, 6 = Saturday)
298+
if (dayOfWeek === 0 || dayOfWeek === 6) {
299+
return false;
300+
}
301+
302+
// Check if it's a holiday (example: checking external API)
303+
const isHoliday = await checkHolidayAPI(date);
304+
return !isHoliday;
305+
}
306+
```
307+
308+
From the schedule configuration, select your validation script in the "Dynamic skip" section.
309+
310+
![Dynamic skip configuration](./dynamic_skip.png 'Dynamic skip configuration')
311+
312+
:::info
313+
314+
If the validation handler script is deleted or archived after the schedule is created, the schedule will fail at runtime with a clear error message indicating the handler script was not found.
315+
316+
:::
317+
272318
### Be notified every time a scheduled workflow has been executed
273319

274320
For scheduled flows, add a simple step to be notified about the execution of the scheduled flow.

0 commit comments

Comments
 (0)