we-call 0.7.1 → 0.12.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 30bad41ed6b34f69292a161663ef04653ae592ec
4
- data.tar.gz: a8d187c323a32f8c73172ee0ab949f76540f3704
2
+ SHA256:
3
+ metadata.gz: dbf74dcbe416b443f5822de5e4dc5244b5448184263b9956329cb6c1129870ed
4
+ data.tar.gz: 58f39eb8e256d379360452dcc60debe784d5817d74f2215dae9b1f30a5c2d6ac
5
5
  SHA512:
6
- metadata.gz: 639f9f9c2c1d5d01435c0e3a293ae27236a48a83dd456438662c3829fcf04d0b032356b52a9af933b41c616420e84e3a879cd7df4418230ecea2977359006bd8
7
- data.tar.gz: e4aa1848b875d23a53510066e7b8ca199e7278a84d92fb76ed3e711e513546c978cdc0942e2888ff106e7225fdba4aa48da9c074b7fe6d1093b662ed6aa9bc82
6
+ metadata.gz: '0875da2fd0d502d5eceaf7f9121242adee5ac7884854edf6bddcd75b06572286e86520e39af3c6ef7a9ad46eec9e7f06c1ee52370bc8b3d5d2ca75549fed8da0'
7
+ data.tar.gz: 37068e825ace749bfdb15165df035024ccd541278b2fa4f1911e307c1ecfbc1cedf298db41c2df5f365b1fe45cec30a60612338c6206c31205ee511b0d715457
@@ -0,0 +1,42 @@
1
+ version: 2.1
2
+
3
+ x-shared: &x-shared
4
+ docker:
5
+ - image: circleci/ruby:2.6.3-stretch-node
6
+
7
+ jobs:
8
+ build:
9
+ <<: *x-shared
10
+ steps:
11
+ - checkout
12
+ - run:
13
+ name: Build
14
+ command: ./script/cibuild
15
+ - persist_to_workspace:
16
+ root: .
17
+ paths: .
18
+ publish-gem:
19
+ <<: *x-shared
20
+ steps:
21
+ - attach_workspace:
22
+ at: ~/project # circleci default working directory
23
+ - run:
24
+ name: Publish Gem
25
+ command: ./script/publish_gem
26
+ workflows:
27
+ version: 2
28
+ build:
29
+ jobs:
30
+ - build:
31
+ filters:
32
+ tags:
33
+ only: /v[0-9]+(\.[0-9]+)+/
34
+ - publish-gem:
35
+ requires:
36
+ - build
37
+ filters:
38
+ branches:
39
+ ignore:
40
+ - /.*/
41
+ tags:
42
+ only: /v[0-9]+(\.[0-9]+)+/
@@ -1 +1 @@
1
- service_name: travis-ci
1
+ service_name: circleci
@@ -0,0 +1,23 @@
1
+ name: Ruby
2
+
3
+ on:
4
+ push:
5
+ branches: [ $default-branch ]
6
+ pull_request:
7
+ branches: [ $default-branch ]
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ubuntu-latest
12
+ steps:
13
+ - uses: actions/checkout@v2
14
+ - name: Set up Ruby
15
+ uses: ruby/setup-ruby@v1
16
+ with:
17
+ ruby-version: 2.6
18
+ - name: Install dependencies
19
+ run: bundle install
20
+ - name: Generate gemfiles
21
+ run: bundle exec appraisal install
22
+ - name: Run tests
23
+ run: bundle exec appraisal rspec
@@ -6,18 +6,21 @@ before_script:
6
6
  script:
7
7
  - bundle exec appraisal rspec
8
8
  gemfiles:
9
- - faraday_0.9.gemfile
10
9
  - faraday_0.10.gemfile
11
10
  - faraday_0.11.gemfile
12
11
  - faraday_0.12.gemfile
13
12
  - faraday_0.13.gemfile
13
+ - faraday_0.15.gemfile
14
+ - faraday_0.14.gemfile
14
15
  - rails_4.2.gemfile
15
16
  - rails_5.0.gemfile
16
17
  - rails_5.1.gemfile
18
+ - rails_5.2.gemfile
17
19
  rvm:
18
- - 2.2.7
19
- - 2.3.4
20
- - 2.4.1
20
+ - 2.2
21
+ - 2.3
22
+ - 2.4
23
+ - 2.5
21
24
  - ruby-head
