gruf 2.2.0 → 2.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA256:
3
- metadata.gz: 5e2128aead5d95df32a7c576007e1f725321d994a30dcc799369ef04a2866bae
4
- data.tar.gz: 9cce18e801ce59b8d156f9f02fdb0266281bea439cd6da85e94d7a0c6ca45df1
2
+ SHA1:
3
+ metadata.gz: 8527045d1d987962200fe9f93d95d510dc065e13
4
+ data.tar.gz: d5d07f8f3b79194510fb4b7d923d1a7d25cc158a
5
5
  SHA512:
6
- metadata.gz: 47e56d29f46dbdd51634bff6c2cba63b482e99ab94a57022e231bd4d081f8b26efcefa524712dd3a9faf0edc9aeddc07895b01a1acf51b9f24f512657faba61d
7
- data.tar.gz: e3b9a9e56016f3ede0520bfc4fafd1f9409c32ea16a977ca27f6c296d0215d26ec9f1d8de705659710da855f22de6083c0681cdc5b974ef80b2602144892f488
6
+ metadata.gz: 40a3edb5d90cb4229344312eab599f9524d3d3e154fafaa6867e8e5958395ff518346e724d13b386f88964840ed48f4dec31f8c58b078f2c48936f90461c65e8
7
+ data.tar.gz: 504cce2f076685d662b45f5d6769f748528d1618a83d312f8cef461242936ff4519cbdb99a430eb0cf6613d166d8e70aa2af01f4bc0b29268b18db4c8cb0a2c9
@@ -2,9 +2,14 @@ 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.1
6
+
7
+ - Now changes proc title once server is ready to process incoming requests [#44]
8
+ - Gruf now requires gRPC 1.10.x+ due to various fixes and improvements in the gRPC core libraries
9
+
5
10
  ### 2.2.0
6
11
 
7
- - Run server in a monitored thread to allow for trapped exits on sigints
12
+ - Run server in a monitored thread to allow for trapped exits on sigints [#43]
8
13
 
9
14
  ### 2.1.1
10
15
 
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.4.x-1.9.x. gruf is compatible and tested with Ruby 2.2-2.5.
20
+ gruf currently has active support for gRPC 1.10.x+. gruf is compatible and tested with Ruby 2.2-2.5.
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), for instance).
23
23
 
@@ -36,7 +36,7 @@ Gem::Specification.new do |spec|
36
36
  spec.add_development_dependency 'rake', '~> 10.0'
37
37
  spec.add_development_dependency 'pry'
38
38
 
39
- spec.add_runtime_dependency 'grpc', '~> 1.4'
40
- spec.add_runtime_dependency 'grpc-tools', '~> 1.4'
39
+ spec.add_runtime_dependency 'grpc', '~> 1.10'
40
+ spec.add_runtime_dependency 'grpc-tools', '~> 1.10'
41
41
  spec.add_runtime_dependency 'activesupport'
42
42
  end
@@ -135,13 +135,13 @@ module Gruf
135
135
  #
136
136
  # @param [Symbol] call_sig The call signature being executed
137
137
  # @param [Object] req (Optional) The protobuf request message to send
138
- # @param [Hash] md (Optional) A hash of metadata key/values that are transported with the client request
138
+ # @param [Hash] metadata (Optional) A hash of metadata key/values that are transported with the client request
139
139
  # @param [Hash] opts (Optional) A hash of options to send to the gRPC request_response method
140
140
  #
141
- def execute(call_sig, req, md, opts = {}, &block)
141
+ def execute(call_sig, req, metadata, opts = {}, &block)
142
142
  Timer.time do
143
143
  opts[:return_op] = true
144
- opts[:metadata] = md
144
+ opts[:metadata] = metadata
145
145
  send(call_sig, req, opts, &block)
146
146
  end
147
147
  end
@@ -112,10 +112,11 @@ module Gruf
112
112
  ##
113
113
  # Ensure all metadata values are strings as HTTP/2 requires string values for transport
114
114
  #
115
+ # @param [Hash] metadata The existing metadata hash
115
116
  # @return [Hash] The newly set metadata
116
117
  #
117
- def metadata=(md)
118
- @metadata = md.map { |k, str| [k, str.to_s] }.to_h
118
+ def metadata=(metadata)
119
+ @metadata = metadata.map { |k, str| [k, str.to_s] }.to_h
119
120
  end
120
121
 
121
122
  ##
@@ -34,16 +34,16 @@ module Gruf
34
34
  ##
35
35
  # Initialize a response object with the given gRPC operation
