connectrpc 0.2.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +57 -21
- data/docs/design.md +245 -52
- data/docs/development.md +102 -14
- data/docs/grpc-web.md +30 -13
- data/docs/grpc.md +98 -5
- data/docs/rbs.md +56 -19
- data/docs/streaming.md +80 -34
- data/docs/unary.md +269 -45
- data/lib/connectrpc/bindings/google_protobuf.rb +20 -7
- data/lib/connectrpc/client.rb +47 -22
- data/lib/connectrpc/deadline.rb +27 -6
- data/lib/connectrpc/error.rb +2 -2
- data/lib/connectrpc/generator/names.rb +17 -0
- data/lib/connectrpc/generator/rbs_renderer.rb +4 -3
- data/lib/connectrpc/generator/renderer.rb +35 -3
- data/lib/connectrpc/generator/runtime_names.rb +23 -5
- data/lib/connectrpc/generator/schema.rb +14 -7
- data/lib/connectrpc/grpc.rb +7 -4
- data/lib/connectrpc/grpc_client.rb +2 -2
- data/lib/connectrpc/grpc_server.rb +14 -14
- data/lib/connectrpc/grpc_web_cors.rb +12 -4
- data/lib/connectrpc/grpc_web_server.rb +19 -13
- data/lib/connectrpc/instrumentation.rb +47 -7
- data/lib/connectrpc/keepalive.rb +40 -0
- data/lib/connectrpc/method.rb +8 -8
- data/lib/connectrpc/metrics/connection_observer.rb +46 -17
- data/lib/connectrpc/metrics/definitions.rb +6 -2
- data/lib/connectrpc/protocol.rb +64 -11
- data/lib/connectrpc/proxy.rb +425 -0
- data/lib/connectrpc/server.rb +97 -13
- data/lib/connectrpc/streaming/client.rb +22 -25
- data/lib/connectrpc/streaming/client_execution.rb +2 -1
- data/lib/connectrpc/streaming/client_scope.rb +14 -7
- data/lib/connectrpc/streaming/server.rb +1 -0
- data/lib/connectrpc/streaming/server_terminal.rb +57 -14
- data/lib/connectrpc/streaming/session_messages.rb +12 -5
- data/lib/connectrpc/streaming/streams.rb +17 -6
- data/lib/connectrpc/streaming/terminal.rb +3 -5
- data/lib/connectrpc/transports/net_http.rb +512 -52
- data/lib/connectrpc/version.rb +1 -1
- data/lib/connectrpc.rb +1 -0
- data/sig/connectrpc.rbs +63 -17
- metadata +6 -2
data/docs/development.md
CHANGED
|
@@ -86,7 +86,7 @@ for final handoff; moved middleware specs have their own canonical gate.
|
|
|
86
86
|
[CI](https://github.com/jimeh/connectrpc-ruby/blob/main/docs/ci.md) splits the same
|
|
87
87
|
canonical component tasks into nine core, three Rails, four optional HTTP/2,
|
|
88
88
|
two optional Rack, two optional testing, two optional RBS and four optional Falcon
|
|
89
|
-
checks, plus the optional OTel, metrics, health and
|
|
89
|
+
checks, plus the optional OTel, metrics, health, Sentry and hyper leaves, with syntax, specs, package isolation,
|
|
90
90
|
interop and official conformance on both Rubies. Hosted clean-environment and
|
|
91
91
|
matrix results remain CI evidence; a local pass cannot establish them.
|
|
92
92
|
|
|
@@ -321,7 +321,7 @@ into one of three tiers, and internal gems follow the train:
|
|
|
321
321
|
| Gem | Package | Requirement | Reason | What would unblock it |
|
|
322
322
|
| --- | --- | --- | --- | --- |
|
|
323
323
|
| async-http | connectrpc-async | `~> 0.105.0` | Own copies of `read_in_background` and `Output#start` publish their task before the eager first pass; an `Output` subclass calls the private `stream`/`passthrough`; the `Stream` module writes `@input`/`@output` and reads `@length`; `Server#each` is an owned loop. The require guard checks their shape, but not the eager-start ordering or ivar roles they replace, and reverting them hangs the suite. | Upstream ask U2 in [issue #68](https://github.com/jimeh/connectrpc-ruby/issues/68): publish the reader and output tasks before their first run, a stream-class hook, and a `Stream#length` reader. |
|
|
324
|
-
| protocol-http2 | connectrpc-async | `~> 0.29.2` | Receive-window enforcement (`consume_local_window` and the stream `receive_data` check) and recording credit before writing WINDOW_UPDATE replace its flow-control accounting. | Upstream ask U3 in issue #68: enforce receive flow control and expand the local window before writing WINDOW_UPDATE. |
|
|
324
|
+
| protocol-http2 | connectrpc-async | `~> 0.29.2` | Receive-window enforcement (`consume_local_window` and the stream `receive_data` check) and recording credit before writing WINDOW_UPDATE replace its flow-control accounting. `update_local_settings` keeps the configured connection window target, and streams take the advertised stream window before SETTINGS ACK. | Upstream ask U3 in issue #68: enforce receive flow control and expand the local window before writing WINDOW_UPDATE. |
|
|
325
325
|
|
|
326
326
|
connectrpc-falcon has no patch pins of its own. Its `HTTP1Connection`
|
|
327
327
|
subclasses async-http's `HTTP1::Server`, and Falcon's `UpstreamContract`
|
|
@@ -379,7 +379,8 @@ mise run floors:prometheus
|
|
|
379
379
|
mise run floors:yabeda
|
|
380
380
|
mise run floors:health
|
|
381
381
|
mise run floors:sentry
|
|
382
|
-
mise run floors
|
|
382
|
+
mise run floors:hyper # rb_sys 0.9.130 for the source gem
|
|
383
|
+
mise run floors # all ten
|
|
383
384
|
```
|
|
384
385
|
|
|
385
386
|
Floors do not apply to development tools or transitive-only dependencies. A
|
|
@@ -414,7 +415,8 @@ spec and suite, and reports which contract broke, before anyone bumps a pin:
|
|
|
414
415
|
```sh
|
|
415
416
|
mise run canary:async
|
|
416
417
|
mise run canary:falcon
|
|
417
|
-
mise run canary
|
|
418
|
+
mise run canary:hyper # cargo update in a temporary copy; see below
|
|
419
|
+
mise run canary # all three
|
|
418
420
|
```
|
|
419
421
|
|
|
420
422
|
`CONNECTRPC_DEPENDENCY_CANARY=1` makes the launcher write an ignored
|
|
@@ -512,6 +514,25 @@ tag-triggered publishing workflow. See the
|
|
|
512
514
|
for App and trusted-publisher setup, synchronized versions and recovery.
|
|
513
515
|
Project MIT licensing is approved. Releasing still needs separate, explicit authorization.
|
|
514
516
|
|
|
517
|
+
Guides on main describe the next release. When a PR documents a feature,
|
|
518
|
+
option, event or metric that the latest release lacks, mark it "Since X.Y.Z"
|
|
519
|
+
in the prose with the version the next release will have:
|
|
520
|
+
|
|
521
|
+
- Use the version of the open Release Please PR.
|
|
522
|
+
- When no release PR is open, use the next patch after the version in
|
|
523
|
+
`.github/.release-please-manifest.json`. A merged release PR sets that
|
|
524
|
+
version even while its tag waits to be published. Before 1.0, the release
|
|
525
|
+
config (`bump-patch-for-minor-pre-major`) releases `feat:` commits as a
|
|
526
|
+
patch.
|
|
527
|
+
- A breaking change makes the next release a minor (`bump-minor-pre-major`),
|
|
528
|
+
such as 0.3.0 after 0.2.1 in the manifest. Mark it with that version, and update any markers
|
|
529
|
+
on main that name the superseded patch version.
|
|
530
|
+
|
|
531
|
+
Keep markers out of headings, so anchors stay stable, and keep them after the
|
|
532
|
+
release, so readers on older installs can tell what they lack. Fixes and behavior changes to existing
|
|
533
|
+
features need no marker; breaking minors also need migration notes in
|
|
534
|
+
[upgrading.md](upgrading.md).
|
|
535
|
+
|
|
515
536
|
## Optional Rails development
|
|
516
537
|
|
|
517
538
|
The self-contained [Rails adapter guide](../gems/connectrpc-on-rails/README.md)
|
|
@@ -664,7 +685,7 @@ run independently of the other package jobs. Runtime bundles never gain an SDK.
|
|
|
664
685
|
Package checks install normal dependencies offline into a fresh external
|
|
665
686
|
GEM_HOME, then run copied generated callers with actual SDK in-memory exports.
|
|
666
687
|
See the [package guide](../gems/connectrpc-otel/README.md) for the precise trace
|
|
667
|
-
baseline and unknown-method
|
|
688
|
+
baseline and the unknown-method `rpc.method_original` limitation.
|
|
668
689
|
|
|
669
690
|
## Optional metrics development
|
|
670
691
|
|
|
@@ -703,6 +724,69 @@ is covered by `mise run test -- spec/context_on_cancel_spec.rb`. The vendored
|
|
|
703
724
|
schema and generated files belong to `generation:build`/`generation:check`.
|
|
704
725
|
See the [health guide](../gems/connectrpc-health/README.md).
|
|
705
726
|
|
|
727
|
+
## Optional hyper development
|
|
728
|
+
|
|
729
|
+
`gems/connectrpc-hyper/` is a Rust extension (hyper, h2, rustls with
|
|
730
|
+
aws-lc-rs, tokio; bound with magnus and rb-sys). Besides the pinned Rubies it
|
|
731
|
+
needs Rust 1.98.0 (the rb-sys-dock image's), which `hyper:toolchain` (a
|
|
732
|
+
`hyper:tools` dependency) installs from `mise.lock` with rustfmt, clippy,
|
|
733
|
+
cargo-deny 0.20.2 and cargo-audit 0.23.0; libclang for
|
|
734
|
+
bindgen; a C compiler; and Go 1.27.3 for the peer. On distributions whose
|
|
735
|
+
libclang lacks clang's resource headers, the launcher points bindgen at the C
|
|
736
|
+
compiler's include directory. Tasks:
|
|
737
|
+
|
|
738
|
+
| Command | Purpose |
|
|
739
|
+
| --- | --- |
|
|
740
|
+
| `mise run hyper:setup` | Install the bundle under `vendor/hyper/bundle` and compile the extension into `lib/connectrpc/hyper/<minor>/` (ignored), one per Ruby minor. |
|
|
741
|
+
| `mise run hyper:peer` | Build the disposable grpc-go/connect-go/raw HTTP/2 Go peer into `vendor/hyper/peer`. |
|
|
742
|
+
| `mise run hyper:test -- spec/pool_spec.rb` | Run specs (paths relative to the gem); coverage goes to `coverage/hyper/<Ruby>/`. |
|
|
743
|
+
| `mise run hyper:check` | Ruby syntax and RuboCop, `cargo fmt --check`, `cargo clippy -D warnings`, `cargo test --lib`, `cargo deny check`, `cargo audit` and the third-party notices check. |
|
|
744
|
+
| `mise run hyper:interop` | The grpc-go/connect-go interop matrix (`--tag interop`). |
|
|
745
|
+
| `mise run hyper:package` | Build the source gem, fetch its locked crates into `vendor/hyper/cargo`, install it offline (`CARGO_NET_OFFLINE=true`) into a fresh GEM_HOME and run `scripts/smoke.rb`. |
|
|
746
|
+
| `mise run hyper:verify` | All of the above. |
|
|
747
|
+
| `mise run hyper:msrv` | Build the extension with Rust 1.85.0, the declared `rust-version`. |
|
|
748
|
+
| `mise run hyper:cross -- <platform>` | Cross-build one platform gem (or `ruby` for the source gem) into `vendor/hyper/cross/<platform>/`; `PLATFORM=<platform>` also works. `HYPER_CROSS_TWICE=1` rebuilds from empty caches at the same paths and fails unless the SHA256 match. |
|
|
749
|
+
| `mise run hyper:smoke:source -- vendor/hyper/cross/ruby [EVIDENCE.json]` | Install the built source gem into a fresh GEM_HOME, compiling with Rust 1.98.0 and fetching its locked crates, then smoke it. |
|
|
750
|
+
| `mise run hyper:cargo:update` | `cargo update` (or `-- -p <crate>`), then regenerate `THIRD_PARTY_NOTICES.md`. |
|
|
751
|
+
| `mise run canary:hyper` | Non-gating: the specs against `cargo update`'s newest crates. |
|
|
752
|
+
|
|
753
|
+
Repeat a lane on the other Ruby with `MISE_RUBY_VERSION=4.0.9`. The offload
|
|
754
|
+
specs need Ruby 4.0's fiber-scheduler blocking-operation hook and skip
|
|
755
|
+
on 3.4.12; the DNS shim specs need Linux and glibc, and the fork specs skip
|
|
756
|
+
where `fork` is unavailable.
|
|
757
|
+
|
|
758
|
+
Cargo policy: `Cargo.lock` is committed and every build passes `--locked`,
|
|
759
|
+
including `extconf.rb`, cross builds and the source gem's install. Update it
|
|
760
|
+
only with `hyper:cargo:update`, and check that each new crate release is at
|
|
761
|
+
least seven days old, as for tools; the daily
|
|
762
|
+
[canary](ci.md#pins-lifted-canary) shows whether the newest crates still pass.
|
|
763
|
+
`deny.toml` limits licenses and sources. `THIRD_PARTY_NOTICES.md` lists every
|
|
764
|
+
crate linked on any target with its license texts and ships in the gem; a
|
|
765
|
+
stale file fails `hyper:check` and `hyper:package`.
|
|
766
|
+
|
|
767
|
+
Cross builds use rb-sys-dock and the `rbsys/<platform>:0.9.130` images pinned
|
|
768
|
+
by digest in `HyperPlatforms::IMAGES` (Docker required; the image compiles, and
|
|
769
|
+
host Rust 1.98.0 only runs a `cargo metadata --locked` preflight). The image tag
|
|
770
|
+
must equal the bundled rb_sys version, so update both together. `hyper:cross`
|
|
771
|
+
copies the package's tracked and unignored files into
|
|
772
|
+
`vendor/hyper/cross-work/<platform>`, builds there for Ruby 3.4 and 4.0, fails
|
|
773
|
+
if the build changed `Cargo.toml`, `Cargo.lock` or the extension's
|
|
774
|
+
`Cargo.toml`, checks the gem and moves it to `vendor/hyper/cross/`, so several
|
|
775
|
+
platforms can build from one checkout and the checkout stays clean. Cross
|
|
776
|
+
builds keep a Cargo home and rb-sys-dock cache per platform,
|
|
777
|
+
`vendor/hyper/cross-cargo/<platform>` and `vendor/hyper/rb-sys-dock/<platform>`;
|
|
778
|
+
run one build per platform at a time. With `HYPER_CROSS_TWICE=1` it
|
|
779
|
+
deletes the work copy and both caches and rebuilds at the same absolute paths,
|
|
780
|
+
because darwin binaries embed the build's absolute object paths. The `ruby` leaf requires Ruby
|
|
781
|
+
3.4.12 and the commit time as `SOURCE_DATE_EPOCH`, so its archive equals the
|
|
782
|
+
release candidate's source gem.
|
|
783
|
+
`ruby gems/connectrpc-hyper/scripts/install_smoke.rb vendor/hyper/cross/<platform> [EVIDENCE.json]`
|
|
784
|
+
installs a built gem offline into a fresh GEM_HOME with a core gem built from
|
|
785
|
+
the checkout, runs the smoke calls and optionally records release evidence; CI
|
|
786
|
+
uses it on each platform. The source
|
|
787
|
+
gem needs Rust 1.85+, libclang and a C compiler on the installing host. See the
|
|
788
|
+
[package guide](../gems/connectrpc-hyper/README.md) and [the plan](plans/hyper.md).
|
|
789
|
+
|
|
706
790
|
## Optional Sentry development
|
|
707
791
|
|
|
708
792
|
`mise run sentry:setup` installs the independent Sentry bundle under
|
|
@@ -728,14 +812,15 @@ and its limits.
|
|
|
728
812
|
|
|
729
813
|
## Native streaming verification
|
|
730
814
|
|
|
731
|
-
`async:test` and `falcon:test` include the incremental
|
|
732
|
-
matrix, bounded output/ingress, healthy
|
|
733
|
-
`otel:test` includes actual SDK
|
|
734
|
-
codec/handler cleanup and separate
|
|
735
|
-
Falcon H1 focused specs distinguish the
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
815
|
+
`async:test` and `falcon:test` include the incremental
|
|
816
|
+
shape/codec/coding/security matrix, bounded output/ingress, healthy
|
|
817
|
+
same-connection siblings and cancellation. `otel:test` includes actual SDK
|
|
818
|
+
processor-task identity, mTLS peer identity, codec/handler cleanup and separate
|
|
819
|
+
processing/HTTP completion evidence. Falcon H1 focused specs distinguish the
|
|
820
|
+
read of up to 256 KiB of unread input before the response head, bounded by
|
|
821
|
+
`request_body_timeout` and the Connect deadline, from the cooperative 500 ms
|
|
822
|
+
total final-close expiry anchored at actual final HTTP flush. They check the
|
|
823
|
+
read before the head, delayed callbacks spending the same budget, no reads or
|
|
739
824
|
pipeline parsing during remaining grace, admission joins before host cleanup,
|
|
740
825
|
owner interruption and real worker shutdown. Timings may overshoot under reactor
|
|
741
826
|
delay; they are not hard real-time bounds. SDK specs preserve completed delivery
|
|
@@ -760,6 +845,9 @@ aggregate and the existing two-Ruby CI jobs. No test results are cached.
|
|
|
760
845
|
`async:conformance:threaded` adds separate Connect and gRPC unary/server-stream
|
|
761
846
|
client profiles through `ThreadedTransport` from plain threads; see
|
|
762
847
|
[conformance](../conformance/README.md#threadedtransport-client-profiles).
|
|
848
|
+
`async:conformance:per-call` runs the same inventories through `PerCallTransport`
|
|
849
|
+
from plain threads and inside a reactor; see
|
|
850
|
+
[conformance](../conformance/README.md#percalltransport-client-profiles).
|
|
763
851
|
The Falcon-only `falcon:conformance:http1` leaf adds separate SS/CS server
|
|
764
852
|
profiles requiring 174 identity and 160 gzip passes. Root `verify` includes this
|
|
765
853
|
complete H1 gate, so use that pass for full-profile confirmation. Fresh exact
|
|
@@ -779,7 +867,7 @@ servers through connection churn and faults, then checks that everything they
|
|
|
779
867
|
own retires. It is non-gating and belongs to no `test` or `verify` task:
|
|
780
868
|
|
|
781
869
|
```sh
|
|
782
|
-
mise run async:soak # Async H2 Transport, ThreadedTransport and Host
|
|
870
|
+
mise run async:soak # Async H2 Transport, ThreadedTransport, PerCallTransport and Host
|
|
783
871
|
mise run falcon:soak # Falcon HTTP/2 and HTTP/1.1 (HTTP1Transport, Net::HTTP)
|
|
784
872
|
mise run soak # both, Async then Falcon
|
|
785
873
|
```
|
data/docs/grpc-web.md
CHANGED
|
@@ -8,13 +8,12 @@ message bindings, unary invokers and server-stream handlers remain protocol neut
|
|
|
8
8
|
There is no Ruby gRPC-Web client or new runtime dependency.
|
|
9
9
|
|
|
10
10
|
```ruby
|
|
11
|
-
binding = ConnectRPC::Bindings::GoogleProtobuf.new
|
|
12
11
|
cors = ConnectRPC::GRPCWebCORS.new(
|
|
13
12
|
origins: ["https://app.example"], credentials: true,
|
|
14
13
|
request_headers: %w[authorization x-csrf-token], expose_headers: ["x-request-id"]
|
|
15
14
|
)
|
|
16
15
|
server = ConnectRPC::Server.new(
|
|
17
|
-
services: [service], handlers: handlers,
|
|
16
|
+
services: [service], handlers: handlers,
|
|
18
17
|
protocol: %i[connect grpc grpc_web], cors: cors
|
|
19
18
|
)
|
|
20
19
|
```
|
|
@@ -61,7 +60,11 @@ Exactly one framed protobuf request and request EOF precede invocation. Empty
|
|
|
61
60
|
protobuf is a message; missing or excess requests are UNIMPLEMENTED. Excess
|
|
62
61
|
framing is detected without decoding a second message. Reserved flags, request
|
|
63
62
|
terminal, truncation, malformed protobuf/base64 and malformed Content-Length
|
|
64
|
-
are INVALID_ARGUMENT.
|
|
63
|
+
are INVALID_ARGUMENT. Native gRPC on the same Server reports a malformed request
|
|
64
|
+
as INTERNAL instead. Each follows its reference server: grpc-go 1.85.0 maps a
|
|
65
|
+
server request decode failure to INTERNAL (`rpc_util.go`), while connect-go
|
|
66
|
+
1.21.1, the reference gRPC-Web server, maps it to INVALID_ARGUMENT on every
|
|
67
|
+
protocol (`envelope.go`). Unnegotiated compressed DATA is INTERNAL. Unsupported
|
|
65
68
|
valid grpc-encoding tokens are UNIMPLEMENTED; malformed/repeated encoding is
|
|
66
69
|
INTERNAL. Web remains identity-only on a mixed server configured with gzip.
|
|
67
70
|
|
|
@@ -84,13 +87,18 @@ for auth, CSRF and trace request headers.
|
|
|
84
87
|
|
|
85
88
|
Owned OPTIONS preflight returns empty 204 or 403 before RPC observation, body
|
|
86
89
|
reads, binding or application callbacks. Requested method must be POST and
|
|
87
|
-
requested names must be allowed. Max-Age
|
|
88
|
-
|
|
90
|
+
requested names must be allowed. Max-Age defaults to zero, so browsers
|
|
91
|
+
preflight every call. Since 0.3.0, `max_age:` accepts an Integer from 0 to
|
|
92
|
+
86,400 seconds. Actual Web requests without Origin are allowed; disallowed or
|
|
93
|
+
ambiguous origins receive 403 before input.
|
|
89
94
|
Allowed-origin policy also decorates RPC errors, negotiation failures and native
|
|
90
95
|
admission 503. Vary merges Origin, Accept and preflight controls without replacing
|
|
91
96
|
application cache, cookie or security fields. Conflicting application
|
|
92
|
-
access-control fields fail closed before publication.
|
|
93
|
-
|
|
97
|
+
access-control fields fail closed before publication. A head that cannot be
|
|
98
|
+
published, such as one with a conflicting access-control field or over the field
|
|
99
|
+
limit, fails the call and the host aborts the response; no terminal is sent
|
|
100
|
+
without a head. Set `cors: nil` when outer middleware already owns CORS. CORS
|
|
101
|
+
does not authenticate or replace CSRF checks.
|
|
94
102
|
|
|
95
103
|
Native Rails overrides stay private:
|
|
96
104
|
|
|
@@ -106,13 +114,20 @@ invoker, callbacks, authentication, sessions, cookies, CSRF and security headers
|
|
|
106
114
|
remain active. Preflight does not bypass actual POST checks. A valid CSRF token
|
|
107
115
|
does not override Rails' origin policy. No CSRF exemption is installed.
|
|
108
116
|
|
|
117
|
+
Core CORS requires gRPC-Web to be enabled and adds CORS fields only to
|
|
118
|
+
preflights and gRPC-Web responses, never to Connect responses. A cross-origin
|
|
119
|
+
browser Connect client such as connect-es therefore needs outer CORS middleware,
|
|
120
|
+
such as rack-cors, with `cors: nil` on that mount.
|
|
121
|
+
|
|
109
122
|
## Interceptors
|
|
110
123
|
|
|
111
124
|
Web unary calls run the Server's [unary interceptors](unary.md#interceptors)
|
|
112
125
|
with `call.protocol == :grpc_web`, after the single request frame is read and
|
|
113
126
|
decoded and around the invoker. Response metadata written before or after
|
|
114
|
-
`yield
|
|
115
|
-
|
|
127
|
+
`yield`, and a unary error's metadata, are published with the head after the
|
|
128
|
+
chain returns; trailers reach the terminal frame. A server-streaming error's
|
|
129
|
+
metadata joins the head while it is unpublished, and the terminal frame after
|
|
130
|
+
the head is published. Server-streaming Web calls run the Server's
|
|
116
131
|
[stream interceptors](streaming.md#interceptors) with
|
|
117
132
|
`call.protocol == :grpc_web`, after the single request frame is read and
|
|
118
133
|
decoded; the call is a `ServerStreamCall::ServerStreaming` carrying that
|
|
@@ -138,8 +153,8 @@ response. Native output retains one queued and one in-flight 16 KiB entity
|
|
|
138
153
|
fragment. Text uses raw slices of at most 12,288 bytes and flushes padded groups
|
|
139
154
|
at existing write boundaries, including the first small prefix.
|
|
140
155
|
|
|
141
|
-
Native H2 ingress remains 65,536 bytes/five entries
|
|
142
|
-
consumption-based stream credit. The H1 input adapter may retain one pinned
|
|
156
|
+
Native H2 ingress remains one stream receive window (65,536 bytes/five entries
|
|
157
|
+
by default) with 16 KiB chunks and consumption-based stream credit. The H1 input adapter may retain one pinned
|
|
143
158
|
backend chunk of up to 64 KiB. During rejected-input cleanup this remainder can
|
|
144
159
|
coexist with one discard read of at most 64 KiB. Complete parsed field blocks are checked before application copies;
|
|
145
160
|
H2 includes pseudo/status fields. Parser/readahead, HPACK/CONTINUATION temporaries,
|
|
@@ -164,14 +179,16 @@ and owner abort. Each discard read is at most 64 KiB; progress does not reset th
|
|
|
164
179
|
budget and a following request is never consumed. Expiry or malformed framing
|
|
165
180
|
retires that connection raw-first, preserving the original RPC outcome and
|
|
166
181
|
independent aborted delivery. This best effort does not promise delivery for
|
|
167
|
-
arbitrarily slow uploads or extend existing cleanup allowances.
|
|
182
|
+
arbitrarily slow uploads or extend existing cleanup allowances. The 100 ms
|
|
183
|
+
allowance is a provisional budget in the
|
|
184
|
+
[support contract](support.md#falcon-connect-h1-retirement). See the
|
|
168
185
|
[Falcon guide](../gems/connectrpc-falcon/README.md#grpc-web).
|
|
169
186
|
|
|
170
187
|
`Server#cors_response(path:, http_method:, headers:, response: nil)` is a pure
|
|
171
188
|
typed host SPI for early decisions and idempotent decoration, including admission
|
|
172
189
|
503. Call it before lifecycle start for preflight or denied requests.
|
|
173
190
|
|
|
174
|
-
The optional OTel adapter maps Web to the project's gRPC semconv 1.
|
|
191
|
+
The optional OTel adapter maps Web to the project's gRPC semconv 1.45 mapping,
|
|
175
192
|
with `rpc.system.name=grpc` and bounded `connectrpc.protocol=grpc_web`. Call.protocol
|
|
176
193
|
is fixed before subscriber start. Processing, admission, delivery and original
|
|
177
194
|
failures remain separate; SDK/exporter ownership and privacy are unchanged.
|
data/docs/grpc.md
CHANGED
|
@@ -3,6 +3,94 @@
|
|
|
3
3
|
The [supported 0.x contract](support.md) defines the target compatibility
|
|
4
4
|
boundary and the remaining adoption gates.
|
|
5
5
|
|
|
6
|
+
## Quick start
|
|
7
|
+
|
|
8
|
+
This serves and calls the `Greet::V1::GreetService` from the
|
|
9
|
+
[README quick start](../README.md#quick-start) over native gRPC. Generate
|
|
10
|
+
`lib/greet/v1/greet_pb.rb` and `lib/greet/v1/greet_connect.rb` as step 3 there
|
|
11
|
+
shows. The Gemfile needs these gems:
|
|
12
|
+
|
|
13
|
+
```ruby
|
|
14
|
+
gem "connectrpc"
|
|
15
|
+
gem "connectrpc-async"
|
|
16
|
+
gem "google-protobuf", ">= 4.36.2", "< 5"
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
These lines leave the version open. Add the same requirement to both
|
|
20
|
+
`connectrpc` and `connectrpc-async`, such as the one the
|
|
21
|
+
[README quick start](../README.md#quick-start) uses, because the
|
|
22
|
+
[package policy](../README.md#packages) requires matching versions.
|
|
23
|
+
|
|
24
|
+
Save the server as `server.rb` and run `bundle exec ruby server.rb`. It serves
|
|
25
|
+
Connect and native gRPC on one HTTP/2 port, h2c here, inside a reactor the
|
|
26
|
+
application owns. On Ctrl-C, `ensure` closes the host gracefully and Ruby then
|
|
27
|
+
reports the `Interrupt`:
|
|
28
|
+
|
|
29
|
+
```ruby
|
|
30
|
+
$LOAD_PATH.unshift(File.expand_path("lib", __dir__))
|
|
31
|
+
require "async"
|
|
32
|
+
require "connectrpc/async"
|
|
33
|
+
require "greet/v1/greet_connect"
|
|
34
|
+
|
|
35
|
+
class Greeter
|
|
36
|
+
def greet(request, _context)
|
|
37
|
+
Greet::V1::GreetResponse.new(greeting: "Hello, #{request.name}!")
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
service = Greet::V1::GreetService
|
|
42
|
+
server = ConnectRPC::Server.new(
|
|
43
|
+
services: [service::SERVICE],
|
|
44
|
+
handlers: service.handlers_for(Greeter.new, strict: true),
|
|
45
|
+
protocol: :auto
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
Sync do
|
|
49
|
+
host = ConnectRPC::Async::Host.new(server: server, port: 8080).start
|
|
50
|
+
puts "Serving Connect and gRPC on http://127.0.0.1:#{host.port}"
|
|
51
|
+
host.wait # Returns once host.close stops the listeners.
|
|
52
|
+
ensure
|
|
53
|
+
host&.close(grace: 5)
|
|
54
|
+
end
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Save the client as `client.rb` and run `bundle exec ruby client.rb` from another
|
|
58
|
+
terminal. `ThreadedTransport` lets a plain thread, such as a Puma or Sidekiq
|
|
59
|
+
worker, call without a reactor:
|
|
60
|
+
|
|
61
|
+
```ruby
|
|
62
|
+
$LOAD_PATH.unshift(File.expand_path("lib", __dir__))
|
|
63
|
+
require "connectrpc/async"
|
|
64
|
+
require "greet/v1/greet_connect"
|
|
65
|
+
|
|
66
|
+
transport = ConnectRPC::Async::ThreadedTransport.new(origin: "http://127.0.0.1:8080")
|
|
67
|
+
core = ConnectRPC::Client.new(
|
|
68
|
+
base_url: "http://127.0.0.1:8080",
|
|
69
|
+
transport: transport,
|
|
70
|
+
protocol: :grpc
|
|
71
|
+
)
|
|
72
|
+
client = Greet::V1::GreetService::Client.new(client: core)
|
|
73
|
+
begin
|
|
74
|
+
response = client.greet(Greet::V1::GreetRequest.new(name: "gRPC"), timeout: 2)
|
|
75
|
+
puts response.message.greeting # => Hello, gRPC!
|
|
76
|
+
ensure
|
|
77
|
+
transport.close
|
|
78
|
+
end
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
The generated file loads the Google protobuf binding, so neither side passes
|
|
82
|
+
`binding:`, and the binding also serves as the gRPC status codec. Since 0.3.0,
|
|
83
|
+
`handlers_for` maps each RPC to the object's method of the same snake-case name.
|
|
84
|
+
|
|
85
|
+
Code that already runs in a reactor task can use `ConnectRPC::Async::Transport`
|
|
86
|
+
with the same options instead. Since 0.3.0, `ConnectRPC::Async::PerCallTransport`
|
|
87
|
+
suits occasional calls to many servers: it takes no origin and opens one
|
|
88
|
+
connection per call, from a plain thread or inside a reactor. Other gRPC clients, such as grpc-go, can call
|
|
89
|
+
the same server. The [Async guide](../gems/connectrpc-async/README.md) covers
|
|
90
|
+
TLS, mTLS, keepalive and connection management.
|
|
91
|
+
|
|
92
|
+
## Protocol and configuration
|
|
93
|
+
|
|
6
94
|
Configure `Client(protocol: :grpc)` with an Async transport and a protobuf
|
|
7
95
|
binding. Unary, server streaming, client streaming and bidi use the existing
|
|
8
96
|
method declarations, generated clients and scoped stream endpoints. Configure
|
|
@@ -58,9 +146,13 @@ the field block budget. Numeric values above uint32 map to unknown; there is no
|
|
|
58
146
|
10-character spelling limit or unbounded integer parse. Output is canonical.
|
|
59
147
|
Rich status codes compare numerically before unknown-code normalization, and
|
|
60
148
|
rich messages take precedence over grpc-message. Invalid percent escapes remain
|
|
61
|
-
literal; decoded invalid UTF8 is scrubbed.
|
|
62
|
-
|
|
63
|
-
|
|
149
|
+
literal; decoded invalid UTF8 is scrubbed. Details on OK, malformed or
|
|
150
|
+
duplicate details, and mismatched rich codes produce safe internal instead of
|
|
151
|
+
silently dropping rich data. grpc-go 1.85.0 also rejects a mismatch and invalid
|
|
152
|
+
base64, but ignores details that repeat or do not parse as a `google.rpc.Status`,
|
|
153
|
+
and accepts details on OK when their code is also OK. The
|
|
154
|
+
[support contract](support.md#native-grpc-rich-status) classifies this strict
|
|
155
|
+
policy as provisional.
|
|
64
156
|
|
|
65
157
|
Missing server timeout means no logical expiry. gRPC timeout accepts all six
|
|
66
158
|
case-sensitive units and zero as immediately expired. Clients default to 30
|
|
@@ -72,8 +164,9 @@ Send-I/O terminal recovery has one absolute 100ms budget and allows at most
|
|
|
72
164
|
262,144 additional body bytes, with separate finite header limits. It skips
|
|
73
165
|
messages without decoding or inflating them and cannot take over an active
|
|
74
166
|
reader. Only a validated remote error can replace an unhandled send failure;
|
|
75
|
-
remote success cannot. The existing destructive cleanup has a separate
|
|
76
|
-
|
|
167
|
+
remote success cannot. The existing destructive cleanup has a separate 1-second
|
|
168
|
+
[allowance](../gems/connectrpc-async/README.md#cleanup-allowance). A stuck frame
|
|
169
|
+
can fail its connection and siblings during that cleanup.
|
|
77
170
|
|
|
78
171
|
Only actual peer CANCEL resets signal server Context cancellation. Half-close,
|
|
79
172
|
EOF, other resets, connection loss and shutdown do not. No retry or replay occurs.
|
data/docs/rbs.md
CHANGED
|
@@ -4,11 +4,12 @@ The [supported 0.x contract](support.md) defines the target compatibility
|
|
|
4
4
|
boundary and the remaining adoption gates.
|
|
5
5
|
|
|
6
6
|
Every package ships its own gem-discovered signatures and dependency manifest.
|
|
7
|
-
Core also generates mixed unary/streaming service signatures. RBS
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
Core also generates mixed unary/streaming service signatures. RBS and Steep are
|
|
8
|
+
development tools; neither is required by the runtime. Default Connect
|
|
9
|
+
generation writes only Ruby files. The plugin parameter `rbs=true` also adds
|
|
10
|
+
`<stem>_connect.rbs` for each service-bearing input. Since 0.3.0, `rbs=false`
|
|
11
|
+
explicitly selects the default Ruby-only output. Unknown, duplicate, combined,
|
|
12
|
+
invalid and trailing parameters fail without files.
|
|
12
13
|
|
|
13
14
|
## Generate messages and services
|
|
14
15
|
|
|
@@ -133,6 +134,13 @@ heterogeneous maps do not encode a particular key's method association. The
|
|
|
133
134
|
core Server registration map erases those associations only after generated
|
|
134
135
|
`.handlers` has checked each callable.
|
|
135
136
|
|
|
137
|
+
Since 0.3.0, generated `.handlers_for(impl, ?strict: bool)` accepts any Object
|
|
138
|
+
and returns the same handler-map value type. Its `public_method` values are
|
|
139
|
+
not checked against each RPC's handler signature, statically or at runtime; the
|
|
140
|
+
object's methods must accept the handler arguments themselves. Generated client
|
|
141
|
+
signatures add `?deadline: ::ConnectRPC::Deadline?`, and core Client, Server and
|
|
142
|
+
`ErrorDetail#decode` accept an optional `binding: _Binding?`.
|
|
143
|
+
|
|
136
144
|
Method's `request_type` and `response_type` are arbitrary binding tokens typed
|
|
137
145
|
as Object. A manual `Method.new` cannot infer instance types from those tokens.
|
|
138
146
|
Supply an explicit application assertion after verifying your binding contract:
|
|
@@ -202,35 +210,44 @@ target :app do
|
|
|
202
210
|
library "connectrpc-yabeda"
|
|
203
211
|
library "connectrpc-health"
|
|
204
212
|
library "connectrpc-sentry"
|
|
213
|
+
library "connectrpc-hyper"
|
|
205
214
|
check "app"
|
|
206
215
|
configure_code_diagnostics(Steep::Diagnostic::Ruby.strict)
|
|
207
216
|
end
|
|
208
217
|
```
|
|
209
218
|
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
219
|
+
Name `library "connectrpc"` beside every optional library. Falcon signatures
|
|
220
|
+
also need `library "connectrpc-async"`. Package manifests list only the standard
|
|
221
|
+
libraries their signatures use, because `rbs collection` locks every manifest
|
|
222
|
+
dependency as a standard library; a gem name there would make Steep fail to load
|
|
223
|
+
the whole environment. Projects that use `rbs collection` lock each installed
|
|
224
|
+
connectrpc package from `Gemfile.lock` as a gem, in any Gemfile order, and the
|
|
225
|
+
`library` lines above remain valid alongside the collection.
|
|
226
|
+
|
|
227
|
+
Core declares no Google runtime or optional hosting/tracing namespace and has no
|
|
228
|
+
runtime tool dependencies. Its GoogleProtobuf binding class signature is
|
|
229
|
+
available without the explicit message-runtime bridge; the binding itself still
|
|
230
|
+
requires the optional runtime require. `library "connectrpc-health"` covers the
|
|
231
|
+
registry and `SERVICE` only; its generated `grpc.health.v1` messages and client
|
|
232
|
+
are an explicit bridge described [below](#opt-in-framework-compatibility).
|
|
217
233
|
|
|
218
234
|
| Owner | Supported API and extension SPI |
|
|
219
235
|
| --- | --- |
|
|
220
|
-
| Core | Method, non-generic Service, Client/Server options and calls, records, Metadata, CancellationSource/Token/Registration, Deadline/Context, Error/ErrorDetail, explicit NetHTTP and Google binding entry points |
|
|
236
|
+
| Core | Method, non-generic Service, Client/Server options and calls, records, Metadata, CancellationSource/Token/Registration, Deadline/Context, Error/ErrorDetail, `Keepalive` (since 0.3.0), explicit NetHTTP (since 0.3.0 with `ca_file:`, `certificate_chain:`, `private_key:` and `proxy:`) and Google binding entry points |
|
|
221
237
|
| Core shared, unary and observation SPI | `_Cancellation`, `_Binding`, `_Transport`, `_Input`, `_Handler`, `_Invoker`, callable clocks/error handlers, `_Subscriber`, six separate optional observer callback capabilities, host lifecycle Handle |
|
|
222
238
|
| Core metrics (`connectrpc/metrics`) | `Metrics::Definitions`, `Instrument`, `Subscriber` and `ConnectionObserver` (custom sinks call its `publish_state` once their metrics exist); the `Metrics::_Recorder` sink SPI and the structural `Metrics::_ConnectionEvent` shape |
|
|
223
239
|
| Core streaming and gRPC/Web SPI | `_StreamingTransport`, `_StreamExchange`, streaming input/output, `_GRPCTransport`, `_GRPCStreamExchange`, `_GRPCStatusCodec`, native server publication/output interfaces including `_GRPCWebOutput`; see the protocol-specific sections below |
|
|
224
240
|
| Rack | Middleware constructor/call and shared `_App`, `_Body`, `_CallableBody`, `_Stream`, env and response contracts |
|
|
225
241
|
| Testing | In-process Transport constructor/call, reusable as the core transport |
|
|
226
242
|
| Rails | Controller inclusion and `connect`; documented private overrides for service, binding, handlers, limits, instrumentation, interceptors and Web protocol/status/CORS; nullable request/context/method readers |
|
|
227
|
-
| Async | Application/native HTTP capabilities, Host, Transport, HTTP1Transport, ServerSession/accepted handles, TLSConfiguration, complete static/provider record shapes, status/error callbacks, rotation/drain/identity |
|
|
243
|
+
| Async | Application/native HTTP capabilities, Host, Transport, ThreadedTransport, PerCallTransport (since 0.3.0), HTTP1Transport, client `proxy:` options (since 0.3.0), ServerSession/accepted handles, TLSConfiguration, complete static/provider record shapes, status/error callbacks, rotation/drain/identity |
|
|
228
244
|
| Falcon | Endpoint's supported operations, Environment overrides and Server/native application/TLS lifecycle |
|
|
229
245
|
| OTel | Subscriber configuration and narrow tracer-provider/tracer/span/propagator capabilities; SDK and context implementation remain application owned |
|
|
230
246
|
| Prometheus | Metrics configuration, readers and `connection_observer`; narrow structural registry/metric capabilities for prometheus-client |
|
|
231
247
|
| Yabeda | Metrics configuration, readers and `connection_observer`; Yabeda itself remains untyped and application configured |
|
|
232
|
-
| Health | Registry constructor, status operations and handlers; `SERVICE`, plus the generated `grpc.health.v1` messages, client and handler
|
|
248
|
+
| Health | Registry constructor, status operations and handlers; `SERVICE`, plus the generated `grpc.health.v1` messages, client and handler factories (`handlers` and, since 0.3.0, `handlers_for`) through its opt-in bridge |
|
|
233
249
|
| Sentry | `Subscriber.new(capture_exceptions: bool)` and `Subscriber#start`; observers are private and the Sentry SDK remains untyped and application configured |
|
|
250
|
+
| Hyper | Since 0.3.0, `Transport` options, unary `call`, streaming and native gRPC capabilities and exchanges through core's SPI interfaces, and `close(grace:) -> bool`; the extension and exchange are private |
|
|
234
251
|
|
|
235
252
|
`Async::Host#close`, `Async::ServerSession#close` and `Falcon::Server#close`
|
|
236
253
|
return `bool?`. Nil means a nonjoining owned request or coordinator reentry is
|
|
@@ -309,7 +326,9 @@ optional observer discovery. The internal Numeric arithmetic declaration fills
|
|
|
309
326
|
a missing upstream base signature; custom numeric arithmetic remains a runtime
|
|
310
327
|
requirement. Narrow assertions record established phase, slice and format facts.
|
|
311
328
|
|
|
312
|
-
|
|
329
|
+
The internal `ConnectRPC::Proxy` resolver is in the strict source set and
|
|
330
|
+
declared under `typecheck/internal`, not `sig/`; it is not a supported API.
|
|
331
|
+
NetHTTP socket/watchdog/TLS implementation, Google codec internals, generator
|
|
313
332
|
internals and optional backend/framework implementation checking are later stages.
|
|
314
333
|
Their supported public signatures and consumer checks are included here.
|
|
315
334
|
|
|
@@ -319,7 +338,7 @@ capabilities return an Enumerator of name/value tuples. Struct `each_pair`
|
|
|
319
338
|
yields one name/value tuple, which a block may explicitly destructure.
|
|
320
339
|
|
|
321
340
|
Custom OpenTelemetry providers must supply the finite span-context capabilities
|
|
322
|
-
used by the
|
|
341
|
+
used by the W3C propagator: valid state, raw trace/span ids, sampled
|
|
323
342
|
flags and serialized tracestate. These declarations introduce no SDK or upstream
|
|
324
343
|
namespace; static types do not prove valid id lengths or sampling policy.
|
|
325
344
|
|
|
@@ -393,7 +412,11 @@ ambiguous annotation properties. Positives, strict implementation, RBS validatio
|
|
|
393
412
|
and Falcon-only checks remain separate.
|
|
394
413
|
`rbs:package` uses the existing optional bundle setups for offline runtime
|
|
395
414
|
archives, resolved by RubyGems from the running Ruby ABI's caches, builds every owned signature package and checks each library through
|
|
396
|
-
normal installed discovery.
|
|
415
|
+
normal installed discovery. Each optional package also gets an offline
|
|
416
|
+
`rbs collection` consumer whose Gemfile names only that package. The check
|
|
417
|
+
requires `rbs collection install` to lock every connectrpc library as a gem and
|
|
418
|
+
strict `steep check` to pass.
|
|
419
|
+
It checks composed environments in both load orders,
|
|
397
420
|
real Rails subclass inclusion, Rack/Testing calls, native session/TLS operations,
|
|
398
421
|
Falcon endpoint integration, API-only OTel without loading an SDK, and both
|
|
399
422
|
metrics sinks recording through one core metrics layer. The original
|
|
@@ -469,7 +492,7 @@ includes bounded response-head/read/finish waits. Existing unary `_Transport`
|
|
|
469
492
|
consumers need no new method. New core streaming files participate in the strict
|
|
470
493
|
implementation target, with private declarations outside gem archives. Installed
|
|
471
494
|
checks generate real mixed services and run native Async/Falcon streaming over
|
|
472
|
-
localhost with all
|
|
495
|
+
localhost with all twelve normally installed packages, both composition orders,
|
|
473
496
|
codecs and codings. These remain separate from independent Go/official evidence.
|
|
474
497
|
Custom server hosts may pass `capabilities: Array[:server_stream | :client_stream |
|
|
475
498
|
:bidi_stream]?` to `Server#call_stream`. Nil preserves the legacy `http2:` behavior;
|
|
@@ -532,6 +555,20 @@ installed runtime check requires the package in both composition orders and
|
|
|
532
555
|
proves an uninitialized SDK observes nothing and loads neither sentry-rails nor
|
|
533
556
|
sentry-opentelemetry.
|
|
534
557
|
|
|
558
|
+
## Hyper types
|
|
559
|
+
|
|
560
|
+
The hyper package declares `Transport` and `VERSION`. Its constructor types
|
|
561
|
+
every option, including `keepalive: Keepalive?` from core, and its methods
|
|
562
|
+
return core's `TransportResponse`, `_StreamExchange` and `_GRPCStreamExchange`,
|
|
563
|
+
so the package adds no SPI of its own. The native extension, exchange, error
|
|
564
|
+
translation and TLS validation are private constants classified internal in the
|
|
565
|
+
source inventory. API callers construct both connection modes and use every
|
|
566
|
+
entry point against core's client. `rbs:package` compiles the source gem offline
|
|
567
|
+
from the pre-fetched locked crates, discovers its signatures outside the
|
|
568
|
+
checkout, locks it through `rbs collection`, and the installed runtime makes
|
|
569
|
+
real h2c calls from a plain thread to the installed Async Host in both
|
|
570
|
+
composition orders.
|
|
571
|
+
|
|
535
572
|
## HTTP/1 client types
|
|
536
573
|
|
|
537
574
|
The Async package owns the independent `HTTP1Transport` constructor, unary
|