holistics 0.2.5 → 0.2.6

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
2
  SHA1:
3
- metadata.gz: 39bcdb685f435ddf1b9e4ff3db50a382db24a575
4
- data.tar.gz: 2401856878ab1ba0c4f7c8a141c58ce489dae8c8
3
+ metadata.gz: f9fb3b55061bda996463b5457b34288074c77b1d
4
+ data.tar.gz: e71483052146db2964c65985601d12083ea154e8
5
5
  SHA512:
6
- metadata.gz: ebc1d1b0e83247c076c585b0dd52433b5961a5b99d19bec3bc5300730816bde0da223d5a78146283b8470da28037511a1e7abe63a0841bc9f8f684046d217afc
7
- data.tar.gz: 97aa1ddea6fc4f27fb15a4f7f70da6d653c5029d993caa071fa1bd62c49e88ada17acde1cc4e4a4d6929a66c5662c57a8d26dd769800fdbb9e5f4ac5204d0be5
6
+ metadata.gz: 7672b4b309d1d310cb884d41a64f9aca1cac83071a559cec6d022dda49d045cb02a1565f4098d5a08cd0ce13bed1cd2c9eb2d54b82256044a09e61cd9a48948f
7
+ data.tar.gz: 2a4171ce380f169fe6cdd3f8963a28a608f03d6eec1cba3618f65ff0a3d3a55af051799431fb1e1d5585e753d224018b400341d5523368d8d5869c16942b2cb9
@@ -20,4 +20,6 @@ This project adheres to [Semantic Versioning](http://semver.org/).
20
20
  ## v0.2.5
21
21
  * Support invoking email schedule with `holistics email_schedule trigger <id>`
22
22
 
23
+ ## v0.2.6
24
+ * Add error handling and retry mechanism for `fetch_job_details`
23
25
 
@@ -15,6 +15,14 @@ module Holistics
15
15
  Pathname.new(__FILE__).parent.parent
16
16
  end
17
17
 
18
+ def self.env
19
+ return ENV['HOLISTICS_ENV']
20
+ end
21
+
22
+ def self.test?
23
+ self.env == 'test'
24
+ end
25
+
18
26
  def self.logger
19
27
  @logger ||= CustomLogger.new(STDOUT)
20
28
  end
@@ -14,9 +14,9 @@ module Holistics
14
14
 
15
15
  def server_url
16
16
  host =
17
- if ENV['HOLISTICS_DEV'] || ENV['HOLISTICS_TEST']
17
+ if %w(development test).include?(ENV['HOLISTICS_ENV'])
18
18
  'http://localhost:3000'
19
- elsif ENV['HOLISTICS_STAGING']
19
+ elsif ENV['HOLISTICS_STAGING'] || ENV['HOLISTICS_ENV'] == 'staging'
20
20
  'https://staging.holistics.io'
21
21
  elsif ENV['HOLISTICS_HOST']
22
22
  ENV['HOLISTICS_HOST']
@@ -1,14 +1,24 @@
1
1
  module Holistics
2
2
  module Helpers
3
3
  class JobManager
4
+ MAX_RETRIES = 3
4
5
 
5
6
  def auth_helper
6
7
  @auth_info ||= Helpers::AuthInfo.new
7
8
  end
8
9
 
9
10
  def fetch_job_details(job_id, last_id = 0)
11
+ tries ||= MAX_RETRIES
10
12
  response = HTTParty.get(auth_helper.api_url_for("jobs/#{job_id}/logs.json", last_id: last_id))
11
13
  JSON.parse(response.body)
14
+ rescue JSON::ParserError => err
15
+ sleep 2 ** (MAX_RETRIES - tries) unless Holistics.test?
16
+ if (tries -= 1) >= 0
17
+ puts 'Retrying...'
18
+ retry
19
+ end
20
+ puts 'Retry exceeded... Raise error'
21
+ raise
12
22
  end
13
23
 
14
24
  def job_show options
@@ -1,4 +1,4 @@
1
1
  module Holistics
2
- VERSION = '0.2.5'
3
- DATE = '2016-11-25'
2
+ VERSION = '0.2.6'
3
+ DATE = '2017-03-10'
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: holistics
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thanh Dinh Khac
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-11-25 00:00:00.000000000 Z
12
+ date: 2017-03-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -128,7 +128,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
128
128
  version: '0'
129
129
  requirements: []
130
130
  rubyforge_project:
131
- rubygems_version: 2.4.8
131
+ rubygems_version: 2.6.10
132
132
  signing_key:
133
133
  specification_version: 4
134
134
  summary: CLI interface for Holistics