36
36
  #
37
- # @param [GRPC::ActiveCall::Operation] op The given operation for the current call
37
+ # @param [GRPC::ActiveCall::Operation] operation The given operation for the current call
38
38
  # @param [Float] execution_time The amount of time that the response took to occur
39
39
  #
40
- def initialize(op, execution_time = nil)
41
- @operation = op
42
- @message = op.execute
43
- @metadata = op.metadata
44
- @trailing_metadata = op.trailing_metadata
45
- @deadline = op.deadline
46
- @cancelled = op.cancelled?
40
+ def initialize(operation, execution_time = nil)
41
+ @operation = operation
42
+ @message = operation.execute
43
+ @metadata = operation.metadata
44
+ @trailing_metadata = operation.trailing_metadata
45
+ @deadline = operation.deadline
46
+ @cancelled = operation.cancelled?
47
47
  @execution_time = execution_time || 0.0
48
48
  end
49
49
 
@@ -53,7 +53,7 @@ module Gruf
53
53
  # @return [Object] The protobuf response message
54
54
  #
55
55
  def message
56
- @message ||= op.execute
56
+ @message ||= @operation.execute
57
57
  end
58
58
 
59
59
  ##
@@ -42,6 +42,7 @@ module Gruf
42
42
  @stop_server = false
43
43
  @stop_server_cv = ConditionVariable.new
44
44
  @stop_server_mu = Monitor.new
45
+ @server_mu = Monitor.new
45
46
  setup
46
47
  end
47
48
 
@@ -49,12 +50,14 @@ module Gruf
49
50
  # @return [GRPC::RpcServer] The GRPC server running
50
51
  #
51
52
  def server
52
- unless @server
53
- @server = GRPC::RpcServer.new(options)
54
- @port = @server.add_http2_port(options.fetch(:hostname, Gruf.server_binding_url), ssl_credentials)
55
- @services.each { |s| @server.handle(s) }
53
+ @server_mu.synchronize do
54
+ @server ||= begin
55
+ server = GRPC::RpcServer.new(options)
56
+ @port = server.add_http2_port(options.fetch(:hostname, Gruf.server_binding_url), ssl_credentials)
57
+ @services.each { |s| server.handle(s) }
58
+ server
59
+ end
56
60
  end
57
- @server
58
61
  end
59
62
 
60
63
  ##
@@ -62,6 +65,13 @@ module Gruf
62
65
  #
63
66
  # :nocov:
64
67
  def start!
68
+ update_proc_title(:starting)
69
+
70
+ server_thread = Thread.new do
71
+ logger.info { 'Booting gRPC Server...' }
72
+ server.run
73
+ end
74
+
65
75
  stop_server_thread = Thread.new do
66
76
  loop do
67
77
  break if @stop_server
@@ -71,12 +81,14 @@ module Gruf
71
81
  server.stop
72
82
  end
73
83
 
74
- logger.info { 'Booting gRPC Server...' }
84
+ server.wait_till_running
75
85
  @started = true
76
- server.run
86
+ update_proc_title(:serving)
77
87
  stop_server_thread.join
88
+ server_thread.join
78
89
  @started = false
79
90
 
91
+ update_proc_title(:stopped)
80
92
  logger.info { 'Goodbye!' }
81
93
  end
82
94
  # :nocov:
@@ -218,5 +230,16 @@ module Gruf
218
230
  end
219
231
  end
220
232
  # :nocov:
233
+
234
+ ##
235
+ # Updates proc name/title
236
+ #
237
+ # @param [Symbol] state
238
+ #
239
+ # :nocov:
240
+ def update_proc_title(state)
241
+ Process.setproctitle("gruf #{Gruf::VERSION} -- #{state}")
242
+ end
243
+ # :nocov:
221
244
  end
222
245
  end
@@ -14,5 +14,5 @@
14
14
  # OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
15
15
  #
16
16
  module Gruf
17
- VERSION = '2.2.0'.freeze
17
+ VERSION = '2.2.1'.freeze
18
18
  end
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.2.0
4
+ version: 2.2.1
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-21 00:00:00.000000000 Z
11
+ date: 2018-03-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -58,28 +58,28 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '1.4'
61
+ version: '1.10'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '1.4'
68
+ version: '1.10'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: grpc-tools
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '1.4'
75
+ version: '1.10'
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '1.4'
82
+ version: '1.10'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: activesupport
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -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.7.6
161
+ rubygems_version: 2.6.13
162
162
  signing_key:
163
163
  specification_version: 4
164
164
  summary: gRPC Ruby Framework