Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions examples/cron/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
target
17 changes: 17 additions & 0 deletions examples/cron/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[package]
name = "cron-worker"
version = "0.1.0"
edition = "2021"

[package.metadata.release]
release = false

# https://github.com/rustwasm/wasm-pack/issues/1247
[package.metadata.wasm-pack.profile.release]
wasm-opt = false

[lib]
crate-type = ["cdylib"]

[dependencies]
worker = { workspace = true }
3 changes: 3 additions & 0 deletions examples/cron/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# `cron-worker` on Cloudflare Workers

Demonstration of using cron Worker invocation.
6 changes: 6 additions & 0 deletions examples/cron/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
use worker::*;

#[event(scheduled)]
async fn scheduled(_evt: ScheduledEvent, _env: Env, _ctx: ScheduleContext) {
console_log!("Hello cron!");
}
14 changes: 14 additions & 0 deletions examples/cron/wrangler.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name = "cron-worker"
main = "build/worker/shim.mjs"
compatibility_date = "2023-03-22"

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

[triggers]
# Run every 5 minutes. https://developers.cloudflare.com/workers/configuration/cron-triggers/
crons = ["*/5 * * * *"]

[observability]
enabled = true
head_sampling_rate = 1