gruf 2.16.2 → 2.17.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/CHANGELOG.md +6 -0
- data/README.md +1 -1
- data/gruf.gemspec +1 -1
- data/lib/gruf/controllers/autoloader.rb +17 -10
- data/lib/gruf/controllers/base.rb +0 -1
- data/lib/gruf/controllers/service_binder.rb +41 -36
- data/lib/gruf/interceptors/active_record/connection_reset.rb +11 -2
- data/lib/gruf/version.rb +1 -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: feddcb49d9325078dfb0d7367f5e82dfea0d46a82e56784b10484c873ab375a5
|
4
|
+
data.tar.gz: b4614f08c2b6d8f62edfc1f34be0dffc7af4825b680e49aaf5c6160315314d32
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3e67b5fdaf175a0c8b839532d6024415f12c1fdbd91f44fdec5cfa1ac0d7c33e821b740a192f251664f6ff09ef5dc96d903c480a474d2f53d4b876189023550c
|
7
|
+
data.tar.gz: 4061112bf7ea91180fb5ea16d5d135cc3a1a7dab7d94ba479d462f3acca3aa183373f64eb5d8e7d9ad0442a457ed5b25e806e407f27c9d3c6ee0658d153b654c
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,12 @@ Changelog for the gruf gem. This includes internal history before the gem was ma
|
|
2
2
|
|
3
3
|
### Pending release
|
4
4
|
|
5
|
+
### 2.17.0
|
6
|
+
|
7
|
+
* [#179] Add Ruby 3.2 support
|
8
|
+
* [#178] Introduce read-write lock for code reloading; cover controller class resolution with code reloading.
|
9
|
+
* [#180] Support multiple databases connection reset in `Gruf::Interceptors::ActiveRecord::ConnectionReset`.
|
10
|
+
|
5
11
|
### 2.16.2
|
6
12
|
|
7
13
|
* [#175] Fix code reload thread-safety. Calls to `Zeitwerk::Loader#setup` are now made in a thread-safe manner.
|
data/README.md
CHANGED
@@ -17,7 +17,7 @@ up fast and efficiently at scale. Some of its features include:
|
|
17
17
|
still preserving gRPC BadStatus codes
|
18
18
|
* Server and client execution timings in responses
|
19
19
|
|
20
|
-
gruf currently has active support for gRPC 1.10.x+. gruf is compatible and tested with Ruby 2.6-3.
|
20
|
+
gruf currently has active support for gRPC 1.10.x+. gruf is compatible and tested with Ruby 2.6-3.2.
|
21
21
|
gruf is also not [Rails](https://github.com/rails/rails)-specific, and can be used in any Ruby framework
|
22
22
|
(such as [Grape](https://github.com/ruby-grape/grape) or [dry-rb](https://dry-rb.org/), for instance).
|
23
23
|
|
data/gruf.gemspec
CHANGED
@@ -32,7 +32,7 @@ Gem::Specification.new do |spec|
|
|
32
32
|
spec.executables << 'gruf'
|
33
33
|
spec.require_paths = ['lib']
|
34
34
|
|
35
|
-
spec.required_ruby_version = '>= 2.7', '< 3.
|
35
|
+
spec.required_ruby_version = '>= 2.7', '< 3.3'
|
36
36
|
|
37
37
|
spec.metadata = {
|
38
38
|
'bug_tracker_uri' => 'https://github.com/bigcommerce/gruf/issues',
|
@@ -15,6 +15,8 @@
|
|
15
15
|
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
16
16
|
# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
17
17
|
#
|
18
|
+
require 'concurrent/atomic/read_write_lock'
|
19
|
+
|
18
20
|
module Gruf
|
19
21
|
module Controllers
|
20
22
|
##
|
@@ -47,10 +49,19 @@ module Gruf
|
|
47
49
|
# Reload all files managed by the autoloader, if reloading is enabled
|
48
50
|
#
|
49
51
|
def reload
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
52
|
+
return unless @reloading_enabled
|
53
|
+
|
54
|
+
reload_lock.with_write_lock do
|
55
|
+
@loader.reload
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def with_fresh_controller(controller_name)
|
60
|
+
return yield(controller_name.constantize) unless @reloading_enabled
|
61
|
+
|
62
|
+
::Gruf::Autoloaders.reload
|
63
|
+
reload_lock.with_read_lock do
|
64
|
+
yield(controller_name.constantize)
|
54
65
|
end
|
55
66
|
end
|
56
67
|
|
@@ -77,12 +88,8 @@ module Gruf
|
|
77
88
|
##
|
78
89
|
# Handle thread-safe access to the loader
|
79
90
|
#
|
80
|
-
def
|
81
|
-
@
|
82
|
-
require 'monitor'
|
83
|
-
Monitor.new
|
84
|
-
end
|
85
|
-
@reload_mutex.synchronize(&block)
|
91
|
+
def reload_lock
|
92
|
+
@reload_lock ||= Concurrent::ReadWriteLock.new
|
86
93
|
end
|
87
94
|
end
|
88
95
|
end
|
@@ -90,7 +90,6 @@ module Gruf
|
|
90
90
|
# @param [block] &block The passed block for executing the method
|
91
91
|
#
|
92
92
|
def call(method_key, &block)
|
93
|
-
::Gruf.autoloaders.reload if ::Gruf.development?
|
94
93
|
Interceptors::Context.new(@interceptors).intercept! do
|
95
94
|
process_action(method_key, &block)
|
96
95
|
end
|
@@ -46,54 +46,59 @@ module Gruf
|
|
46
46
|
#
|
47
47
|
def bind_method(service_ref, controller, method_name, desc)
|
48
48
|
method_key = method_name.to_s.underscore.to_sym
|
49
|
+
controller_name = controller.name
|
49
50
|
service_ref.class_eval do
|
50
51
|
if desc.request_response?
|
51
52
|
define_method(method_key) do |message, active_call|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
53
|
+
Gruf::Autoloaders.controllers.with_fresh_controller(controller_name) do |fresh_controller|
|
54
|
+
c = fresh_controller.new(
|
55
|
+
method_key: method_key,
|
56
|
+
service: service_ref,
|
57
|
+
message: message,
|
58
|
+
active_call: active_call,
|
59
|
+
rpc_desc: desc
|
60
|
+
)
|
61
|
+
c.call(method_key)
|
62
|
+
end
|
61
63
|
end
|
62
64
|
elsif desc.client_streamer?
|
63
65
|
define_method(method_key) do |active_call|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
66
|
+
Gruf::Autoloaders.controllers.with_fresh_controller(controller_name) do |fresh_controller|
|
67
|
+
c = fresh_controller.new(
|
68
|
+
method_key: method_key,
|
69
|
+
service: service_ref,
|
70
|
+
message: proc { |&block| active_call.each_remote_read(&block) },
|
71
|
+
active_call: active_call,
|
72
|
+
rpc_desc: desc
|
73
|
+
)
|
74
|
+
c.call(method_key)
|
75
|
+
end
|
73
76
|
end
|
74
77
|
elsif desc.server_streamer?
|
75
78
|
define_method(method_key) do |message, active_call, &block|
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
79
|
+
Gruf::Autoloaders.controllers.with_fresh_controller(controller_name) do |fresh_controller|
|
80
|
+
c = fresh_controller.new(
|
81
|
+
method_key: method_key,
|
82
|
+
service: service_ref,
|
83
|
+
message: message,
|
84
|
+
active_call: active_call,
|
85
|
+
rpc_desc: desc
|
86
|
+
)
|
87
|
+
c.call(method_key, &block)
|
88
|
+
end
|
85
89
|
end
|
86
90
|
else # bidi
|
87
91
|
define_method(method_key) do |messages, active_call, &block|
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
92
|
+
Gruf::Autoloaders.controllers.with_fresh_controller(controller_name) do |fresh_controller|
|
93
|
+
c = fresh_controller.new(
|
94
|
+
method_key: method_key,
|
95
|
+
service: service_ref,
|
96
|
+
message: messages,
|
97
|
+
active_call: active_call,
|
98
|
+
rpc_desc: desc
|
99
|
+
)
|
100
|
+
c.call(method_key, &block)
|
101
|
+
end
|
97
102
|
end
|
98
103
|
end
|
99
104
|
end
|
@@ -27,11 +27,13 @@ module Gruf
|
|
27
27
|
# connection pool, we need to ensure that this is done to properly
|
28
28
|
#
|
29
29
|
def call
|
30
|
-
|
30
|
+
if enabled?
|
31
|
+
target_classes.each { |klass| klass.establish_connection unless klass.connection.active? }
|
32
|
+
end
|
31
33
|
|
32
34
|
yield
|
33
35
|
ensure
|
34
|
-
|
36
|
+
target_classes.each(&:clear_active_connections!) if enabled?
|
35
37
|
end
|
36
38
|
|
37
39
|
private
|
@@ -42,6 +44,13 @@ module Gruf
|
|
42
44
|
def enabled?
|
43
45
|
defined?(::ActiveRecord::Base)
|
44
46
|
end
|
47
|
+
|
48
|
+
##
|
49
|
+
# @return [Array<Class>] The list of ActiveRecord classes to reset
|
50
|
+
#
|
51
|
+
def target_classes
|
52
|
+
options[:target_classes] || [::ActiveRecord::Base]
|
53
|
+
end
|
45
54
|
end
|
46
55
|
end
|
47
56
|
end
|
data/lib/gruf/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gruf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.17.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shaun McCormick
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-01-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler-audit
|
@@ -399,14 +399,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
399
399
|
version: '2.7'
|
400
400
|
- - "<"
|
401
401
|
- !ruby/object:Gem::Version
|
402
|
-
version: '3.
|
402
|
+
version: '3.3'
|
403
403
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
404
404
|
requirements:
|
405
405
|
- - ">="
|
406
406
|
- !ruby/object:Gem::Version
|
407
407
|
version: '0'
|
408
408
|
requirements: []
|
409
|
-
rubygems_version: 3.
|
409
|
+
rubygems_version: 3.4.1
|
410
410
|
signing_key:
|
411
411
|
specification_version: 4
|
412
412
|
summary: gRPC Ruby Framework
|