| 1 | # Examples |
| 2 | |
| 3 | These small Wrangler projects demonstrate progressively more of the Worker and |
| 4 | Durable Object surface supported by `celld`: |
| 5 | |
| 6 | - `hello/` — a stateless Worker `fetch` handler |
| 7 | - `webapi/` — common Web Platform APIs |
| 8 | - `counter/` — a SQLite-backed Durable Object |
| 9 | - `vectordb/` — nearest-color search with a per-object `vec0` index |
| 10 | - `d1/` — a guestbook on a D1 database |
| 11 | - `r2/` — object reads, writes, and deletes on an R2 bucket |
| 12 | - `kv/` — key reads, writes, and deletes in a KV namespace |
| 13 | - `async/` — a timer and asynchronous Durable Object storage |
| 14 | - `body/` — request and response bodies |
| 15 | - `router/` — Worker-to-Durable-Object routing |
| 16 | - `wsecho/` — WebSocket echo with hibernation |
| 17 | - `wsclient/` — outbound WebSocket client from a Durable Object |
| 18 | - `alarm/` — a Durable Object alarm handler |
| 19 | - `cron/` — a cron trigger that logs each tick |
| 20 | - `workflow/` — a Workflow that builds a report in one durable step |
| 21 | - `rpc/` — Durable Object method calls through JS RPC |
| 22 | - `wasm/` — a Durable Object counter in Rust, compiled to Wasm with |
| 23 | [workers-rs](https://github.com/cloudflare/workers-rs); needs a build step |
| 24 | first (see its [README](wasm/README.md)) |
| 25 | |
| 26 | Deploy an example from its directory to the same bucket the nodes use: |
| 27 | |
| 28 | ```sh |
| 29 | celld deploy . --bucket s3://my-cells-bucket |
| 30 | ``` |
| 31 | |
| 32 | The counter example uses the `name` query parameter as the Durable Object |
| 33 | name. It uses `default` when the parameter is absent. Send requests for |
| 34 | different names to demonstrate independent cells: |
| 35 | |
| 36 | ```sh |
| 37 | curl 'http://127.0.0.1:8080/increment?name=alpha' |
| 38 | curl 'http://127.0.0.1:8080/increment?name=beta' |
| 39 | curl 'http://127.0.0.1:8080/increment?name=alpha' |
| 40 | ``` |
| 41 | |
| 42 | A fleet can place the named cells on different nodes, and each cell keeps an |
| 43 | independent counter. |
| 44 | |
| 45 | They are examples, not the complete compatibility test suite. |