gritz-rails 0.1.0 → 0.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cdb05adc6d6f492115eb0e7d9de033bd3e4509a65f60db732377e254b7f28d5f
4
- data.tar.gz: 927579595d4645896cac9dfe6f8514ccd2e52abf94ad10f1cb77c07158dff833
3
+ metadata.gz: db2dd987cc966eb4ffa310dce392e015ae4d947dac66de527c2707827e63574b
4
+ data.tar.gz: 6cd72f23e08e662fccd17c0c47a0b29e3fc9d6fce461acb472b86b85c72c82a6
5
5
  SHA512:
6
- metadata.gz: dac749d3fc8f50ac2716e3de2557f5fd62b9cb61cd62c5fdfaa0a37dbaa76d690279a4de3cf8cd0baf53128878e08cbe7228e940317f7ab2b1c8a896f08ec6f1
7
- data.tar.gz: 02d442a42de49ba6a6c0a27587e74b380f510c6baebb28b9ab6c79318774cb75cd1f878f6af4c08d856d8923cd0b9081b5b2f7e31ae7ef34e721bbb8d832a21f
6
+ metadata.gz: 827c182bb93e7ea33fc185d0f1f9c6db3f8cfdd963e7c144eb4ca6f7d54710cbb14d7499f88bb7ecfcf82ad61d10f09f2be9193c3dec3a3ee6da3a2cc915323f
7
+ data.tar.gz: a398e00080645b7644e9bd15232a8bd0fed16a465b5c2ef1fa5559e06afe0d48584ef47f690241028de7be63c2f42303fbfc19f13af7f165613d10063088c4b7
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.2.0
4
+
5
+ - Support gritz-core 0.6.0 and select Fiber isolation for Async RPC execution.
6
+ - Enable development Reflection automatically only for the Native adapter.
7
+
3
8
  ## 0.1.0
4
9
 
5
10
  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.5.0. Runtime dependencies are `gritz-core` and `railties`; applications choose their transport separately.
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.5.0"
9
- gem "gritz-rails", "~> 0.1.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
- The initial package is `pkg/gritz-rails.gem`. Stop before its first tag/publication and configure [Trusted Publishing](docs/guides/releasing.md) after the owner releases it.
59
+ Publication uses [Trusted Publishing](docs/guides/releasing.md).
56
60
 
57
61
  ## License
58
62
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Gritz
4
4
  module Rails
5
- VERSION = "0.1.0"
5
+ VERSION = "0.2.0"
6
6
  end
7
7
  end
data/lib/gritz/rails.rb CHANGED
@@ -22,7 +22,8 @@ module Gritz
22
22
  end
23
23
 
24
24
  development = ::Rails.env.development?
25
- config.reflection = true if development
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.0
4
+ version: 0.2.0
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.5.0
18
+ version: 0.6.0
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.5.0
25
+ version: 0.6.0
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: 4.0.16
90
+ rubygems_version: 3.6.9
91
91
  specification_version: 4
92
92
  summary: Rails integration for Gritz RPC servers
93
93
  test_files: []