gritz-rails 0.1.0 → 0.2.1
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 +9 -0
- data/README.md +11 -7
- data/lib/gritz/rails/version.rb +1 -1
- data/lib/gritz/rails.rb +3 -1
- metadata +4 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1acd55a0722e9f5b1f34b177c49c52b1939d5ccdef0436d512b451f446832f5c
|
|
4
|
+
data.tar.gz: 9def966cde20ca7bbc1826b7d5858c5bf62e254c2f8f7ea98b32a98c676b3821
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ef3f0006d82dd20dd4cad689781ef30583c8d32c3dffad50af702b168b469547ad6035a4489d65c75d03b709c4ca701bce11294f06f37858bf6397d8bc2d6bbd
|
|
7
|
+
data.tar.gz: '043739e949ba7dc03b13d026e09e980b5b6966f8d005b92c30866c765fe48f3a187895a23dd454b4bde72b7eab75bb63c654599ac6404cbc908edf116174dd47'
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.2.1
|
|
4
|
+
|
|
5
|
+
- Use gritz-core 0.6.1 to avoid formatting suppressed RPC completion logs.
|
|
6
|
+
|
|
7
|
+
## 0.2.0
|
|
8
|
+
|
|
9
|
+
- Support gritz-core 0.6.0 and select Fiber isolation for Async RPC execution.
|
|
10
|
+
- Enable development Reflection automatically only for the Native adapter.
|
|
11
|
+
|
|
3
12
|
## 0.1.0
|
|
4
13
|
|
|
5
14
|
Initial release.
|
data/README.md
CHANGED
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
# Gritz Rails
|
|
2
2
|
|
|
3
|
-
Rails integration for [Gritz](https://github.com/gritzrpc/gritz): RPC controller loading, generators, complete-RPC execution and single-process development reloading. Requires CRuby 3.3+, Rails 8.0 or 8.1, and Gritz 0.
|
|
3
|
+
Rails integration for [Gritz](https://github.com/gritzrpc/gritz): RPC controller loading, generators, complete-RPC execution and single-process development reloading. Requires CRuby 3.3+, Rails 8.0 or 8.1, and Gritz 0.6.0. Runtime dependencies are `gritz-core` and `railties`; applications choose their transport separately.
|
|
4
4
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
7
7
|
```ruby
|
|
8
|
-
gem "gritz", "~> 0.
|
|
9
|
-
gem "gritz-rails", "~> 0.
|
|
8
|
+
gem "gritz", "~> 0.6.0"
|
|
9
|
+
gem "gritz-rails", "~> 0.2.0"
|
|
10
10
|
```
|
|
11
11
|
|
|
12
|
-
The first `gritz-rails` release is prepared for the project owner. Until it is published, use `gem "gritz-rails", git: "https://github.com/gritzrpc/gritz-rails.git", branch: "main"`.
|
|
13
|
-
|
|
14
12
|
```sh
|
|
15
13
|
bin/rails generate gritz:install
|
|
16
14
|
# Generate protobufs into lib/protos, then generate a bound controller:
|
|
@@ -24,7 +22,7 @@ Implement each generated action using `request.message` or `request.each_message
|
|
|
24
22
|
|
|
25
23
|
## Rails lifecycle
|
|
26
24
|
|
|
27
|
-
Generated `config/gritz.rb` loads the application through `rails_app`, selects four workers in production and zero elsewhere, and registers controllers. Additional settings come after `rails_app`, including explicit `reflection false` or `true`. Rails development enables Reflection by default; other environments keep the core's disabled default.
|
|
25
|
+
Generated `config/gritz.rb` loads the application through `rails_app`, selects four workers in production and zero elsewhere, and registers controllers. Additional settings come after `rails_app`, including explicit `reflection false` or `true`. Rails development enables Reflection for the Native adapter by default; other environments keep the core's disabled default.
|
|
28
26
|
|
|
29
27
|
Every complete application RPC runs inside the Rails executor. Development uses the Rails reloader and resolves controller constants after reload. Active Record connections return to their pools, query caches finish and CurrentAttributes reset on successful and failed calls. Application threads created inside a handler must use Rails' own executor wrapping. See the [Rails execution guide](https://guides.rubyonrails.org/threading_and_code_execution.html).
|
|
30
28
|
|
|
@@ -34,6 +32,12 @@ Application code is eager loaded before fork. In prefork mode, all Active Record
|
|
|
34
32
|
|
|
35
33
|
For an already initialized application, use `Gritz::Rails.install(config, application: Rails.application)` once before starting the server. Match Active Record pool capacity to RPC concurrency with `RAILS_MAX_THREADS` or your database configuration.
|
|
36
34
|
|
|
35
|
+
## Async execution
|
|
36
|
+
|
|
37
|
+
Use `gritz-async` in place of the `gritz` meta gem. In `config/gritz.rb`, require `gritz/async`, set `transport :async` and `listener_strategy :inherited_fd` **before** `rails_app`. Define services with `Gritz::Async::Service` and load only generated `*_pb.rb` messages; generated `*_services_pb.rb` files load the official grpc gem. Start with `bundle exec gritz start -C config/gritz.rb` to use the Async entrypoint.
|
|
38
|
+
|
|
39
|
+
The integration selects `ActiveSupport::IsolatedExecutionState.isolation_level = :fiber`, isolating CurrentAttributes and executor resources across concurrent RPCs. Use a database driver that supports Fiber Scheduler I/O and size its pool for concurrent database work. Async does not currently serve Reflection or the gRPC Health service; use Gritz's admin readiness endpoint.
|
|
40
|
+
|
|
37
41
|
## Examples and migration
|
|
38
42
|
|
|
39
43
|
The [Rails catalog sample](examples/rails_app) serves SQLite-backed unary and streaming RPCs with four production workers. It includes the [memory validation](docs/reports/T5-07-rails-memory.md).
|
|
@@ -52,7 +56,7 @@ bundle exec rake build
|
|
|
52
56
|
|
|
53
57
|
CI tests Ruby 3.3, 3.4 and 4.0 against Rails 8.0 and 8.1. Tests include real RPCs, file-change reloading, all-pool fork cleanup, executable generated configuration and Linux four-worker sample lifecycle. Sibling checkout overrides follow [CONTRIBUTING.md](CONTRIBUTING.md).
|
|
54
58
|
|
|
55
|
-
|
|
59
|
+
Publication uses [Trusted Publishing](docs/guides/releasing.md).
|
|
56
60
|
|
|
57
61
|
## License
|
|
58
62
|
|
data/lib/gritz/rails/version.rb
CHANGED
data/lib/gritz/rails.rb
CHANGED
|
@@ -22,7 +22,8 @@ module Gritz
|
|
|
22
22
|
end
|
|
23
23
|
|
|
24
24
|
development = ::Rails.env.development?
|
|
25
|
-
|
|
25
|
+
ActiveSupport::IsolatedExecutionState.isolation_level = :fiber if config.transport == :async
|
|
26
|
+
config.reflection = true if development && config.transport == :native
|
|
26
27
|
first = config.middleware.entries.first
|
|
27
28
|
if first
|
|
28
29
|
config.middleware.insert_before(first.middleware, Executor, application:, development:)
|
|
@@ -35,6 +36,7 @@ module Gritz
|
|
|
35
36
|
end
|
|
36
37
|
end
|
|
37
38
|
config.add_preloader do
|
|
39
|
+
ActiveSupport::IsolatedExecutionState.isolation_level = :fiber if config.transport == :async
|
|
38
40
|
raise ConfigurationError, "Rails development mode requires workers 0" if development && config.workers.positive?
|
|
39
41
|
|
|
40
42
|
application.eager_load!
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: gritz-rails
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1
|
|
4
|
+
version: 0.2.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Yudai Takada
|
|
@@ -15,14 +15,14 @@ dependencies:
|
|
|
15
15
|
requirements:
|
|
16
16
|
- - '='
|
|
17
17
|
- !ruby/object:Gem::Version
|
|
18
|
-
version: 0.
|
|
18
|
+
version: 0.6.1
|
|
19
19
|
type: :runtime
|
|
20
20
|
prerelease: false
|
|
21
21
|
version_requirements: !ruby/object:Gem::Requirement
|
|
22
22
|
requirements:
|
|
23
23
|
- - '='
|
|
24
24
|
- !ruby/object:Gem::Version
|
|
25
|
-
version: 0.
|
|
25
|
+
version: 0.6.1
|
|
26
26
|
- !ruby/object:Gem::Dependency
|
|
27
27
|
name: railties
|
|
28
28
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -87,7 +87,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
87
87
|
- !ruby/object:Gem::Version
|
|
88
88
|
version: '0'
|
|
89
89
|
requirements: []
|
|
90
|
-
rubygems_version:
|
|
90
|
+
rubygems_version: 3.6.9
|
|
91
91
|
specification_version: 4
|
|
92
92
|
summary: Rails integration for Gritz RPC servers
|
|
93
93
|
test_files: []
|