tonic-rails 0.7.0-aarch64-linux-gnu → 0.8.1-aarch64-linux-gnu
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/CHANGELOG.md +34 -1
- data/README.md +19 -0
- data/lib/tonic/rails/3.3/tonic_rails_native.so +0 -0
- data/lib/tonic/rails/3.4/tonic_rails_native.so +0 -0
- data/lib/tonic/rails/4.0/tonic_rails_native.so +0 -0
- data/lib/tonic/rails/client.rb +42 -5
- data/lib/tonic/rails/version.rb +1 -1
- data/lib/tonic-rails.rb +4 -2
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6d1f9d3967458bdef0ccca7a32cc6a667b5697d15e5438e2d5de4ef933648727
|
|
4
|
+
data.tar.gz: ad24f42debbefec05ce1732eed8c5c0f29f99b0274f492245eb66f0a46659bc4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9299b0de21c4c8948224a1f7f0813fe6db76d26f5fbd2368069fe10170d1744f5f7897a546156755d5c63b773b8e18f93c8c2206e876433bc3b63704439c4457
|
|
7
|
+
data.tar.gz: 6e6f86cbfe7e6bfb0b2c4f8da6c25db03beb86ee7ca6f42a3c4234b3a4e9ee605de88314562601a56e23bd6c41809a71f8e637f838b24f34a76a0f0d70f98bd7
|
data/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,37 @@ minor versions may contain breaking changes.
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.8.1] - 2026-10-13
|
|
11
|
+
|
|
12
|
+
### Fixed
|
|
13
|
+
|
|
14
|
+
- Client: a call whose deadline passed could raise `CANCELLED` ("Timeout
|
|
15
|
+
expired") instead of `DEADLINE_EXCEEDED` (#48), mostly on Windows.
|
|
16
|
+
tonic enforces the deadline too, and when its timer fired first the
|
|
17
|
+
call ended with its status. Calls now raise `DEADLINE_EXCEEDED`
|
|
18
|
+
whichever timer fires first.
|
|
19
|
+
|
|
20
|
+
## [0.8.0] - 2026-10-12
|
|
21
|
+
|
|
22
|
+
### Added
|
|
23
|
+
|
|
24
|
+
- Client: `method_retries:` sets retry policies per service
|
|
25
|
+
(`"demo.v1.ItemService"`) or per method
|
|
26
|
+
(`"demo.v1.ItemService/GetItem"`), like gRPC's service config. The most
|
|
27
|
+
specific setting wins: the call's `retries:`, then the method, then the
|
|
28
|
+
service, then the client's `retries:`.
|
|
29
|
+
|
|
30
|
+
### Fixed
|
|
31
|
+
|
|
32
|
+
- Windows: the process could crash with a segfault under load (#41). The
|
|
33
|
+
extension's locks spun and then called `Sleep`, which the mingw linker
|
|
34
|
+
bound to the `Sleep` that Ruby's DLL exports instead of the system's,
|
|
35
|
+
and Ruby's version crashes on threads Ruby doesn't own. Locks now come
|
|
36
|
+
from Rust's standard library, which doesn't spin through `Sleep`, the
|
|
37
|
+
build binds `Sleep` to kernel32, and CI checks that the Windows build
|
|
38
|
+
imports nothing but Ruby's C API from Ruby's DLL. 0.6.0 and 0.7.0 crashed in about 1 in 5 runs of the test suite;
|
|
39
|
+
earlier versions could crash in the same way, but rarely.
|
|
40
|
+
|
|
10
41
|
## [0.7.0] - 2026-10-11
|
|
11
42
|
|
|
12
43
|
### Added
|
|
@@ -186,7 +217,9 @@ First public release.
|
|
|
186
217
|
- Precompiled native gems for Linux (x86_64, aarch64; glibc and musl) and
|
|
187
218
|
macOS (x86_64, arm64), Ruby 3.3 to 4.0.
|
|
188
219
|
|
|
189
|
-
[Unreleased]: https://github.com/CodingAnarchy/tonic-rails/compare/v0.
|
|
220
|
+
[Unreleased]: https://github.com/CodingAnarchy/tonic-rails/compare/v0.8.1...HEAD
|
|
221
|
+
[0.8.1]: https://github.com/CodingAnarchy/tonic-rails/compare/v0.8.0...v0.8.1
|
|
222
|
+
[0.8.0]: https://github.com/CodingAnarchy/tonic-rails/compare/v0.7.0...v0.8.0
|
|
190
223
|
[0.7.0]: https://github.com/CodingAnarchy/tonic-rails/compare/v0.6.0...v0.7.0
|
|
191
224
|
[0.6.0]: https://github.com/CodingAnarchy/tonic-rails/compare/v0.5.0...v0.6.0
|
|
192
225
|
[0.5.0]: https://github.com/CodingAnarchy/tonic-rails/compare/v0.4.0...v0.5.0
|
data/README.md
CHANGED
|
@@ -518,6 +518,24 @@ items.get_item({ id: 1 }, retries: false) # not this call
|
|
|
518
518
|
items.get_item({ id: 1 }, retries: { max_attempts: 5 }) # or differently
|
|
519
519
|
```
|
|
520
520
|
|
|
521
|
+
Different methods often need different policies: a read can retry more
|
|
522
|
+
eagerly than a write. `method_retries:` sets them per service or per
|
|
523
|
+
method, by their protobuf names:
|
|
524
|
+
|
|
525
|
+
```ruby
|
|
526
|
+
ITEMS = Tonic::Rails::Client.new(
|
|
527
|
+
"items.internal:50051",
|
|
528
|
+
retries: true, # every call...
|
|
529
|
+
method_retries: {
|
|
530
|
+
"demo.v1.ItemService/GetItem" => { max_attempts: 5 }, # ...but this method,
|
|
531
|
+
"demo.v1.AdminService" => false, # and this whole service
|
|
532
|
+
},
|
|
533
|
+
)
|
|
534
|
+
```
|
|
535
|
+
|
|
536
|
+
The most specific setting wins: the call's own `retries:`, then its
|
|
537
|
+
method's entry, then its service's, then the client's `retries:`.
|
|
538
|
+
|
|
521
539
|
`retries: true` tries a call up to 3 times when it fails with
|
|
522
540
|
`UNAVAILABLE`. A Hash changes any of these:
|
|
523
541
|
|
|
@@ -612,6 +630,7 @@ the client is created, not on the first call.
|
|
|
612
630
|
| `max_message_size` | 4 MiB | largest message sent or received |
|
|
613
631
|
| `connect_timeout` | 5 | seconds to wait for a connection |
|
|
614
632
|
| `retries` | `false` | retry calls the server never started on; see [Retries](#retries) |
|
|
633
|
+
| `method_retries` | `{}` | retries per service or method, by name |
|
|
615
634
|
| `logger` | `Tonic::Rails.configuration.logger` | where retries are logged |
|
|
616
635
|
|
|
617
636
|
### Fork safety
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
data/lib/tonic/rails/client.rb
CHANGED
|
@@ -16,6 +16,7 @@ module Tonic
|
|
|
16
16
|
#
|
|
17
17
|
# Retries are opt-in: `retries: true` (or a Hash; see RetryPolicy) on
|
|
18
18
|
# the client or a call retries calls the server never started on.
|
|
19
|
+
# `method_retries:` sets them per service or method.
|
|
19
20
|
#
|
|
20
21
|
# Stubs are built from the protobuf descriptors that
|
|
21
22
|
# `tonic_rails:compile_protos` (protoc --ruby_out) generates; no
|
|
@@ -46,6 +47,10 @@ module Tonic
|
|
|
46
47
|
# @return [RetryPolicy, nil] how calls are retried, unless they say otherwise
|
|
47
48
|
attr_reader :retries
|
|
48
49
|
|
|
50
|
+
# @return [Hash{String=>RetryPolicy, nil}] retry policies by service or
|
|
51
|
+
# method name, which take precedence over #retries
|
|
52
|
+
attr_reader :method_retries
|
|
53
|
+
|
|
49
54
|
# @param address [String] "host:port"
|
|
50
55
|
# @param tls [Boolean] false for plaintext, which must be explicit
|
|
51
56
|
# @param tls_ca_path [String, nil] CA certificates (PEM) to trust instead
|
|
@@ -61,11 +66,15 @@ module Tonic
|
|
|
61
66
|
# @param connect_timeout [Numeric] seconds to wait for a connection
|
|
62
67
|
# @param retries [RetryPolicy, Hash, Boolean] retry calls the server
|
|
63
68
|
# never started on (see RetryPolicy); off by default
|
|
69
|
+
# @param method_retries [Hash{String=>RetryPolicy, Hash, Boolean}]
|
|
70
|
+
# retries for some services ("demo.v1.ItemService") or methods
|
|
71
|
+
# ("demo.v1.ItemService/GetItem"), instead of `retries`. A method's
|
|
72
|
+
# entry beats its service's.
|
|
64
73
|
# @param logger [Logger, nil] where retries are logged; defaults to
|
|
65
74
|
# Tonic::Rails.configuration.logger
|
|
66
75
|
def initialize(address, tls: true, tls_ca_path: nil, tls_cert_path: nil, tls_key_path: nil,
|
|
67
76
|
tls_server_name: nil, deadline: nil, metadata: {}, max_message_size: DEFAULT_MAX_MESSAGE_SIZE,
|
|
68
|
-
connect_timeout: 5, retries: false, logger: nil)
|
|
77
|
+
connect_timeout: 5, retries: false, method_retries: {}, logger: nil)
|
|
69
78
|
Tonic::Rails.native_extension!
|
|
70
79
|
validate_address!(address)
|
|
71
80
|
validate_tls!(tls, tls_cert_path, tls_key_path)
|
|
@@ -78,6 +87,7 @@ module Tonic
|
|
|
78
87
|
@address = address
|
|
79
88
|
@deadline = deadline
|
|
80
89
|
@retries = RetryPolicy.from(retries)
|
|
90
|
+
@method_retries = method_retry_policies(method_retries)
|
|
81
91
|
@logger = logger
|
|
82
92
|
@metadata = Metadata.encode(metadata)
|
|
83
93
|
@stubs = {}
|
|
@@ -127,7 +137,7 @@ module Tonic
|
|
|
127
137
|
bytes = input.encode(request_message(path, input, request))
|
|
128
138
|
metadata = call_metadata(metadata)
|
|
129
139
|
deadline_at = deadline_at(deadline)
|
|
130
|
-
policy = retry_policy(retries)
|
|
140
|
+
policy = retry_policy(path, retries)
|
|
131
141
|
|
|
132
142
|
Instrumentation.instrument_request(path, address, metadata) do |payload|
|
|
133
143
|
code, error_message, response, headers, trailers, details = with_retries(path, policy, deadline_at, payload) do
|
|
@@ -150,7 +160,7 @@ module Tonic
|
|
|
150
160
|
# Fixed now, so the stream keeps the deadline of the RPC this
|
|
151
161
|
# thread is handling even if it's read later.
|
|
152
162
|
deadline_at = deadline_at(deadline)
|
|
153
|
-
policy = retry_policy(retries)
|
|
163
|
+
policy = retry_policy(path, retries)
|
|
154
164
|
|
|
155
165
|
ServerStream.new(path) do |stream, block|
|
|
156
166
|
Instrumentation.instrument_request(path, address, metadata) do |payload|
|
|
@@ -238,8 +248,35 @@ module Tonic
|
|
|
238
248
|
(remaining * 1000).ceil
|
|
239
249
|
end
|
|
240
250
|
|
|
241
|
-
|
|
242
|
-
|
|
251
|
+
METHOD_NAME = %r{\A[A-Za-z_][\w.]*(/[A-Za-z_]\w*)?\z}
|
|
252
|
+
private_constant :METHOD_NAME
|
|
253
|
+
|
|
254
|
+
def method_retry_policies(option)
|
|
255
|
+
raise ArgumentError, "method_retries must be a Hash" unless option.is_a?(Hash)
|
|
256
|
+
|
|
257
|
+
option.to_h do |name, retries|
|
|
258
|
+
name = name.to_s.delete_prefix("/")
|
|
259
|
+
unless name.match?(METHOD_NAME)
|
|
260
|
+
raise ArgumentError, "method_retries keys must be \"package.Service\" or \"package.Service/Method\", " \
|
|
261
|
+
"got #{name.inspect}"
|
|
262
|
+
end
|
|
263
|
+
|
|
264
|
+
[name, RetryPolicy.from(retries)]
|
|
265
|
+
end.freeze
|
|
266
|
+
end
|
|
267
|
+
|
|
268
|
+
# The most specific policy for a call: its own, its method's, its
|
|
269
|
+
# service's, then the client's.
|
|
270
|
+
def retry_policy(path, retries)
|
|
271
|
+
return RetryPolicy.from(retries) unless retries.nil?
|
|
272
|
+
return @retries if @method_retries.empty?
|
|
273
|
+
|
|
274
|
+
method = path.delete_prefix("/")
|
|
275
|
+
service = method.split("/", 2).first
|
|
276
|
+
return @method_retries[method] if @method_retries.key?(method)
|
|
277
|
+
return @method_retries[service] if @method_retries.key?(service)
|
|
278
|
+
|
|
279
|
+
@retries
|
|
243
280
|
end
|
|
244
281
|
|
|
245
282
|
# Yield each message of a native stream, then return its result.
|
data/lib/tonic/rails/version.rb
CHANGED
data/lib/tonic-rails.rb
CHANGED
|
@@ -81,11 +81,13 @@ module Tonic
|
|
|
81
81
|
# Precompiled platform gems ship one binary per Ruby minor version.
|
|
82
82
|
ruby_version = RUBY_VERSION[/\d+\.\d+/]
|
|
83
83
|
require "tonic/rails/#{ruby_version}/tonic_rails_native"
|
|
84
|
-
rescue LoadError
|
|
84
|
+
rescue LoadError => versioned
|
|
85
85
|
begin
|
|
86
86
|
require "tonic/rails/tonic_rails_native"
|
|
87
87
|
rescue LoadError => e
|
|
88
|
-
|
|
88
|
+
# A precompiled binary that exists but won't load says more than
|
|
89
|
+
# the missing fallback does.
|
|
90
|
+
@native_load_error = versioned.message.include?("cannot load such file") ? e : versioned
|
|
89
91
|
end
|
|
90
92
|
end
|
|
91
93
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: tonic-rails
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.8.1
|
|
5
5
|
platform: aarch64-linux-gnu
|
|
6
6
|
authors:
|
|
7
7
|
- Matt Tanous
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-10-
|
|
11
|
+
date: 2026-10-13 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activesupport
|