googleapis / gax-ruby

Google API Extensions for Ruby
https://rubygems.org/gems/google-gax
BSD 3-Clause "New" or "Revised" License
20 stars 22 forks source link

Add Configuration #194

Closed blowmage closed 5 years ago

blowmage commented 5 years ago

This PR adds Google::Gax::Configuration which will be used to configure the Client defaults. This will allow users to configure the behavior of API client, by both configuring the defaults on the global level as well as configuring the defaults on the client instance object level.

# Set global defaults
Google::Cloud::Vision::V1::ImageAnnotator.configure do |config|
  config.timeout = 120
  config.retry_policy = { retry_codes: [14] }
  config.methods.batch_annotate_images.retry_policy = { retry_codes: [12, 14] }
end

# Set/override the defaults on an individual instance
client = Google::Cloud::Vision::V1::ImageAnnotator::Client.new do |config|
  config.timeout = 90
  config.retry_policy = { retry_codes: [12, 14] }
  config.methods.batch_annotate_images.retry_policy = { retry_codes: [14] }
end

[refs #188]

codecov[bot] commented 5 years ago

Codecov Report

Merging #194 into master will decrease coverage by 0.65%. The diff coverage is 95.85%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #194      +/-   ##
==========================================
- Coverage   98.83%   98.18%   -0.66%     
==========================================
  Files          32       34       +2     
  Lines        1547     1980     +433     
==========================================
+ Hits         1529     1944     +415     
- Misses         18       36      +18
Impacted Files Coverage Δ
test/google/gax/configuration_test.rb 100% <100%> (ø)
lib/google/gax.rb 100% <100%> (ø) :arrow_up:
lib/google/gax/configuration.rb 89.88% <89.88%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 9724c58...64ce8de. Read the comment docs.