coverband-service-client 0.0.5 → 0.0.6

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: c222bdf2625345d8c4cf136402c9e2c3731bcfbc4b68f50d34fdd665e92bd733
4
- data.tar.gz: 81cc0d890f0d74e54f7d72b338f4fdbb8942b12df5290aea10398a90cf791239
3
+ metadata.gz: 2bbda63a9e7eacfee67d03b5e0b08f9a4a2ef31d4eea06fcb3901730b81fad95
4
+ data.tar.gz: bab021109fc8d6a785f273c35a7e39c9da4cf78f65d3a2b3a52105d2c9c00333
5
5
  SHA512:
6
- metadata.gz: 9b1e498b08fd591b75f0c9e71efe80bbaa7c866e5e53337e590dd9df1b3bf1b17b600e156fd020b0a72fb923561a3b2e6c21aedc2e2bdde21dc736954dbff8de
7
- data.tar.gz: d3ffa21ae79bfc8571e1c5d5fc6b02ecd92e1c90b899a9f856412617fcc7e47f3ec48f746efa54dd4f45cecfbb66d7dfa4dc3a3f029c84f0e44be772a6d41df9
6
+ metadata.gz: c9b9fa656753664c2e6dd37670274d9bd9231dea30c071c8735c406f234649e9c1758804da33239889ad6e7636c4652ac8e8d6c851d2eb87b74bb62683d40cc8
7
+ data.tar.gz: 52f461ebbfdbd5b379c7e8a48661c89aada386cca21e85f60aee3b075bb9291b6a9397503063117c33b850c933562339d57dd5910727f6713240fe57ce84e12e
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- coverband-service-client (0.0.5)
4
+ coverband-service-client (0.0.6)
5
5
  coverband (~> 4.2.4)
6
6
 
7
7
  GEM
@@ -10,7 +10,7 @@ GEM
10
10
  coverband (4.2.4)
11
11
  redis
12
12
  minitest (5.14.0)
13
- rake (10.5.0)
13
+ rake (13.0.1)
14
14
  redis (4.1.3)
15
15
 
16
16
  PLATFORMS
@@ -20,7 +20,7 @@ DEPENDENCIES
20
20
  bundler (~> 2.0)
21
21
  coverband-service-client!
22
22
  minitest (~> 5.0)
23
- rake (~> 10.0)
23
+ rake (~> 13.0)
24
24
 
25
25
  BUNDLED WITH
26
26
  2.0.2
@@ -27,7 +27,7 @@ Gem::Specification.new do |spec|
27
27
  spec.require_paths = ["lib"]
28
28
 
29
29
  spec.add_development_dependency "bundler", "~> 2.0"
30
- spec.add_development_dependency "rake", "~> 10.0"
30
+ spec.add_development_dependency "rake", "~> 13.0"
31
31
  spec.add_development_dependency "minitest", "~> 5.0"
32
32
  spec.add_runtime_dependency "coverband", "~> 4.2.4"
33
33
  end
@@ -6,6 +6,7 @@ require 'securerandom'
6
6
  COVERBAND_ENV = ENV['RACK_ENV'] || ENV['RAILS_ENV'] || (defined?(Rails) ? Rails.env : 'unknown')
7
7
  COVERBAND_SERVICE_URL = ENV['COVERBAND_URL'] ||
8
8
  ((COVERBAND_ENV == 'development') ? 'http://127.0.0.1:3456' : 'https://coverband-service.herokuapp.com')
9
+ COVERBAND_TIMEOUT = (COVERBAND_ENV == 'development') ? 5 : 1
9
10
 
10
11
  module Coverband
11
12
 
@@ -68,19 +69,21 @@ module Coverband
68
69
 
69
70
  # TODO: do we need dup
70
71
  # TODO: remove timestamps, server will track first_seen
