gruf 2.9.0 → 2.9.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
2
  SHA256:
3
- metadata.gz: 77be459526bb01a2e709cb26663e0b2bbdc614eb28de7084a132c14d741fef66
4
- data.tar.gz: b36e8446fd325c42b9c494370b09fd9ecd2364d5a84194683f5d9d81961dd5b2
3
+ metadata.gz: bffd546b0bd27dcd8cd54146065623e73e0396211ae263985a197255bb8ec48a
4
+ data.tar.gz: 9b0364643ab5c1008a330ed61c8fba4458f9b075c34eea81acb10de4ee70f53d
5
5
  SHA512:
6
- metadata.gz: 9d11c575a288e18321aeee6de57b9b9c8a9db09e2c200ce3c5a50d7331e7e1af2975bcba2ae276917e0bf087bbc7c1f0726b4df13d9861bab361c66069a691f9
7
- data.tar.gz: baed74a1e86746ae86314f4fa33065f1b0a3d9ae479c8f288f444444be24e78d76a9f0337cdcfe62b9637d53e6709cf031122cf8728bf709abaa4e6fd79ad788
6
+ metadata.gz: 3ef4637ca552b572f77b270ccdc491c660b62d7c1d8ff85fe67151cf22f09e92f18a9b88b63d31e956411cb46380ba695e0eccc74d47a2095c8fc7d6ebfaf838
7
+ data.tar.gz: 0f38cc6c69487f1cab2ebc5e07b5a06de20f5e35d0000ad4c80a021288557aaaef2acf58fe254be6dc292ddd2e764976acfdd65578a7a0233c663dea83018eb3
data/CHANGELOG.md CHANGED
@@ -2,6 +2,11 @@ Changelog for the gruf gem. This includes internal history before the gem was ma
2
2
 
3
3
  ### Pending release
4
4
 
5
+ ### 2.9.1
6
+
7
+ - Drop support for Ruby 2.4/2.5 to align with Ruby EOL schedule, supporting 2.6+ only
8
+ - Allow for float/TimeSpec timeout values on clients
9
+
5
10
  ### 2.9.0
6
11
 
7
12
  - Change to racially neutral terminology across library
data/lib/gruf/client.rb CHANGED
@@ -62,7 +62,7 @@ module Gruf
62
62
  @opts[:hostname] = @opts.fetch(:hostname, Gruf.default_client_host)
63
63
  @opts[:channel_credentials] = @opts.fetch(:channel_credentials, Gruf.default_channel_credentials)
64
64
  @error_factory = Gruf::Client::ErrorFactory.new
65
- client_options[:timeout] = client_options[:timeout].to_i if client_options.key?(:timeout)
65
+ client_options[:timeout] = parse_timeout(client_options[:timeout]) if client_options.key?(:timeout)
66
66
  client = "#{service}::Stub".constantize.new(@opts[:hostname], build_ssl_credentials, **client_options)
67
67
  super(client)
68
68
  end
@@ -216,5 +216,27 @@ module Gruf
216
216
  Gruf::Serializers::Errors::Json
217
217
  end
218
218
  end
219
+
220
+ ##
221
+ # Handle various timeout values and prevent improper value setting
222
+ #
223
+ # @see GRPC::Core::TimeConsts#from_relative_time
224
+ # @param [mixed] timeout
225
+ # @return [Float]
226
+ # @return [GRPC::Core::TimeSpec]
227
+ #
228
+ def parse_timeout(timeout)
229
+ if timeout.nil?
230
+ GRPC::Core::TimeConsts::ZERO
231
+ elsif timeout.is_a?(GRPC::Core::TimeSpec)
232
+ timeout
233
+ elsif timeout.is_a?(Numeric)
234
+ timeout
235
+ elsif timeout.respond_to?(:to_f)
236
+ timeout.to_f
237
+ else
238
+ raise ArgumentError, 'timeout is not a valid value: does not respond to to_f'
239
+ end
240
+ end
219
241
  end
220
242
  end
data/lib/gruf/version.rb CHANGED
@@ -16,5 +16,5 @@
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
18
  module Gruf
19
- VERSION = '2.9.0'
19
+ VERSION = '2.9.1'
20
20
  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.9.0
4
+ version: 2.9.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: 2021-03-02 00:00:00.000000000 Z
11
+ date: 2021-03-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler