Skip to content
This repository was archived by the owner on Oct 22, 2025. It is now read-only.

Commit 3f08a5a

Browse files
committed
chore: implement Registry.run (#998)
1 parent 25e4447 commit 3f08a5a

File tree

140 files changed

+2852
-1587
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

140 files changed

+2852
-1587
lines changed

CLAUDE.md

Lines changed: 90 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,29 @@
55
- Use `RivetKit` when referring to the project in documentation and plain English
66
- Use `rivetkit` when referring to the project in code, package names, and imports
77

8+
## `packages/**/package.json`
9+
10+
- Always include relevant keywords for the packages
11+
12+
## `packages/**/README.md`
13+
14+
Always include a README.md for new packages. The `README.md` should always follow this structure:
15+
16+
```md
17+
# RivetKit {subname, e.g. library: RivetKit Workers, driver and platform: RivetKit Redis Adapter, RivetKit Cloudflare Workers Adapter}
18+
19+
_Lightweight Libraries for Backends_
20+
21+
[Learn More →](https://github.com/rivet-gg/rivetkit)
22+
23+
[Discord](https://rivet.gg/discord) — [Documentation](https://rivetkit.org) — [Issues](https://github.com/rivet-gg/rivetkit/issues)
24+
25+
## License
26+
27+
Apache 2.0
28+
```
29+
30+
831
## Common Terminology
932

1033
- **Worker**: A stateful, long-lived entity that processes messages and maintains state
@@ -20,12 +43,14 @@
2043

2144
## Build Commands
2245

46+
Run these commands from the root of the project. They depend on Turborepo, so you cannot run the commands within the package itself. Running these commands are important in order to ensure that all dependencies are automatically built.
47+
2348
- **Type Check:** `pnpm check-types` - Verify TypeScript types
2449
- **Check specific package:** `pnpm check-types -F rivetkit` - Check only specified package
2550
- **Build:** `pnpm build` - Production build using Turbopack
2651
- **Build specific package:** `pnpm build -F rivetkit` - Build only specified package
2752
- **Format:** `pnpm fmt` - Format code with Biome
28-
- Do not run the format command automatically.
53+
- Do not run the format command automatically.
2954

3055
## Core Concepts
3156

@@ -44,6 +69,7 @@ Driver interfaces define the contract between rivetkit and various backends:
4469
- **WorkerDriver:** Manages worker state, lifecycle, and persistence
4570
- **ManagerDriver:** Manages worker discovery, routing, and scaling
4671
- **CoordinateDriver:** Handles peer-to-peer communication between worker instances
72+
- Only applicable in coordinate topologies
4773

4874
### Driver Implementations
4975

@@ -75,6 +101,7 @@ This ensures imports resolve correctly across different build environments and p
75101
## Code Style Guidelines
76102

77103
- **Formatting:** Uses Biome for consistent formatting
104+
- See biome.json for reference on formatting rules
78105
- **Imports:** Organized imports enforced, unused imports warned
79106
- **TypeScript:** Strict mode enabled, target ESNext
80107
- **Naming:**
@@ -83,26 +110,28 @@ This ensures imports resolve correctly across different build environments and p
83110
- UPPER_CASE for constants
84111
- Use `#` prefix for private class members (not `private` keyword)
85112
- **Error Handling:**
86-
- Extend from `WorkerError` base class
113+
- Extend from `WorkerError` base class (packages/core/src/worker/errors.ts)
87114
- Use `UserError` for client-safe errors
88115
- Use `InternalError` for internal errors
89116
- Don't try to fix type issues by casting to unknown or any. If you need to do this, then stop and ask me to manually intervene.
90117
- Write log messages in lowercase
91-
- Instead of returning raw HTTP responses with c.json, use or write an error in packages/rivetkit/src/worker/errors.ts and throw that instead. The middleware will automatically serialize the response for you.
118+
- Use `logger()` to log messages
119+
- Do not store `logger()` as a variable, always call it using `logger().info("...")`
120+
- Use structured logging where it makes sense, for example: `logger().info("foo", { bar: 5, baz: 10 })`
121+
- Supported logging methods are: trace, debug, info, warn, error, critical
122+
- Instead of returning errors as raw HTTP responses with c.json, use or write an error in packages/rivetkit/src/worker/errors.ts and throw that instead. The middleware will automatically serialize the response for you.
92123

93124
## Project Structure
94125

95126
- Monorepo with pnpm workspaces and Turborepo
96-
- Core code in `packages/rivetkit/`
127+
- Core code in `packages/core/`
97128
- Platform implementations in `packages/platforms/`
98129
- Driver implementations in `packages/drivers/`
99130

100131
## Development Notes
101132

102-
- Prefer classes over factory functions
103133
- Use zod for runtime type validation
104134
- Use `assertUnreachable(x: never)` for exhaustive type checking in switch statements
105-
- Follow existing patterns for P2P networking
106135
- Add proper JSDoc comments for public APIs
107136
- Ensure proper error handling with descriptive messages
108137
- Run `pnpm check-types` regularly during development to catch type errors early. Prefer `pnpm check-types` instead of `pnpm build`.
@@ -112,3 +141,58 @@ This ensures imports resolve correctly across different build environments and p
112141
## Test Guidelines
113142

114143
- Do not check if errors are an instanceOf WorkerError in tests. Many error types do not have the same prototype chain when sent over the network, but still have the same properties so you can safely cast with `as`.
144+
145+
## Examples
146+
147+
Examples live in the `examples/` folder.
148+
149+
### `examples/*/package.json`
150+
151+
- Always name the example `example-{name}`
152+
- Always use `workspace:*` for dependencies
153+
- Use `tsx` unless otherwise instructed
154+
- Always have a `dev` and `check-types` scripts
155+
- `dev` should use `tsx --watch` unless otherwise instructed
156+
- `check-types` should use `tsc --noEmit`
157+
158+
### `examples/*/README.md`
159+
160+
Always include a README.md. The `README.md` should always follow this structure:
161+
162+
```md
163+
# {human readable title} for RivetKit
164+
165+
Example project demonstrating {specific feature} with [RivetKit](https://rivetkit.org).
166+
167+
[Learn More →](https://github.com/rivet-gg/rivetkit)
168+
169+
[Discord](https://rivet.gg/discord) — [Documentation](https://rivetkit.org) — [Issues](https://github.com/rivet-gg/rivetkit/issues)
170+
171+
## Getting Started
172+
173+
### Prerequisites
174+
175+
- {node or bun based on demo}
176+
- {any other related services if this integrates with external SaaS}
177+
178+
### Installation
179+
180+
```sh
181+
git clone https://github.com/rivet-gg/rivetkit
182+
cd rivetkit/examples/{name}
183+
npm install
184+
```
185+
186+
### Development
187+
188+
```sh
189+
npm run dev
190+
```
191+
192+
{instructions to either open browser or run script to test it}
193+
194+
## License
195+
196+
Apache 2.0
197+
```
198+

docs/workers/quickstart.mdx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ const myRealtime = realtime({
3030

3131
const registry = setup({
3232
registry: { counter, myWorkflow, myRealtime },
33-
maxConnParamLength: 123
3433
});
3534

3635
export type Registry = typeof registry;

examples/chat-room-python/.gitignore

Lines changed: 0 additions & 2 deletions
This file was deleted.

examples/chat-room-python/requirements.txt

Lines changed: 0 additions & 4 deletions
This file was deleted.

examples/chat-room-python/scripts/cli.py

Lines changed: 0 additions & 52 deletions
This file was deleted.

examples/chat-room-python/scripts/connect.py

Lines changed: 0 additions & 30 deletions
This file was deleted.

examples/chat-room-python/src/server.ts

Lines changed: 0 additions & 4 deletions
This file was deleted.

examples/chat-room-python/src/workers/registry.ts

Lines changed: 0 additions & 40 deletions
This file was deleted.

examples/chat-room-python/tests/test_chat_room.py

Lines changed: 0 additions & 66 deletions
This file was deleted.

0 commit comments

Comments
 (0)