Time Trigger
Wick’s Time Trigger takes a cron-like configuration and calls a configured operation on a schedule.
Any number of Time Triggers can be added to an application.
Example
Example showing how to use the Time Trigger to create a cron-like service that delegates to Wick components.
This app configuration starts off with the common Application kind
and a name field.
kind: wick/app@v1
name: sample_time_trigger
The time trigger takes an
operation
, an optional list of
inputs
to pass to the payload
on execution, and a
schedule
.
triggers:
- kind: wick/trigger/time@v1
operation: comp::write_string
payload:
- name: filename
value: time-trigger.txt
- name: contents
value: Running
schedule:
cron: '*/1 * * * * *'
repeat: 5
A
schedule
takes a required cron string and an optional repeat
parameter which acts as a maximum number of executions. If you need help with cron syntax, visit cron.help.
schedule:
cron: '*/1 * * * * *'
repeat: 5
The full configuration is located at examples/time/time.wick. Run this application locally by cloning the wick repository and using wick run
(or cargo run -p wick-cli -- run
to run from source)
git clone https://github.com/candlecorp/wick && cd wick
wick run examples/time/time.wick
Complete Example
Note: Examples may require environment variables and execution from within the wick project’s root to access any local files.
The full example configuration is included below,
---
kind: wick/app@v1
name: sample_time_trigger
metadata:
description: Example showing how to use the Time Trigger to create a cron-like service that delegates to Wick components.
version: 0.0.1
authors:
- 'Wick Maintainers'
vendors:
- 'Candle Corporation'
licenses:
- Apache-2.0
import:
- name: comp
component:
kind: wick/component/manifest@v1
ref: ../components/wasi-fs/component.wick
with:
root: '{{ ctx.env.ROOT_DIR }}'
triggers:
- kind: wick/trigger/time@v1
schedule:
cron: '*/1 * * * * *'
repeat: 5
payload:
- name: filename
value: 'time-trigger.txt'
- name: contents
value: 'Running'
operation: comp::write_string