bidu-house 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +2 -2
- data/README.md +17 -0
- data/lib/bidu/house/report/error.rb +7 -2
- data/lib/bidu/house/version.rb +1 -1
- data/spec/lib/bidu/house/report/error_spec.rb +32 -4
- data/spec/lib/bidu/house/report_builder_spec.rb +3 -3
- data/spec/lib/bidu/house/status_builder_spec.rb +2 -1
- data/spec/lib/bidu/house/status_spec.rb +6 -3
- metadata +29 -29
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a983db5f6db921362ce62f4d7f0a0cbe09272968
|
4
|
+
data.tar.gz: bfc7a4ace34f0eb1ba940ad1e562e2ed0351d98c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b4c2f0f4e0c0c5151a98171e5ae307cf332c965b00e3dacc44dfa05ea369f9aa2fedd5b984c5231ebe3d96c5514b3abc7746471e02d5aaf5cf267c825179e943
|
7
|
+
data.tar.gz: 535155a3de8ecb7e6a101e80a1d3bd287c75d3be780a9d53df3221deb1cb38d1be5286b988e56cf2b9f1b4bc1b98f460c9fe69ca1b1f79366a11351d3a816273
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
bidu-house (0.2.
|
4
|
+
bidu-house (0.2.1)
|
5
5
|
activesupport
|
6
6
|
bidu-active_ext
|
7
7
|
concern_builder
|
@@ -27,7 +27,7 @@ GEM
|
|
27
27
|
bidu-active_ext (1.0.0)
|
28
28
|
activesupport
|
29
29
|
bidu-core_ext
|
30
|
-
bidu-core_ext (1.2.
|
30
|
+
bidu-core_ext (1.2.1)
|
31
31
|
activesupport
|
32
32
|
builder (3.2.2)
|
33
33
|
coderay (1.1.0)
|
data/README.md
CHANGED
@@ -63,3 +63,20 @@ with error and render the report
|
|
63
63
|
wget http://localhost:3000/health-check/status?period=3.days&threshold=0.005
|
64
64
|
wget http://localhost:3000/health-check/late-status?period=1.hours&threshold=0.1
|
65
65
|
```
|
66
|
+
|
67
|
+
6. Use the status json to understand what is wrong
|
68
|
+
```json
|
69
|
+
{
|
70
|
+
"status": "error",
|
71
|
+
"failures": {
|
72
|
+
"ids": [10, 14],
|
73
|
+
"percentage": 0.5,
|
74
|
+
"status": "error"
|
75
|
+
},
|
76
|
+
"delays": {
|
77
|
+
"ids": [12],
|
78
|
+
"percentage": 0.001,
|
79
|
+
"status": "ok"
|
80
|
+
}
|
81
|
+
}
|
82
|
+
```
|
@@ -35,13 +35,18 @@ module Bidu
|
|
35
35
|
end
|
36
36
|
|
37
37
|
def error?
|
38
|
-
percentage > threshold
|
38
|
+
@error ||= percentage > threshold
|
39
|
+
end
|
40
|
+
|
41
|
+
def status
|
42
|
+
error? ? :error : :ok
|
39
43
|
end
|
40
44
|
|
41
45
|
def as_json
|
42
46
|
{
|
43
47
|
ids: scoped.pluck(external_key),
|
44
|
-
percentage: percentage
|
48
|
+
percentage: percentage,
|
49
|
+
status: status
|
45
50
|
}
|
46
51
|
end
|
47
52
|
|
data/lib/bidu/house/version.rb
CHANGED
@@ -293,16 +293,44 @@ describe Bidu::House::Report::Error do
|
|
293
293
|
end
|
294
294
|
end
|
295
295
|
|
296
|
+
describe '#status' do
|
297
|
+
context 'when errors percentage overcames threshold' do
|
298
|
+
it { expect(subject.status).to eq(:error) }
|
299
|
+
end
|
300
|
+
|
301
|
+
context 'when errors percentage does not overcames threshold' do
|
302
|
+
let(:errors) { 0 }
|
303
|
+
it { expect(subject.status).to eq(:ok) }
|
304
|
+
end
|
305
|
+
end
|
306
|
+
|
296
307
|
describe '#as_json' do
|
308
|
+
let(:expected) do
|
309
|
+
{ ids: ids_expected, percentage: percentage_expected, status: status_expected }
|
310
|
+
end
|
311
|
+
|
312
|
+
context 'when everything is ok' do
|
313
|
+
let(:errors) { 1 }
|
314
|
+
let(:successes) { 9 }
|
315
|
+
let(:ids_expected) { [90] }
|
316
|
+
let(:status_expected) { :ok }
|
317
|
+
let(:percentage_expected) { 0.1 }
|
318
|
+
let(:threshold) { 0.5 }
|
319
|
+
|
320
|
+
it 'returns the external keys, status and error percentage' do
|
321
|
+
expect(subject.as_json).to eq(expected)
|
322
|
+
end
|
323
|
+
|
324
|
+
end
|
325
|
+
|
297
326
|
context 'when there are 75% erros' do
|
327
|
+
let(:status_expected) { :error }
|
328
|
+
let(:percentage_expected) { 0.75 }
|
298
329
|
let(:errors) { 3 }
|
299
330
|
let(:successes) { 1 }
|
300
331
|
let(:ids_expected) { [10, 11, 12] }
|
301
|
-
let(:expected) do
|
302
|
-
{ ids: ids_expected, percentage: 0.75 }
|
303
|
-
end
|
304
332
|
|
305
|
-
it 'returns the external keys and error percentage' do
|
333
|
+
it 'returns the external keys, status and error percentage' do
|
306
334
|
expect(subject.as_json).to eq(expected)
|
307
335
|
end
|
308
336
|
|
@@ -37,7 +37,7 @@ describe Bidu::House::ReportBuilder do
|
|
37
37
|
end
|
38
38
|
|
39
39
|
it 'builds the report using the given configuration' do
|
40
|
-
expect(report.as_json).to eq( ids: ids, percentage: 0.25 )
|
40
|
+
expect(report.as_json).to eq( ids: ids, percentage: 0.25, status: :error )
|
41
41
|
expect(report.error?).to be_truthy
|
42
42
|
end
|
43
43
|
|
@@ -50,7 +50,7 @@ describe Bidu::House::ReportBuilder do
|
|
50
50
|
end
|
51
51
|
|
52
52
|
context 'when passing a custom period parameter' do
|
53
|
-
let(:parameters) { { threshold: 0.4, period: 10.days } }
|
53
|
+
let(:parameters) { { threshold: 0.4, period: 10.days, status: :error } }
|
54
54
|
|
55
55
|
it 'uses custom period parameter' do
|
56
56
|
expect(report.error?).to be_truthy
|
@@ -63,7 +63,7 @@ describe Bidu::House::ReportBuilder do
|
|
63
63
|
end
|
64
64
|
|
65
65
|
it 'ignores the non customizable parameters' do
|
66
|
-
expect(report.as_json).to eq( ids: ids, percentage: 0.25 )
|
66
|
+
expect(report.as_json).to eq( ids: ids, percentage: 0.25, status: :error )
|
67
67
|
expect(report.error?).to be_truthy
|
68
68
|
expect(report.id).to eq(:errors)
|
69
69
|
end
|
@@ -98,7 +98,8 @@ describe Bidu::House::Status do
|
|
98
98
|
status: :error,
|
99
99
|
errors: {
|
100
100
|
ids: ids,
|
101
|
-
percentage: 0.75
|
101
|
+
percentage: 0.75,
|
102
|
+
status: :error
|
102
103
|
}
|
103
104
|
}
|
104
105
|
end
|
@@ -114,11 +115,13 @@ describe Bidu::House::Status do
|
|
114
115
|
status: :error,
|
115
116
|
errors: {
|
116
117
|
ids: ids,
|
117
|
-
percentage: 0.75
|
118
|
+
percentage: 0.75,
|
119
|
+
status: :error
|
118
120
|
},
|
119
121
|
success: {
|
120
122
|
ids: success_ids,
|
121
|
-
percentage: 0.25
|
123
|
+
percentage: 0.25,
|
124
|
+
status: :error
|
122
125
|
}
|
123
126
|
}
|
124
127
|
end
|
metadata
CHANGED
@@ -1,167 +1,167 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bidu-house
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bidu Dev's Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-02-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: concern_builder
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: bidu-active_ext
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: json_parser
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - ~>
|
59
|
+
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '1.1'
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - ~>
|
66
|
+
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '1.1'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: activerecord
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '0'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- -
|
80
|
+
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: sqlite3
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- -
|
87
|
+
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: '0'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- -
|
94
|
+
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: bundler
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- - ~>
|
101
|
+
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
103
|
version: '1.6'
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- - ~>
|
108
|
+
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '1.6'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: rake
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
|
-
- -
|
115
|
+
- - ">="
|
116
116
|
- !ruby/object:Gem::Version
|
117
117
|
version: '0'
|
118
118
|
type: :development
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
|
-
- -
|
122
|
+
- - ">="
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0'
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: rspec
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
128
128
|
requirements:
|
129
|
-
- - ~>
|
129
|
+
- - "~>"
|
130
130
|
- !ruby/object:Gem::Version
|
131
131
|
version: '2.14'
|
132
132
|
type: :development
|
133
133
|
prerelease: false
|
134
134
|
version_requirements: !ruby/object:Gem::Requirement
|
135
135
|
requirements:
|
136
|
-
- - ~>
|
136
|
+
- - "~>"
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: '2.14'
|
139
139
|
- !ruby/object:Gem::Dependency
|
140
140
|
name: pry-nav
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|
142
142
|
requirements:
|
143
|
-
- -
|
143
|
+
- - ">="
|
144
144
|
- !ruby/object:Gem::Version
|
145
145
|
version: '0'
|
146
146
|
type: :development
|
147
147
|
prerelease: false
|
148
148
|
version_requirements: !ruby/object:Gem::Requirement
|
149
149
|
requirements:
|
150
|
-
- -
|
150
|
+
- - ">="
|
151
151
|
- !ruby/object:Gem::Version
|
152
152
|
version: '0'
|
153
153
|
- !ruby/object:Gem::Dependency
|
154
154
|
name: simplecov
|
155
155
|
requirement: !ruby/object:Gem::Requirement
|
156
156
|
requirements:
|
157
|
-
- -
|
157
|
+
- - ">="
|
158
158
|
- !ruby/object:Gem::Version
|
159
159
|
version: '0'
|
160
160
|
type: :development
|
161
161
|
prerelease: false
|
162
162
|
version_requirements: !ruby/object:Gem::Requirement
|
163
163
|
requirements:
|
164
|
-
- -
|
164
|
+
- - ">="
|
165
165
|
- !ruby/object:Gem::Version
|
166
166
|
version: '0'
|
167
167
|
description: Gem for easy health check
|
@@ -171,8 +171,8 @@ executables: []
|
|
171
171
|
extensions: []
|
172
172
|
extra_rdoc_files: []
|
173
173
|
files:
|
174
|
-
- .gitignore
|
175
|
-
- .rspec
|
174
|
+
- ".gitignore"
|
175
|
+
- ".rspec"
|
176
176
|
- Gemfile
|
177
177
|
- Gemfile.lock
|
178
178
|
- LICENSE
|
@@ -212,17 +212,17 @@ require_paths:
|
|
212
212
|
- lib
|
213
213
|
required_ruby_version: !ruby/object:Gem::Requirement
|
214
214
|
requirements:
|
215
|
-
- -
|
215
|
+
- - ">="
|
216
216
|
- !ruby/object:Gem::Version
|
217
217
|
version: '0'
|
218
218
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
219
219
|
requirements:
|
220
|
-
- -
|
220
|
+
- - ">="
|
221
221
|
- !ruby/object:Gem::Version
|
222
222
|
version: '0'
|
223
223
|
requirements: []
|
224
224
|
rubyforge_project:
|
225
|
-
rubygems_version: 2.4.
|
225
|
+
rubygems_version: 2.4.8
|
226
226
|
signing_key:
|
227
227
|
specification_version: 4
|
228
228
|
summary: Gem for easy health check
|