You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/guide/architecture.md
+8-2Lines changed: 8 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -157,6 +157,7 @@ These are the types you interact with when building services:
157
157
|`CompressionContext`| Per-request compression context with envelope settings and full `CompressionConfig`|
158
158
|`CompressionEncoding`| Supported encodings: `Gzip`, `Deflate`, `Brotli`, `Zstd`, or `Identity`. Use `codec_with_level()` for level-aware compression |
159
159
|`CompressionLevel`| Compression level (re-exported from tower-http) |
@@ -208,6 +209,8 @@ Two functions create method routers from handlers:
208
209
|`post_connect(f)`| POST | Unary and streaming RPCs |
209
210
|`get_connect(f)`| GET | Idempotent unary RPCs (query param encoding) |
210
211
212
+
For methods marked with `option idempotency_level = NO_SIDE_EFFECTS` in proto, the code generator automatically merges `get_connect()` and `post_connect()` handlers, enabling both HTTP GET and POST requests per the Connect protocol spec.
213
+
211
214
### How Handler Wrappers Work
212
215
213
216
`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`. The compiler selects the appropriate impl based on the handler signature.
@@ -341,7 +344,7 @@ For generated code to provide default "unimplemented" methods:
341
344
342
345
| Module | Purpose |
343
346
|--------|---------|
344
-
|`protocol.rs`|`RequestProtocol` enum, detection, and validation functions (`can_handle_content_type`, `can_handle_get_encoding`, `SUPPORTED_CONTENT_TYPES`) |
|`envelope_compression.rs`|`Codec` trait, per-envelope compression, `CompressionEncoding::codec_with_level()` for level-aware codecs |
346
349
|`limit.rs`| Receive and send message size limits |
347
350
|`timeout.rs`| Request timeout handling |
@@ -408,7 +411,7 @@ Method availability is enforced via trait bounds:
408
411
409
412
**Constraints:**`no_handlers()` and `with_tonic()` cannot be combined (enforced at compile time).
410
413
411
-
**Protoc Fetching:** The `fetch_protoc(version, path)` method downloads a protoc binary to the specified path using the protoc-fetcher crate. This is useful for CI environments or when a system protoc is unavailable.
414
+
**Protoc Fetching:** The `fetch_protoc(version, path)` method downloads a protoc binary to the specified path using the protoc-fetcher crate. This requires the `fetch-protoc` feature flag. Useful for CI environments or when a system protoc is unavailable.
412
415
413
416
### Pass 1: Prost + Connect
414
417
@@ -423,6 +426,9 @@ prost_build::Config
423
426
- User configuration via `with_prost_config()` is applied here
424
427
- All type customization (attributes, extern paths) must be done in this pass
425
428
- Generated builders use the unified `post_connect()` function which auto-detects RPC type from handler signature
429
+
- For methods with `idempotency_level = NO_SIDE_EFFECTS`, the generator merges `get_connect()` and `post_connect()` handlers
430
+
- Generated builders expose `{METHOD}_IDEMPOTENCY` constants for each method's idempotency level
431
+
-`build_connect()` convenience method wraps the router with `MakeServiceBuilder::new()`, providing default gzip compression
426
432
- With `no_handlers()`, only message types are generated (no service builders)
427
433
- Streaming type aliases (`BoxedCall`, `BoxedStreamCall`, etc.) are only generated for RPC patterns actually used by the service
Use `.fetch_protoc()` to automatically download the protoc compiler. This is useful when you don't want to require protoc to be installed on the build machine.
17
17
18
+
::: warning Feature Required
19
+
The `fetch_protoc()` method requires the `fetch-protoc` feature flag:
20
+
21
+
```toml
22
+
[build-dependencies]
23
+
connectrpc-axum-build = { version = "*", features = ["fetch-protoc"] }
0 commit comments