22
25
  matrix:
23
26
  allow_failures:
data/Appraisals CHANGED
@@ -1,3 +1,11 @@
1
+ appraise "faraday-0.15" do
2
+ gem "faraday", "~> 0.15.0"
3
+ end
4
+
5
+ appraise "faraday-0.14" do
6
+ gem "faraday", "~> 0.14.0"
7
+ end
8
+
1
9
  appraise "faraday-0.13" do
2
10
  gem "faraday", "~> 0.13.0"
3
11
  end
@@ -14,8 +22,8 @@ appraise "faraday-0.10" do
14
22
  gem "faraday", "~> 0.10.0"
15
23
  end
16
24
 
17
- appraise "faraday-0.9" do
18
- gem "faraday", "~> 0.9.0"
25
+ appraise "rails-5.2" do
26
+ gem "rails", "~> 5.2.0"
19
27
  end
20
28
 
21
29
  appraise "rails-5.1" do
@@ -5,6 +5,43 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](http://keepachangelog.com/)
6
6
  and this project adheres to [Semantic Versioning](http://semver.org/).
7
7
 
8
+ ## [v0.12.0] - 2020-12-17
9
+ ### Added
10
+ - Bump version to fix incorrect tag
11
+
12
+ ## [v0.11.0] - 2020-12-08
13
+ ### Added
14
+ - Allow to set retry options on a connection([#36])
15
+
16
+
17
+ ## [v0.9.1] - 2020-11-20
18
+ ### Added
19
+ - Automatically retry on network errors([#31])
20
+
21
+ [activesupport]: https://github.com/rails/rails/tree/master/activesupport
22
+ [#31]: https://github.com/wework/we-call-gem/pull/31
23
+
24
+ ## [v0.9.0] - 2018-09-18
25
+ ### Added
26
+ - Automatically reports deprecations to ActiveSupport if [activesupport] gem exists ([#21])
27
+ - Defaults detect_deprecations to nil instead of :active_support
28
+
29
+ [activesupport]: https://github.com/rails/rails/tree/master/activesupport
30
+ [#21]: https://github.com/wework/we-call-gem/pull/21
31
+
32
+ ## [v0.8.0] - 2018-08-27
33
+ ### Added
34
+ - Support for Ruby v2.5
35
+ - Support for Rails v5.2
36
+ - Support for Faraday v0.14 and v0.15
37
+ - Automatically reports deprecations to Rollbar if [rollbar] gem exists ([#17])
38
+
39
+ [rollbar]: https://github.com/rollbar/rollbar-gem
40
+ [#17]: https://github.com/wework/we-call-gem/pull/17
41
+
42
+ ### Breaking
43
+ - Dropped support for Faraday v0.9 (may still work but its no longer tested or recommended)
44
+
8
45
  ## [v0.7.1] - 2018-02-20
9
46
  ### Fixed
10
47
  - Call the gzip middleware to handle gzipped responses, which have been broken since v0.7 for typhoeus users
data/Gemfile CHANGED
@@ -1,4 +1,6 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
+ ruby '~> 2.2'
4
+
3
5
  # Specify your gem's dependencies in we-call.gemspec
4
6
  gemspec
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # We::Call
2
2
 
3
- [![Build Status][travis-image]][travis-url]
3
+ [![Build Status][ci-image]][ci-url]
4
4
  [![Coverage Status][coveralls-image]][coveralls-url]
5
5
  [![MIT License][license-image]][license-url]
6
6
 
@@ -102,6 +102,42 @@ As well as `timeout: num_seconds` which can set the entire open/read (essentiall
102
102
 
103
103
  ### Client
104
104
 
105
+ **Retry**
106
+
107
+ Automatically enabled, the retry middleware will retry the request in case of network errors. By default, the middleware will retry up to 3 times, waiting 1 second between the retries.
108
+
109
+ Disable the middleware:
110
+
111
+ ```ruby
112
+ We::Call.configure do |config|
113
+ config.retry = false
114
+ end
115
+
116
+ # Provided at initialization
117
+ connection = We::Call::Connection.new(retry_options: false)
118
+ ```
119
+
120
+ Adjust the middleware:
121
+
122
+ ```ruby
123
+ We::Call.configure do |config|
124
+ config.retry_options = { interval: 0.5 }
125
+ end
126
+
127
+ # Provided at initialization
128
+ connection = We::Call::Connection.new(retry_options: { interval: 0.5 })
129
+ ```
130
+
131
+ The gem smartly merges the options passed, so you can specify your own list of exceptions without being afraid to override the default ones:
132
+
133
+ ```ruby
134
+ We::Call.configure do |config|
135
+ config.retry_options = { exceptions: [Faraday::ResourceNotFound] }
136
+ end
137
+ ```
138
+
139
+ Check [Faraday's Retry Docs](https://github.com/lostisland/faraday/blob/master/docs/middleware/request/retry.md) for a list of available options.
140
+
105
141
  **DetectDeprecations**
106
142
 
107
143
  Automatically enabled, the faraday-sunset middleware will watch for the [Sunset header](https://tools.ietf.org/html/draft-wilde-sunset-header-03) and send warning to `ActiveSupport::Deprecation` if enabled, or to whatever is in `ENV['rake.logger']`.
@@ -122,9 +158,10 @@ Easy! Check your logs for `user_agent=service-name; app_name=service-name;` The
122
158
 
123
159
  ## Requirements
124
160
 
125
- - **Ruby:** v2.2 - v2.4
126
- - **Faraday:** v0.9 - v0.13
161
+ - **Ruby:** v2.2 - v2.5
162
+ - **Faraday:** v0.10 - v0.15
127
163
 
164
+ _**Note:** Other versions of Faraday may work, but we can't test against all of them forever._
128
165
 
129
166
  ## TODO
130
167
 
@@ -154,10 +191,10 @@ Bug reports and pull requests are welcome on GitHub at [wework/we-call](https://
154
191
 
155
192
 
156
193
  [coveralls-image]:https://coveralls.io/repos/github/wework/we-call-gem/badge.svg?branch=master
157
- [coveralls-url]:https://coveralls.io/github/wework/we-call-gem?branch=master
194
+ [coveralls-url]:https://coveralls.io/github/wework/we-call-gem?branch=main
158
195
 
159
- [travis-url]:https://travis-ci.org/wework/we-call-gem
160
- [travis-image]: https://travis-ci.org/wework/we-call-gem.svg?branch=master
196
+ [ci-url]:https://app.circleci.com/pipelines/github/wework/we-call-gem
197
+ [ci-image]:https://circleci.com/gh/wework/we-call-gem.svg?style=shield
161
198
 
162
199
  [license-url]: LICENSE
163
200
  [license-image]: http://img.shields.io/badge/license-MIT-000000.svg?style=flat-square
@@ -4,12 +4,14 @@ require 'faraday_middleware'
4
4
  module We
5
5
  module Call
6
6
  class Configuration
7
- attr_accessor :app_env, :app_env_header, :app_name, :app_name_header, :detect_deprecations
7
+ attr_accessor :app_env, :app_env_header, :app_name, :app_name_header, :detect_deprecations,
8
+ :retry, :retry_options
8
9
 
9
10
  def initialize
10
11
  @app_env_header = 'X-App-Env'
11
12
  @app_name_header = 'X-App-Name'
12
- @detect_deprecations = :active_support
13
+ @retry = true
14
+ @retry_options = {}
13
15
  end
14
16
  end
15
17
  end
@@ -14,6 +14,12 @@ module We
14
14
  DEFAULT_ADAPTER_CLASS = Faraday::Adapter::Typhoeus
15
15
  DEFAULT_ADAPTER = :typhoeus
16
16
 
17
+ DEFAULT_RETRY_OPTIONS = {
18
+ max: 3,
19
+ interval: 1,
20
+ exceptions: [Faraday::ConnectionFailed, Faraday::TimeoutError]
21
+ }
22
+
17
23
  class MissingApp < ArgumentError; end
18
24
  class MissingEnv < ArgumentError; end
19
25
  class MissingTimeout < ArgumentError; end
@@ -40,8 +46,9 @@ module We
40
46
  # @param [String] app
41
47
  # @param [String] env
42
48
  # @yieldparam [Faraday::Connection] Faraday connection object is yielded to a block
43
- def new(host:, timeout: nil, open_timeout: OPEN_TIMEOUT, app: guess_app, env: guess_env, &block)
49
+ def new(host:, timeout: nil, open_timeout: OPEN_TIMEOUT, app: guess_app, env: guess_env, retry_options: {}, &block)
44
50
  @host = host
51
+ @retry_options = retry_options
45
52
  @app = app or raise_missing_app!
46
53
  @env = env or raise_missing_env!
47
54
  @timeout = timeout or raise_missing_timeout!
@@ -51,7 +58,7 @@ module We
51
58
 
52
59
  private
53
60
 
54
- attr_reader :app, :env, :host, :timeout, :open_timeout
61
+ attr_reader :app, :env, :host, :timeout, :open_timeout, :retry_options
55
62
 
56
63
  # @return [Faraday::Connection] Preconfigured Faraday Connection object, for hitting get, post, etc.
57
64
  def create
@@ -72,6 +79,9 @@ module We
72
79
  if config.detect_deprecations
73
80
  faraday.response :sunset, setup_sunset_middleware(faraday)
74
81
  end
82
+ if should_retry?
83
+ faraday.request :retry, fetch_retry_options
84
+ end
75
85
 
76
86
  yield faraday if block_given?
77
87
 
@@ -110,13 +120,27 @@ module We
110
120
  end
111
121
 
112
122
  def setup_sunset_middleware(faraday)
113
- # In v0.5.0 this was a bool switch, now it takes :active_support or an instance of a Logger
114
- if config.detect_deprecations == true || config.detect_deprecations == :active_support
115
- return { active_support: true }
116
-
123
+ options = { rollbar: :auto, active_support: :auto }
117
124
  # Pass something that might be a logger or anything with a warn method
118
- elsif config.detect_deprecations.respond_to?(:warn)
119
- return { logger: config.detect_deprecations }
125
+ if config.detect_deprecations.respond_to?(:warn)
126
+ options = options.merge({ logger: config.detect_deprecations })
127
+ end
128
+ options
129
+ end
130
+
131
+ def should_retry?
132
+ retry_options.any? || config.retry
133
+ end
134
+
135
+ def fetch_retry_options
136
+ client_options = retry_options.any? ? retry_options : config.retry_options
137
+
138
+ DEFAULT_RETRY_OPTIONS.merge(client_options) do |key, default_val, new_val|
139
+ if key == :exceptions
140
+ default_val + Array(new_val)
141
+ else
142
+ new_val
143
+ end
120
144
  end
121
145
  end
122
146
 
@@ -1,5 +1,5 @@
1
1
  module We
2
2
  module Call
3
- VERSION = "0.7.1"
3
+ VERSION = '0.12.0'
4
4
  end
5
5
  end
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -e
3
+ cd "$(dirname "$0")/.."
4
+
5
+ bundle install
6
+ bundle exec appraisal install
7
+ bundle exec appraisal rspec
@@ -0,0 +1,18 @@
1
+ #!/bin/bash
2
+ set -eox pipefail
3
+
4
+ mkdir -p ~/.gem
5
+ echo :rubygems_api_key: $RUBYGEMS_APIKEY > ~/.gem/credentials
6
+ chmod 0600 ~/.gem/credentials
7
+
8
+ VERSION_FILE="lib/we/call/version.rb"
9
+ if [[ -n $CIRCLE_TAG ]]; then
10
+ # Determine the version from the tag; remove the leading v "v3.3.0" -> "3.3.0"
11
+ VERSION=$(echo "${CIRCLE_TAG}" | sed 's/^v//')
12
+ # Replace the version for the gemspec with the tag version
13
+ sed -i.bak -E "s/VERSION = .*/VERSION = '$VERSION'/" $VERSION_FILE
14
+ fi
15
+
16
+ gem build *.gemspec
17
+
18
+ gem push *.gem
@@ -23,15 +23,15 @@ Gem::Specification.new do |spec|
23
23
  spec.add_dependency "typhoeus", "~> 1.3"
24
24
  spec.add_dependency "faraday", ">= 0.9.0", "< 1"
25
25
  spec.add_dependency "faraday_middleware", '~> 0.10'
26
- spec.add_dependency "faraday-sunset", "~> 0.1.0"
26
+ spec.add_dependency "faraday-sunset", '~> 0.2'
27
27
 
28
28
  spec.add_development_dependency "appraisal", "~> 2.0"
29
- spec.add_development_dependency "coveralls", '~> 0.7'
29
+ spec.add_development_dependency "coveralls_reborn", '~> 0.13'
30
30
  spec.add_development_dependency "bundler", "~> 1.14"
31
31
  spec.add_development_dependency "rake", "~> 12.0"
32
32
  spec.add_development_dependency "rails", ">= 4.2"
33
33
  spec.add_development_dependency "rspec", "~> 3.5"
34
34
  spec.add_development_dependency "simplecov", '~> 0.15'
35
35
  spec.add_development_dependency "hashie", "~> 3.5"
36
- spec.add_development_dependency "vcr", '~> 3.0'
36
+ spec.add_development_dependency "vcr", '~> 4.0'
37
37
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: we-call
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.1
4
+ version: 0.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - WeWork Engineering
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-02-23 00:00:00.000000000 Z
11
+ date: 2020-12-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: typhoeus
@@ -64,14 +64,14 @@ dependencies:
64
64
  requirements:
65
65
  - - "~>"
66
66
  - !ruby/object:Gem::Version
67
- version: 0.1.0
67
+ version: '0.2'
68
68
  type: :runtime
69
69
  prerelease: false
70
70
  version_requirements: !ruby/object:Gem::Requirement
71
71
  requirements:
72
72
  - - "~>"
73
73
  - !ruby/object:Gem::Version
74
- version: 0.1.0
74
+ version: '0.2'
75
75
  - !ruby/object:Gem::Dependency
76
76
  name: appraisal
77
77
  requirement: !ruby/object:Gem::Requirement
@@ -87,19 +87,19 @@ dependencies:
87
87
  - !ruby/object:Gem::Version
88
88
  version: '2.0'
89
89
  - !ruby/object:Gem::Dependency
90
- name: coveralls
90
+ name: coveralls_reborn
91
91
  requirement: !ruby/object:Gem::Requirement
92
92
  requirements:
93
93
  - - "~>"
94
94
  - !ruby/object:Gem::Version
95
- version: '0.7'
95
+ version: '0.13'
96
96
  type: :development
97
97
  prerelease: false
98
98
  version_requirements: !ruby/object:Gem::Requirement
99
99
  requirements:
100
100
  - - "~>"
101
101
  - !ruby/object:Gem::Version
102
- version: '0.7'
102
+ version: '0.13'
103
103
  - !ruby/object:Gem::Dependency
104
104
  name: bundler
105
105
  requirement: !ruby/object:Gem::Requirement
@@ -190,14 +190,14 @@ dependencies:
190
190
  requirements:
191
191
  - - "~>"
192
192
  - !ruby/object:Gem::Version
193
- version: '3.0'
193
+ version: '4.0'
194
194
  type: :development
195
195
  prerelease: false
196
196
  version_requirements: !ruby/object:Gem::Requirement
197
197
  requirements:
198
198
  - - "~>"
199
199
  - !ruby/object:Gem::Version
200
- version: '3.0'
200
+ version: '4.0'
201
201
  description: Handles conventions of making calls to other services, with required
202
202
  metadata for tracking calls between services, deprecations of endpoints, trace IDs,
203
203
  throttling, etc.
@@ -207,7 +207,9 @@ executables: []
207
207
  extensions: []
208
208
  extra_rdoc_files: []
209
209
  files:
210
+ - ".circleci/config.yml"
210
211
  - ".coveralls.yml"
212
+ - ".github/workflows/build.yml"
211
213
  - ".gitignore"
212
214
  - ".rspec"
213
215
  - ".travis.yml"
@@ -227,6 +229,8 @@ files:
227
229
  - lib/we/call/middleware/server.rb
228
230
  - lib/we/call/middleware/server/log_user_agent.rb
229
231
  - lib/we/call/version.rb
232
+ - script/cibuild
233
+ - script/publish_gem
230
234
  - we-call.gemspec
231
235
  homepage: https://github.com/wework/we-call-gem
232
236
  licenses:
@@ -247,8 +251,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
247
251
  - !ruby/object:Gem::Version
248
252
  version: '0'
249
253
  requirements: []
250
- rubyforge_project:
251
- rubygems_version: 2.6.8
254
+ rubygems_version: 3.0.3
252
255
  signing_key:
253
256
  specification_version: 4
254
257
  summary: Making healthy, happy HTTP calls