Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cron worker example #657

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

pawurb
Copy link

@pawurb pawurb commented Oct 18, 2024

This PR adds minimal example for using cron worker, together with logging. I could not find it anywhere.

Screenshot 2024-10-18 at 12 02 53

Copy link
Collaborator

@zebp zebp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 small issues but otherwise lgtm


#[event(scheduled)]
async fn scheduled(_evt: ScheduledEvent, _env: Env, _ctx: ScheduleContext) {
wasm_rs_dbg::dbg!("Hello cron!");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typically we just use the console_log macro to avoid adding an extra dependency.

command = "cargo install worker-build && worker-build --release"

[triggers]
crons = ["*/5 * * * *"]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice to have a comment above to explain what the example cron does and link to the Cloudflare cron docs.

@pawurb pawurb requested a review from zebp October 25, 2024 09:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants