gruf 2.1.1 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +4 -0
- data/README.md +3 -3
- data/lib/gruf/server.rb +47 -8
- data/lib/gruf/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 5e2128aead5d95df32a7c576007e1f725321d994a30dcc799369ef04a2866bae
|
4
|
+
data.tar.gz: 9cce18e801ce59b8d156f9f02fdb0266281bea439cd6da85e94d7a0c6ca45df1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 47e56d29f46dbdd51634bff6c2cba63b482e99ab94a57022e231bd4d081f8b26efcefa524712dd3a9faf0edc9aeddc07895b01a1acf51b9f24f512657faba61d
|
7
|
+
data.tar.gz: e3b9a9e56016f3ede0520bfc4fafd1f9409c32ea16a977ca27f6c296d0215d26ec9f1d8de705659710da855f22de6083c0681cdc5b974ef80b2602144892f488
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,10 @@ Changelog for the gruf gem. This includes internal history before the gem was ma
|
|
2
2
|
|
3
3
|
### Pending release
|
4
4
|
|
5
|
+
### 2.2.0
|
6
|
+
|
7
|
+
- Run server in a monitored thread to allow for trapped exits on sigints
|
8
|
+
|
5
9
|
### 2.1.1
|
6
10
|
|
7
11
|
- Add ability to pass in client stub options into Gruf::Client
|
data/README.md
CHANGED
@@ -17,9 +17,9 @@ 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.4.x-1.
|
21
|
-
|
22
|
-
|
20
|
+
gruf currently has active support for gRPC 1.4.x-1.9.x. gruf is compatible and tested with Ruby 2.2-2.5.
|
21
|
+
gruf is also not [Rails](https://github.com/rails/rails)-specific, and can be used in any Ruby framework
|
22
|
+
(such as [Grape](https://github.com/ruby-grape/grape), for instance).
|
23
23
|
|
24
24
|
## Installation
|
25
25
|
|
data/lib/gruf/server.rb
CHANGED
@@ -39,7 +39,10 @@ module Gruf
|
|
39
39
|
@interceptors = Gruf::Interceptors::Registry.new unless @interceptors.is_a?(Gruf::Interceptors::Registry)
|
40
40
|
@services = []
|
41
41
|
@started = false
|
42
|
-
|
42
|
+
@stop_server = false
|
43
|
+
@stop_server_cv = ConditionVariable.new
|
44
|
+
@stop_server_mu = Monitor.new
|
45
|
+
setup
|
43
46
|
end
|
44
47
|
|
45
48
|
##
|
@@ -58,18 +61,25 @@ module Gruf
|
|
58
61
|
# Start the gRPC server
|
59
62
|
#
|
60
63
|
# :nocov:
|
61
|
-
# rubocop:disable Lint/ShadowedException
|
62
64
|
def start!
|
65
|
+
stop_server_thread = Thread.new do
|
66
|
+
loop do
|
67
|
+
break if @stop_server
|
68
|
+
@stop_server_mu.synchronize { @stop_server_cv.wait(@stop_server_mu, 10) }
|
69
|
+
end
|
70
|
+
logger.info { 'Shutting down...' }
|
71
|
+
server.stop
|
72
|
+
end
|
73
|
+
|
63
74
|
logger.info { 'Booting gRPC Server...' }
|
64
75
|
@started = true
|
65
|
-
server.
|
66
|
-
|
67
|
-
logger.info { 'Shutting down gRPC server...' }
|
76
|
+
server.run
|
77
|
+
stop_server_thread.join
|
68
78
|
@started = false
|
69
|
-
|
79
|
+
|
80
|
+
logger.info { 'Goodbye!' }
|
70
81
|
end
|
71
82
|
# :nocov:
|
72
|
-
# rubocop:enable Lint/ShadowedException
|
73
83
|
|
74
84
|
##
|
75
85
|
# @param [Class] klass
|
@@ -139,11 +149,40 @@ module Gruf
|
|
139
149
|
|
140
150
|
private
|
141
151
|
|
152
|
+
##
|
153
|
+
# Setup server
|
154
|
+
#
|
155
|
+
# :nocov:
|
156
|
+
def setup
|
157
|
+
setup_signal_handlers
|
158
|
+
load_controllers
|
159
|
+
end
|
160
|
+
# :nocov:
|
161
|
+
|
162
|
+
##
|
163
|
+
# Register signal handlers
|
164
|
+
#
|
165
|
+
# :nocov:
|
166
|
+
def setup_signal_handlers
|
167
|
+
Thread.abort_on_exception = true
|
168
|
+
|
169
|
+
Signal.trap('INT') do
|
170
|
+
@stop_server = true
|
171
|
+
@stop_server_cv.broadcast
|
172
|
+
end
|
173
|
+
|
174
|
+
Signal.trap('TERM') do
|
175
|
+
@stop_server = true
|
176
|
+
@stop_server_cv.broadcast
|
177
|
+
end
|
178
|
+
end
|
179
|
+
# :nocov:
|
180
|
+
|
142
181
|
##
|
143
182
|
# Auto-load all gRPC handlers
|
144
183
|
#
|
145
184
|
# :nocov:
|
146
|
-
def
|
185
|
+
def load_controllers
|
147
186
|
return unless File.directory?(controllers_path)
|
148
187
|
path = File.realpath(controllers_path)
|
149
188
|
$LOAD_PATH.unshift(path)
|
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.2.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: 2018-02-
|
11
|
+
date: 2018-02-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -158,7 +158,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
158
158
|
version: '0'
|
159
159
|
requirements: []
|
160
160
|
rubyforge_project:
|
161
|
-
rubygems_version: 2.6
|
161
|
+
rubygems_version: 2.7.6
|
162
162
|
signing_key:
|
163
163
|
specification_version: 4
|
164
164
|
summary: gRPC Ruby Framework
|