we-call 0.9.0 → 0.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
- SHA1:
3
- metadata.gz: f43c92c0bef85414c9bc30d6a6e36000a608e08d
4
- data.tar.gz: afe98f764a7d361dbe7c4780532fd88a55285014
2
+ SHA256:
3
+ metadata.gz: 83cdb2541d4d694624f06d63e03dce612db88ce09e0ff7532c4d701424aedb46
4
+ data.tar.gz: a3862e1f9f6f4f1685ab2c7c8077e4a166ab3ebfa8a017fb32aa701d7dc68705
5
5
  SHA512:
6
- metadata.gz: a80e16265011e07665a6b44254f43bb2b42bce005c6ade5871b2e97aa240d90f4372008d5a9e1fac91c756867d8c85d69263d3879c6174fe4ee6cda2e92726a2
7
- data.tar.gz: de12d557bcbf695f7e13997fe84cd78fbd25339f7ce5f3075f832d3b4e410aadbca41a1d4e288d8ac58513ae3a366b9e0b5a46e33777347769927c3a5cabca58
6
+ metadata.gz: 1e8f5628d633564aaf0183a89ebebb9e9c4ee82d298d2deee8513b26dd5f8a52326ce57278c3f9782986def685212995f034a3e18d65321a34081689d248ca2a
7
+ data.tar.gz: 3792fa6710c0e4fcca018ad96464772d5776864bea0fc19e2c493bd871a9008eb09f6a675892008df4b9fe8454cdda66eca8a0e09d38dee5018428c8fa985b49
@@ -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
@@ -5,6 +5,13 @@ 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.9.1] - 2020-11-20
9
+ ### Added
10
+ - Automatically retry on network errors([#31])
11
+
12
+ [activesupport]: https://github.com/rails/rails/tree/master/activesupport
13
+ [#31]: https://github.com/wework/we-call-gem/pull/31
14
+
8
15
  ## [v0.9.0] - 2018-09-18
9
16
  ### Added
10
17
  - Automatically reports deprecations to ActiveSupport if [activesupport] gem exists ([#21])
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,36 @@ 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
+
117
+ Adjust the middleware:
118
+
119
+ ```ruby
120
+ We::Call.configure do |config|
121
+ config.retry_options = { interval: 0.5 }
122
+ end
123
+ ```
124
+
125
+ The gem smartly merges the options passed, so you can specify your own list of exceptions without being afraid to override the default ones:
126
+
127
+ ```ruby
128
+ We::Call.configure do |config|
129
+ config.retry_options = { exceptions: [Faraday::ResourceNotFound] }
130
+ end
131
+ ```
132
+
133
+ Check [Faraday's Retry Docs](https://github.com/lostisland/faraday/blob/master/docs/middleware/request/retry.md) for a list of available options.
134
+
105
135
  **DetectDeprecations**
106
136
 
107
137
  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']`.
@@ -155,10 +185,10 @@ Bug reports and pull requests are welcome on GitHub at [wework/we-call](https://
155
185
 
156
186
 
157
187
  [coveralls-image]:https://coveralls.io/repos/github/wework/we-call-gem/badge.svg?branch=master
158
- [coveralls-url]:https://coveralls.io/github/wework/we-call-gem?branch=master
188
+ [coveralls-url]:https://coveralls.io/github/wework/we-call-gem?branch=main
159
189
 
160
- [travis-url]:https://travis-ci.org/wework/we-call-gem
161
- [travis-image]: https://travis-ci.org/wework/we-call-gem.svg?branch=master
190
+ [ci-url]:https://app.circleci.com/pipelines/github/wework/we-call-gem
191
+ [ci-image]:https://circleci.com/gh/wework/we-call-gem.svg?style=shield
162
192
 
163
193
  [license-url]: LICENSE
164
194
  [license-image]: http://img.shields.io/badge/license-MIT-000000.svg?style=flat-square
@@ -4,11 +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'
13
+ @retry = true
14
+ @retry_options = {}
12
15
  end
13
16
  end
14
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
@@ -72,6 +78,9 @@ module We
72
78
  if config.detect_deprecations
73
79
  faraday.response :sunset, setup_sunset_middleware(faraday)
74
80
  end
81
+ if config.retry
82
+ faraday.request :retry, fetch_retry_options
83
+ end
75
84
 
76
85
  yield faraday if block_given?
77
86
 
@@ -118,6 +127,16 @@ module We
118
127
  options
119
128
  end
120
129
 
130
+ def fetch_retry_options
131
+ DEFAULT_RETRY_OPTIONS.merge(config.retry_options) do |key, default_val, new_val|
132
+ if key == :exceptions
133
+ default_val + Array(new_val)
134
+ else
135
+ new_val
136
+ end
137
+ end
138
+ end
139
+
121
140
  # @return [String] Environment (usually 'development', 'staging', 'production', etc.)
122
141
  def guess_env
123
142
  return config.app_env if config.app_env
@@ -1,5 +1,5 @@
1
1
  module We
2
2
  module Call
3
- VERSION = "0.9.0"
3
+ VERSION = '0.9.1'
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
@@ -26,7 +26,7 @@ Gem::Specification.new do |spec|
26
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"
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.9.0
4
+ version: 0.9.1
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-09-28 00:00:00.000000000 Z
11
+ date: 2020-11-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: typhoeus
@@ -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
@@ -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.14
254
+ rubygems_version: 3.0.3
252
255
  signing_key:
253
256
  specification_version: 4
254
257
  summary: Making healthy, happy HTTP calls