Skip to content

Commit b454bc7

Browse files
committed
chore: update document && unify crates version to workspace
1 parent 55a3673 commit b454bc7

File tree

6 files changed

+54
-26
lines changed

6 files changed

+54
-26
lines changed

Cargo.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ members = [
77
]
88

99
[workspace.package]
10+
version = "0.0.16"
1011
edition = "2024"
1112
repository = "https://github.com/washanhanzi/connectrpc-axum"
1213

connectrpc-axum-build/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "connectrpc-axum-build"
3-
version = "0.0.15"
4-
edition = "2024"
3+
version.workspace = true
4+
edition.workspace = true
55
description = "Code generation for connectrpc-axum"
66
readme = "../README.md"
77
repository = "https://github.com/washanhanzi/connectrpc-axum"

connectrpc-axum/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "connectrpc-axum"
3-
version = "0.0.14"
4-
edition = "2024"
3+
version.workspace = true
4+
edition.workspace = true
55
description = "axum style and axum compatible Connect Protocol server"
66
readme = "../README.md"
77
repository = "https://github.com/washanhanzi/connectrpc-axum"

docs/guide/architecture.md

Lines changed: 44 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,9 @@ These are the types you interact with when building services:
8787
| Type | Purpose |
8888
|------|---------|
8989
| `ConnectRequest<T>` | Axum extractor - deserializes protobuf/JSON from request body |
90-
| `ConnectStreamingRequest<T>` | Extractor for client streaming requests |
90+
| `ConnectRequest<Streaming<T>>` | Extractor for client/bidi streaming requests (unified pattern) |
91+
| `Streaming<T>` | Stream of messages from client (similar to Tonic's `Streaming<T>`) |
92+
| `ConnectStreamingRequest<T>` | Extractor for client streaming requests (legacy) |
9193
| `ConnectResponse<T>` | Response wrapper - encodes per detected protocol |
9294
| `ConnectStreamResponse<S>` | Server streaming response wrapper |
9395
| `StreamBody<S>` | Marker for streaming response bodies |
@@ -108,12 +110,32 @@ These implement `axum::handler::Handler` for each RPC pattern:
108110

109111
| Wrapper | Use Case |
110112
|---------|----------|
111-
| `ConnectHandlerWrapper<F>` | Unary requests |
112-
| `ConnectStreamHandlerWrapper<F>` | Server streaming |
113-
| `ConnectClientStreamHandlerWrapper<F>` | Client streaming |
114-
| `ConnectBidiStreamHandlerWrapper<F>` | Bidirectional streaming |
113+
| `ConnectHandlerWrapper<F>` | Unified: unary, server/client/bidi streaming (auto-detected) |
114+
| `ConnectStreamHandlerWrapper<F>` | Server streaming (explicit) |
115+
| `ConnectClientStreamHandlerWrapper<F>` | Client streaming (explicit) |
116+
| `ConnectBidiStreamHandlerWrapper<F>` | Bidirectional streaming (explicit) |
115117
| `TonicCompatibleHandlerWrapper<F>` | Tonic-style unary with axum extractors |
116-
| `TonicCompatibleStreamHandlerWrapper<F>` | Tonic-style streaming with axum extractors |
118+
| `TonicCompatibleStreamHandlerWrapper<F>` | Tonic-style server streaming with axum extractors |
119+
| `TonicCompatibleClientStreamHandlerWrapper<F>` | Tonic-style client streaming with axum extractors |
120+
| `TonicCompatibleBidiStreamHandlerWrapper<F>` | Tonic-style bidi streaming with axum extractors |
121+
122+
### How Handler Wrappers Work
123+
124+
`ConnectHandlerWrapper<F>` is a newtype that wraps a user function `F`. It has multiple `impl Handler<T, S>` blocks, each with different `where` bounds on `F`:
125+
126+
```rust
127+
// When F returns ConnectResponse<Resp> (not StreamBody)
128+
impl<F, ...> Handler<(ConnectRequest<Req>,), ()> for ConnectHandlerWrapper<F>
129+
where F: Fn(ConnectRequest<Req>) -> Fut,
130+
Fut: Future<Output = Result<ConnectResponse<Resp>, ConnectError>>, ...
131+
132+
// When F returns ConnectResponse<StreamBody<St>>
133+
impl<F, ...> Handler<(ConnectRequest<Req>, StreamBody<St>), ()> for ConnectHandlerWrapper<F>
134+
where F: Fn(ConnectRequest<Req>) -> Fut,
135+
Fut: Future<Output = Result<ConnectResponse<StreamBody<St>>, ConnectError>>, ...
136+
```
137+
138+
The compiler inspects `F`'s signature (input types + return type) and selects the impl whose `where` bounds match. The `T` parameter in `Handler<T, S>` acts as a discriminator tag - it's not used at runtime, only for impl selection.
117139

118140
## Builder Pattern
119141

@@ -196,14 +218,27 @@ connectrpc-axum-examples/ # Examples and test clients
196218
| Module | Purpose |
197219
|--------|---------|
198220
| `tonic.rs` | `ContentTypeSwitch` and `TonicCompatible` types |
199-
| `tonic/handler.rs` | Tonic-compatible handler wrappers and factory traits |
221+
| `tonic/handler.rs` | Tonic-compatible handler wrappers, factory traits, and boxed call types |
200222
| `tonic/parts.rs` | `RequestContext`, `CapturedParts`, and `FromRequestPartsLayer` |
201223

202224
The tonic module provides two key capabilities:
203225

204226
1. **Protocol switching**: `ContentTypeSwitch` routes by Content-Type header between gRPC and Connect
205227
2. **Extractor support**: `FromRequestPartsLayer` captures HTTP request parts for use with axum's `FromRequestParts` extractors in tonic-style handlers
206228

229+
#### Boxed Call Types
230+
231+
The tonic module defines boxed callable types for generated service code:
232+
233+
| Type | Purpose |
234+
|------|---------|
235+
| `BoxedCall<Req, Resp>` | Unary RPC callable |
236+
| `BoxedStreamCall<Req, Resp>` | Server streaming RPC callable |
237+
| `BoxedClientStreamCall<Req, Resp>` | Client streaming RPC callable |
238+
| `BoxedBidiStreamCall<Req, Resp>` | Bidirectional streaming RPC callable |
239+
240+
Each has corresponding factory traits (`IntoFactory`, `IntoStreamFactory`, `IntoClientStreamFactory`, `IntoBidiStreamFactory`) for adapting user handlers.
241+
207242
### context/ module
208243

209244
| Module | Purpose |
@@ -217,7 +252,7 @@ The tonic module provides two key capabilities:
217252

218253
| Module | Purpose |
219254
|--------|---------|
220-
| `request.rs` | `ConnectRequest<T>` extractor |
255+
| `request.rs` | `ConnectRequest<T>` and `Streaming<T>` extractors |
221256
| `response.rs` | `ConnectResponse<T>` encoding |
222257
| `stream.rs` | Streaming types and frame handling |
223258

@@ -237,6 +272,7 @@ prost_build::Config
237272

238273
- User configuration via `with_prost_config()` is applied here
239274
- All type customization (attributes, extern paths) must be done in this pass
275+
- Generated builders use the unified `post_connect()` function which auto-detects RPC type from handler signature
240276

241277
### Pass 1.5: Serde Implementations (always)
242278

docs/guide/development.md

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,4 @@ This project includes several [Claude Code skills](https://docs.anthropic.com/en
3333
| `submit-issue` | Handle questions, feature requests, and bug reports. Attempts to answer from documentation first, verifies bugs with tests, then submits GitHub issues when needed. |
3434
| `test` | Run the complete test suite including unit tests, doc tests, and Go client integration tests. |
3535
| `compare-repo` | Compare an external GitHub repository against connectrpc-axum. Analyzes features, architecture, and implementation to generate a comparison document. |
36-
| `sync-arch-doc` | Sync architecture documentation with main branch changes. Tracks the `docs/arch` branch against `origin/main` and updates architecture docs accordingly. |
37-
38-
### Reference Skills
39-
40-
These skills are used automatically by Claude when relevant:
41-
42-
| Skill | Description |
43-
|-------|-------------|
44-
| `connect-go-reference` | Reference the local `connect-go/` directory for ConnectRPC protocol details. Always uses local files instead of fetching from GitHub. |
45-
| `architecture` | Quick reference to project architecture at `docs/guide/architecture.md`. Use when understanding codebase structure, module organization, or key types. |
36+
| `sync-arch-doc` | Sync architecture documentation with main branch changes. Tracks the `docs/arch` branch against `main` and updates architecture docs accordingly. |

0 commit comments

Comments
 (0)