| 1 | # Examples |
| 2 | |
| 3 | These small Wrangler projects demonstrate the Workers platform that `celld` |
| 4 | supports, one service or API at a time: |
| 5 | |
| 6 | - `hello/` — a stateless Worker `fetch` handler |
| 7 | - `webapi/` — common Web Platform APIs |
| 8 | - `static-assets/` — an asset-only website with headers and redirects |
| 9 | - `counter/` — a SQLite-backed Durable Object |
| 10 | - `vectordb/` — nearest-color search with a per-object `vec0` index |
| 11 | - `d1/` — a guestbook on a D1 database |
| 12 | - `r2/` — object reads, writes, and deletes on an R2 bucket |
| 13 | - `kv/` — key reads, writes, and deletes in a KV namespace |
| 14 | - `queues/` — a producer and a consumer, with retries and a dead-letter queue |
| 15 | - `async/` — a timer and asynchronous Durable Object storage |
| 16 | - `body/` — request and response bodies |
| 17 | - `router/` — Worker-to-Durable-Object routing |
| 18 | - `wsecho/` — WebSocket echo with hibernation |
| 19 | - `wsclient/` — outbound WebSocket client from a Durable Object |
| 20 | - `alarm/` — a Durable Object alarm handler |
| 21 | - `cron/` — a cron trigger that logs each tick |
| 22 | - `workflow/` — a Workflow that builds a report in one durable step |
| 23 | - `rpc/` — Durable Object method calls through JS RPC |
| 24 | - `dynamic-worker-tails/` — a runtime-loaded Worker with a Tail Worker |
| 25 | - `facets/` — a Durable Object facet over a class the Worker Loader starts |
| 26 | - `container/` — a Durable Object that supervises a container with |
| 27 | `@cloudflare/containers`; needs `npm install` and a Docker or Podman CLI |
| 28 | - `sandbox/` — the Cloudflare Sandbox SDK: commands, files, and processes |
| 29 | in a container per sandbox; needs `npm install` and a Docker or Podman CLI |
| 30 | - `pi/` — the PiHarness agent loop in a Durable Object |
| 31 | - `opencode/` — the OpenCode Workerd SDK in a Durable Object |
| 32 | - `wasm/` — a Durable Object counter in Rust, compiled to Wasm with |
| 33 | [workers-rs](https://github.com/cloudflare/workers-rs); needs a build step |
| 34 | first (see its [README](wasm/README.md)) |
| 35 | |
| 36 | Deploy an example from its directory to the same bucket the nodes use: |
| 37 | |
| 38 | ```sh |
| 39 | celld deploy . --bucket s3://my-cells-bucket |
| 40 | ``` |
| 41 | |
| 42 | The counter example uses the `name` query parameter as the Durable Object |
| 43 | name. It uses `default` when the parameter is absent. Send requests for |
| 44 | different names to demonstrate independent cells: |
| 45 | |
| 46 | ```sh |
| 47 | curl 'http://127.0.0.1:8080/increment?name=alpha' |
| 48 | curl 'http://127.0.0.1:8080/increment?name=beta' |
| 49 | curl 'http://127.0.0.1:8080/increment?name=alpha' |
| 50 | ``` |
| 51 | |
| 52 | A fleet can place the named cells on different nodes, and each cell keeps an |
| 53 | independent counter. |
| 54 | |
| 55 | They are examples, not the complete compatibility test suite. |