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/lib/connectrpc/version.rb
CHANGED
data/lib/connectrpc.rb
CHANGED
|
@@ -7,6 +7,7 @@ require_relative "connectrpc/metadata"
|
|
|
7
7
|
require_relative "connectrpc/error"
|
|
8
8
|
require_relative "connectrpc/cancellation"
|
|
9
9
|
require_relative "connectrpc/deadline"
|
|
10
|
+
require_relative "connectrpc/keepalive"
|
|
10
11
|
require_relative "connectrpc/protocol"
|
|
11
12
|
require_relative "connectrpc/compression"
|
|
12
13
|
require_relative "connectrpc/instrumentation"
|
data/sig/connectrpc.rbs
CHANGED
|
@@ -25,9 +25,10 @@ module ConnectRPC
|
|
|
25
25
|
type streaming_cardinality = :server_stream | :client_stream | :bidi_stream
|
|
26
26
|
|
|
27
27
|
class Service
|
|
28
|
-
|
|
28
|
+
# Since 0.3.0, rpcs replaces the former methods keyword and reader.
|
|
29
|
+
def initialize: (name: String, rpcs: Array[declaration]) -> void
|
|
29
30
|
attr_reader name: String
|
|
30
|
-
attr_reader
|
|
31
|
+
attr_reader rpcs: Array[declaration]
|
|
31
32
|
end
|
|
32
33
|
|
|
33
34
|
# Custom token-based codecs erase message identity at this boundary.
|
|
@@ -88,19 +89,25 @@ module ConnectRPC
|
|
|
88
89
|
def initialize: (subscribers: Array[_Subscriber], ?on_error: (^(StandardError) -> void | _InstrumentationErrorHandler)?) -> void
|
|
89
90
|
|
|
90
91
|
class Call
|
|
91
|
-
def
|
|
92
|
-
| (:client | :server, :connect | :grpc | :grpc_web, declaration?, String?, Integer?, Hash[String, String | Array[String]]) ->
|
|
92
|
+
def self.new: (role: :client | :server, protocol: :connect | :grpc | :grpc_web, method: declaration?, server_address: String?, server_port: Integer?, carrier: Hash[String, String | Array[String]], ?url_scheme: String?, ?url_path: String?, ?transport_class: Class?) -> instance
|
|
93
|
+
| (:client | :server, :connect | :grpc | :grpc_web, declaration?, String?, Integer?, Hash[String, String | Array[String]], ?String?, ?String?, ?Class?) -> instance
|
|
94
|
+
def initialize: (role: :client | :server, protocol: :connect | :grpc | :grpc_web, method: declaration?, server_address: String?, server_port: Integer?, carrier: Hash[String, String | Array[String]], ?url_scheme: String?, ?url_path: String?, ?transport_class: Class?) -> void
|
|
93
95
|
attr_reader role: :client | :server
|
|
94
96
|
attr_reader protocol: :connect | :grpc | :grpc_web
|
|
95
97
|
attr_reader method: declaration?
|
|
96
98
|
attr_reader server_address: String?
|
|
97
99
|
attr_reader server_port: Integer?
|
|
98
100
|
attr_reader carrier: Hash[String, String | Array[String]]
|
|
101
|
+
# Since 0.3.0. Client request facts; nil on servers.
|
|
102
|
+
attr_reader url_scheme: String?
|
|
103
|
+
attr_reader url_path: String?
|
|
104
|
+
attr_reader transport_class: Class?
|
|
99
105
|
end
|
|
100
106
|
|
|
101
107
|
class Outcome
|
|
102
|
-
def
|
|
103
|
-
| (String?, Integer?, Exception?, Exception?, Float, Integer?, Integer?, headers, headers) ->
|
|
108
|
+
def self.new: (code: String?, http_status: Integer?, error: Exception?, normalized_error: Exception?, duration: Float, request_bytes: Integer?, response_bytes: Integer?, request_metadata: headers, response_metadata: headers, ?response_trailers: headers) -> instance
|
|
109
|
+
| (String?, Integer?, Exception?, Exception?, Float, Integer?, Integer?, headers, headers, ?headers) -> instance
|
|
110
|
+
def initialize: (code: String?, http_status: Integer?, error: Exception?, normalized_error: Exception?, duration: Float, request_bytes: Integer?, response_bytes: Integer?, request_metadata: headers, response_metadata: headers, ?response_trailers: headers) -> void
|
|
104
111
|
attr_reader code: String?
|
|
105
112
|
attr_reader http_status: Integer?
|
|
106
113
|
attr_reader error: Exception?
|
|
@@ -109,7 +116,10 @@ module ConnectRPC
|
|
|
109
116
|
attr_reader request_bytes: Integer?
|
|
110
117
|
attr_reader response_bytes: Integer?
|
|
111
118
|
attr_reader request_metadata: headers
|
|
119
|
+
# Response headers. Connect unary trailer-prefixed headers are trailers.
|
|
112
120
|
attr_reader response_metadata: headers
|
|
121
|
+
# Since 0.3.0. Trailing metadata, without any trailer- wire prefix.
|
|
122
|
+
attr_reader response_trailers: headers
|
|
113
123
|
end
|
|
114
124
|
|
|
115
125
|
class Completion
|
|
@@ -145,6 +155,11 @@ module ConnectRPC
|
|
|
145
155
|
def call: (StandardError) -> void
|
|
146
156
|
end
|
|
147
157
|
|
|
158
|
+
# Receives each unexpected exception a Server turns into a generic internal error.
|
|
159
|
+
interface _ServerErrorHandler
|
|
160
|
+
def call: (StandardError) -> void
|
|
161
|
+
end
|
|
162
|
+
|
|
148
163
|
interface _ObserverAttach
|
|
149
164
|
def attach: () -> Object?
|
|
150
165
|
end
|
|
@@ -176,24 +191,30 @@ module ConnectRPC
|
|
|
176
191
|
|
|
177
192
|
module Transports
|
|
178
193
|
class NetHTTP
|
|
179
|
-
|
|
194
|
+
# Since 0.3.0, custom trust, client certificates and http:// proxies.
|
|
195
|
+
# proxy: defaults to a snapshot of HTTP_PROXY, HTTPS_PROXY and NO_PROXY.
|
|
196
|
+
def initialize: (?ca_file: String?, ?certificate_chain: Array[String]?, ?private_key: String?, ?proxy: :environment | String | URI::Generic | nil) -> void
|
|
197
|
+
def inspect: () -> String
|
|
180
198
|
def call: (TransportRequest) -> TransportResponse
|
|
181
199
|
end
|
|
182
200
|
end
|
|
183
201
|
|
|
184
202
|
class Client
|
|
185
|
-
|
|
186
|
-
def
|
|
203
|
+
# Since 0.3.0, an omitted or nil binding uses the loaded Google protobuf binding.
|
|
204
|
+
def initialize: (base_url: String, ?binding: _Binding?, ?transport: (_Transport | _StreamingTransport | _GRPCTransport)?, ?codec: codec, ?request_limit: Integer, ?response_limit: Integer, ?request_wire_limit: Integer, ?response_wire_limit: Integer, ?accept_encoding: Array[:identity | :gzip]?, ?use_get: bool, ?get_url_limit: Integer, ?protocol: :connect | :grpc, ?mode: :unary, ?encoding: :identity | :gzip, ?instrumentation: Instrumentation?, ?terminal_wire_limit: Integer, ?terminal_limit: Integer, ?status_codec: _GRPCStatusCodec?, ?grpc_status_wire_limit: Integer, ?grpc_status_limit: Integer, ?interceptors: Array[client_interceptor]) -> void
|
|
205
|
+
# Since 0.3.0, deadline: bounds the call with the earlier of it and timeout.
|
|
206
|
+
def call: [Req, Resp] (Method[Req, Resp], Req request, ?metadata: metadata_input, ?timeout: Numeric?, ?deadline: Deadline?, ?cancellation: CancellationToken?) -> Response[Resp]
|
|
187
207
|
end
|
|
188
208
|
|
|
189
209
|
class Server
|
|
190
210
|
# Generated .handlers checks each concrete callable before this heterogeneous
|
|
191
211
|
# registration map erases its individual request/response associations.
|
|
192
|
-
|
|
212
|
+
# Since 0.3.0, an omitted or nil binding uses the loaded Google protobuf binding.
|
|
213
|
+
def initialize: (services: Array[Service], ?binding: _Binding?, ?handlers: Hash[String, registered_handler], ?invoker: (^(Method[untyped, untyped], untyped, Context) -> untyped | _Invoker)?, ?request_limit: Integer, ?response_limit: Integer, ?request_wire_limit: Integer, ?response_wire_limit: Integer, ?protocol: server_protocol_selection, ?mode: :unary, ?encoding: :identity | :gzip, ?instrumentation: Instrumentation?, ?get_query_limit: Integer?, ?terminal_wire_limit: Integer, ?terminal_limit: Integer, ?status_codec: _GRPCStatusCodec?, ?grpc_status_wire_limit: Integer, ?grpc_status_limit: Integer, ?cors: GRPCWebCORS?, ?interceptors: Array[server_interceptor], ?on_error: (^(StandardError) -> void | _ServerErrorHandler)?) -> void
|
|
193
214
|
attr_reader services: Array[Service]
|
|
194
215
|
def handles?: (String path) -> bool
|
|
195
216
|
def start_call: (path: String, headers: headers, ?http_method: String) -> Instrumentation::Handle?
|
|
196
|
-
def call: (path: String, http_method: String, headers: headers, input: _Input?, ?query: String, ?lifecycle: Instrumentation::Handle?, ?cancellation: _Cancellation?) -> TransportResponse
|
|
217
|
+
def call: (path: String, http_method: String, headers: headers, input: _Input?, ?query: String, ?lifecycle: Instrumentation::Handle?, ?cancellation: _Cancellation?, ?on_error: (^(StandardError) -> void | _ServerErrorHandler)?) -> TransportResponse
|
|
197
218
|
end
|
|
198
219
|
|
|
199
220
|
# Interceptor misuse raised by core: a continuation called twice, late or off
|
|
@@ -449,6 +470,8 @@ module ConnectRPC
|
|
|
449
470
|
def headers=: (headers?) -> headers?
|
|
450
471
|
def body: () -> String?
|
|
451
472
|
def body=: (String?) -> String?
|
|
473
|
+
def cause: () -> StandardError?
|
|
474
|
+
def cause=: (StandardError?) -> StandardError?
|
|
452
475
|
def []: (:status | "status" | 0 | -3) -> Integer?
|
|
453
476
|
| (:headers | "headers" | 1 | -2) -> headers?
|
|
454
477
|
| (:body | "body" | 2 | -1) -> String?
|
|
@@ -471,6 +494,8 @@ module ConnectRPC
|
|
|
471
494
|
|
|
472
495
|
end
|
|
473
496
|
|
|
497
|
+
# cause is an in-process exception behind an error response. It is never sent
|
|
498
|
+
# and is not a record member. The client raises its decoded error with it.
|
|
474
499
|
class TransportResponse
|
|
475
500
|
def self.new: (status: Integer, headers: headers, body: String) -> TransportResponse
|
|
476
501
|
| ({ status: Integer, headers: headers, body: String }) -> TransportResponse
|
|
@@ -483,6 +508,7 @@ module ConnectRPC
|
|
|
483
508
|
attr_accessor status: Integer
|
|
484
509
|
attr_accessor headers: headers
|
|
485
510
|
attr_accessor body: String
|
|
511
|
+
attr_accessor cause: StandardError?
|
|
486
512
|
def []: (:status | "status" | 0 | -3) -> Integer
|
|
487
513
|
| (:headers | "headers" | 1 | -2) -> headers
|
|
488
514
|
| (:body | "body" | 2 | -1) -> String
|
|
@@ -523,6 +549,7 @@ module ConnectRPC
|
|
|
523
549
|
|
|
524
550
|
class Deadline
|
|
525
551
|
MAX_NATIVE_WAIT: Float
|
|
552
|
+
# Since 0.3.0, zero and negative finite timeouts are already expired.
|
|
526
553
|
def initialize: (Numeric timeout, ?clock: ^() -> Numeric | _Clock) -> void
|
|
527
554
|
def remaining: () -> Numeric
|
|
528
555
|
def expired?: () -> bool
|
|
@@ -531,6 +558,18 @@ module ConnectRPC
|
|
|
531
558
|
def timeout_ms: () -> String
|
|
532
559
|
end
|
|
533
560
|
|
|
561
|
+
# Since 0.3.0. Client HTTP/2 keepalive shared by optional transports;
|
|
562
|
+
# ConnectRPC::Async::Keepalive is the same class.
|
|
563
|
+
class Keepalive
|
|
564
|
+
def initialize: (time: Numeric, ?timeout: Numeric, ?permit_without_calls: bool) -> void
|
|
565
|
+
attr_reader time: Numeric
|
|
566
|
+
attr_reader timeout: Numeric
|
|
567
|
+
attr_reader permit_without_calls: bool
|
|
568
|
+
def ==: (untyped other) -> bool
|
|
569
|
+
def eql?: (untyped other) -> bool
|
|
570
|
+
def hash: () -> Integer
|
|
571
|
+
end
|
|
572
|
+
|
|
534
573
|
class Context
|
|
535
574
|
def initialize: (?request_metadata: metadata_input, ?deadline: Deadline?, ?lifecycle: Instrumentation::Handle?, ?cancellation: _Cancellation?) -> void
|
|
536
575
|
attr_reader request_metadata: Metadata
|
|
@@ -551,7 +590,8 @@ module ConnectRPC
|
|
|
551
590
|
def initialize: (type: String, value: String) -> void
|
|
552
591
|
attr_reader type: String
|
|
553
592
|
attr_reader value: String
|
|
554
|
-
|
|
593
|
+
# Since 0.3.0, an omitted or nil binding uses the loaded Google protobuf binding.
|
|
594
|
+
def decode: (type: Object, ?binding: _Binding?) -> untyped
|
|
555
595
|
def to_h: () -> Hash[String, String]
|
|
556
596
|
end
|
|
557
597
|
|
|
@@ -661,9 +701,10 @@ module ConnectRPC
|
|
|
661
701
|
| _BidiStreamHandler[untyped, untyped] | ^(ServerDuplex[untyped, untyped], StreamingContext) -> void
|
|
662
702
|
|
|
663
703
|
class Client
|
|
664
|
-
|
|
665
|
-
def
|
|
666
|
-
def
|
|
704
|
+
# Since 0.3.0, deadline: bounds each stream with the earlier of it and timeout.
|
|
705
|
+
def server_stream: [Req, Resp] (ServerStreamMethod[Req, Resp], Req, ?metadata: metadata_input, ?timeout: Numeric?, ?deadline: Deadline?, ?cancellation: CancellationToken?) { (ResponseReader[Resp]) -> void } -> nil
|
|
706
|
+
def client_stream: [Req, Resp] (ClientStreamMethod[Req, Resp], ?metadata: metadata_input, ?timeout: Numeric?, ?deadline: Deadline?, ?cancellation: CancellationToken?) { (RequestWriter[Req]) -> void } -> Response[Resp]
|
|
707
|
+
def bidi_stream: [Req, Resp] (BidiStreamMethod[Req, Resp], ?metadata: metadata_input, ?timeout: Numeric?, ?deadline: Deadline?, ?cancellation: CancellationToken?) { (ClientDuplex[Req, Resp]) -> void } -> nil
|
|
667
708
|
end
|
|
668
709
|
class Server
|
|
669
710
|
def call_stream: (path: String, http_method: String, headers: headers, input: _StreamingInput, output: _StreamingOutput, publish: _PublishStreamHead | ^(StreamHead) -> void, ?lifecycle: Instrumentation::Handle?, ?cancellation: _Cancellation?, ?http2: bool, ?capabilities: Array[streaming_cardinality]?) -> TransportResponse?
|
|
@@ -842,11 +883,12 @@ end
|
|
|
842
883
|
|
|
843
884
|
module ConnectRPC
|
|
844
885
|
class GRPCWebCORS
|
|
845
|
-
def initialize: (origins: Array[String], ?credentials: bool, ?request_headers: Array[String], ?expose_headers: Array[String]) -> void
|
|
886
|
+
def initialize: (origins: Array[String], ?credentials: bool, ?request_headers: Array[String], ?expose_headers: Array[String], ?max_age: Integer) -> void
|
|
846
887
|
attr_reader origins: Array[String]
|
|
847
888
|
attr_reader credentials: bool
|
|
848
889
|
attr_reader request_headers: Array[String]
|
|
849
890
|
attr_reader expose_headers: Array[String]
|
|
891
|
+
attr_reader max_age: Integer
|
|
850
892
|
end
|
|
851
893
|
interface _GRPCWebOutput
|
|
852
894
|
def write: (String, ?timeout: Numeric?) -> nil
|
|
@@ -854,7 +896,8 @@ module ConnectRPC
|
|
|
854
896
|
def abort: () -> nil
|
|
855
897
|
end
|
|
856
898
|
class Server
|
|
857
|
-
|
|
899
|
+
# on_error is the host's per-call reporter, run after the Server's own.
|
|
900
|
+
def call_grpc_web: (path: String, http_method: String, headers: headers, input: _StreamingInput, output: _GRPCWebOutput, publish: _PublishStreamHead | ^(StreamHead) -> void, ?capabilities: Array[grpc_web_cardinality], ?lifecycle: Instrumentation::Handle?, ?cancellation: _Cancellation?, ?on_error: (^(StandardError) -> void | _ServerErrorHandler)?) -> TransportResponse?
|
|
858
901
|
def cors_response: (path: String, http_method: String, headers: headers, ?response: TransportResponse?) -> TransportResponse?
|
|
859
902
|
end
|
|
860
903
|
end
|
|
@@ -881,6 +924,9 @@ module ConnectRPC
|
|
|
881
924
|
def previous_state: () -> Symbol?
|
|
882
925
|
def outcome: () -> Symbol?
|
|
883
926
|
def duration: () -> Numeric?
|
|
927
|
+
def active: () -> Integer
|
|
928
|
+
def draining: () -> Integer
|
|
929
|
+
def pending_calls: () -> Integer
|
|
884
930
|
end
|
|
885
931
|
|
|
886
932
|
class Instrument
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: connectrpc
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- jimeh
|
|
8
8
|
bindir: exe
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date: 2026-11-
|
|
10
|
+
date: 2026-11-24 00:00:00.000000000 Z
|
|
11
11
|
dependencies: []
|
|
12
12
|
description: 'Ruby implementation of the Connect protocol: typed clients, a Net::HTTP
|
|
13
13
|
transport, host-neutral servers and a protoc plugin that generates service modules
|
|
@@ -54,6 +54,7 @@ files:
|
|
|
54
54
|
- lib/connectrpc/grpc_web_server.rb
|
|
55
55
|
- lib/connectrpc/instrumentation.rb
|
|
56
56
|
- lib/connectrpc/interceptors.rb
|
|
57
|
+
- lib/connectrpc/keepalive.rb
|
|
57
58
|
- lib/connectrpc/message_io.rb
|
|
58
59
|
- lib/connectrpc/metadata.rb
|
|
59
60
|
- lib/connectrpc/method.rb
|
|
@@ -62,6 +63,7 @@ files:
|
|
|
62
63
|
- lib/connectrpc/metrics/definitions.rb
|
|
63
64
|
- lib/connectrpc/metrics/subscriber.rb
|
|
64
65
|
- lib/connectrpc/protocol.rb
|
|
66
|
+
- lib/connectrpc/proxy.rb
|
|
65
67
|
- lib/connectrpc/server.rb
|
|
66
68
|
- lib/connectrpc/streaming/client.rb
|
|
67
69
|
- lib/connectrpc/streaming/client_execution.rb
|
|
@@ -95,6 +97,8 @@ metadata:
|
|
|
95
97
|
allowed_push_host: https://rubygems.org
|
|
96
98
|
rubygems_mfa_required: 'true'
|
|
97
99
|
source_code_uri: https://github.com/jimeh/connectrpc-ruby
|
|
100
|
+
changelog_uri: https://github.com/jimeh/connectrpc-ruby/blob/main/CHANGELOG.md
|
|
101
|
+
bug_tracker_uri: https://github.com/jimeh/connectrpc-ruby/issues
|
|
98
102
|
rdoc_options: []
|
|
99
103
|
require_paths:
|
|
100
104
|
- lib
|