71
- data = expand_report(report.dup)
72
- full_package = {
73
- collection_type: 'coverage_delta',
74
- collection_data: {
75
- tags: {
76
- process_type: process_type,
77
- app_loading: type == Coverband::EAGER_TYPE,
78
- runtime_env: runtime_env
79
- },
80
- file_coverage: data
72
+ Thread.new do
73
+ data = expand_report(report.dup)
74
+ full_package = {
75
+ collection_type: 'coverage_delta',
76
+ collection_data: {
77
+ tags: {
78
+ process_type: process_type,
79
+ app_loading: type == Coverband::EAGER_TYPE,
80
+ runtime_env: runtime_env
81
+ },
82
+ file_coverage: data
83
+ }
81
84
  }
82
- }
83
- save_coverage(full_package)
85
+ save_coverage(full_package)
86
+ end&.join
84
87
  end
85
88
 
86
89
  def raw_store
@@ -91,10 +94,19 @@ module Coverband
91
94
 
92
95
  def save_coverage(data)
93
96
  uri = URI("#{coverband_url}/api/collector")
94
- req = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json', 'Coverband-Token' => ENV['COVERBAND_API_KEY'])
95
- puts "sending #{data}"
97
+ req = Net::HTTP::Post.new(uri,
98
+ 'Content-Type' => 'application/json',
99
+ 'Coverband-Token' => ENV['COVERBAND_API_KEY'])
100
+ # puts "sending #{data}"
96
101
  req.body = { remote_uuid: SecureRandom.uuid, data: data }.to_json
97
- res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == 'https') do |http|
102
+ res = Net::HTTP.start(
103
+ uri.hostname,
104
+ uri.port,
105
+ open_timeout: COVERBAND_TIMEOUT,
106
+ read_timeout: COVERBAND_TIMEOUT,
107
+ ssl_timeout: COVERBAND_TIMEOUT,
108
+ use_ssl: uri.scheme == 'https'
109
+ ) do |http|
98
110
  http.request(req)
99
111
  end
100
112
  rescue StandardError => e
@@ -150,7 +162,7 @@ module Coverband
150
162
  tracked_views: views
151
163
  }
152
164
  }
153
- puts "sending #{data}"
165
+ # puts "sending #{data}"
154
166
  req.body = { remote_uuid: SecureRandom.uuid, data: data }.to_json
155
167
  res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == 'https') do |http|
156
168
  http.request(req)
@@ -163,18 +175,17 @@ module Coverband
163
175
  end
164
176
 
165
177
  Coverband.configure do |config|
166
- # toggle store type
167
-
168
- # redis_url = ENV['REDIS_URL']
169
- # Normal Coverband Setup
170
- # config.store = Coverband::Adapters::HashRedisStore.new(Redis.new(url: redis_url))
171
-
172
178
  # Use The Test Service Adapter
173
179
  config.store = Coverband::Adapters::Service.new(COVERBAND_SERVICE_URL)
174
180
 
175
181
  # default to tracking views true
176
182
  config.track_views = ENV['COVERBAND_ENABLE_VIEW_TRACKER'] ? true : false
177
183
 
184
+ # report every 10m by default
185
+ config.background_reporting_sleep_seconds = COVERBAND_ENV == 'production' ? 600 : 60
186
+ # add a wiggle to avoid service stampede
187
+ config.reporting_wiggle = COVERBAND_ENV == 'production' ? 90 : 6
188
+
178
189
  if COVERBAND_ENV == 'test'
179
190
  config.background_reporting_enabled = false
180
191
  end
@@ -1,7 +1,7 @@
1
1
  module Coverband
2
2
  module Service
3
3
  module Client
4
- VERSION = '0.0.5'
4
+ VERSION = '0.0.6'
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: coverband-service-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dan Mayer
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2020-02-22 00:00:00.000000000 Z
12
+ date: 2020-03-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -31,14 +31,14 @@ dependencies:
31
31
  requirements:
32
32
  - - "~>"
33
33
  - !ruby/object:Gem::Version
34
- version: '10.0'
34
+ version: '13.0'
35
35
  type: :development
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
39
  - - "~>"
40
40
  - !ruby/object:Gem::Version
41
- version: '10.0'
41
+ version: '13.0'
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: minitest
44
44
  requirement: !ruby/object:Gem::Requirement