dboard 1.1.1 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +5 -1
- data/dboard.gemspec +2 -3
- data/lib/api.rb +22 -0
- data/lib/version.rb +1 -1
- data/spec/collector_spec.rb +3 -3
- data/spec/publisher_spec.rb +22 -3
- data/spec/spec_helper.rb +2 -1
- metadata +6 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7f55103d286932b6db32979de3f7716857da2ad42b7234681796fd9f814a9e09
|
4
|
+
data.tar.gz: 9ba897eddcbf09741ab43d07eb24d8da35071e7e4137e06c3be3afdf6bceaf46
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 76034350ee61d117fcc963d8789b20cfdfd308f4c602313e9fd15f2f833e311e2bc7cf517361b409ab58a4ccd4e8589df6985fdeaafc7f5f9c1045ae89002a4c
|
7
|
+
data.tar.gz: 9738a25264c457fb50af8b7d9e7a96f3c8bda68b19fae10b64ce505d6a3b0c30df9bb0521f682847f8bfa76b145ae99879373581b15b934c35ed670aa247fd7a
|
data/Gemfile
CHANGED
data/dboard.gemspec
CHANGED
@@ -17,10 +17,9 @@ Gem::Specification.new do |s|
|
|
17
17
|
s.files = `git ls-files`.split("\n")
|
18
18
|
s.require_paths = [ "lib" ]
|
19
19
|
|
20
|
+
s.add_dependency "dalli"
|
20
21
|
s.add_dependency "httparty"
|
21
|
-
s.add_dependency "rake"
|
22
22
|
s.add_dependency "json"
|
23
|
-
s.add_dependency "
|
23
|
+
s.add_dependency "rake"
|
24
24
|
s.add_dependency "sinatra"
|
25
|
-
s.add_development_dependency "rspec", "~> 3.9"
|
26
25
|
end
|
data/lib/api.rb
CHANGED
@@ -3,6 +3,7 @@ require File.expand_path(File.join(File.dirname(__FILE__), "collector.rb"))
|
|
3
3
|
require "digest/md5"
|
4
4
|
require "json"
|
5
5
|
require "httparty"
|
6
|
+
require "net_http_timeout_errors"
|
6
7
|
|
7
8
|
module Dboard
|
8
9
|
class Api
|
@@ -11,6 +12,27 @@ module Dboard
|
|
11
12
|
|
12
13
|
class Client
|
13
14
|
include HTTParty
|
15
|
+
|
16
|
+
def self.post(...)
|
17
|
+
with_retries { super }
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
private_class_method \
|
23
|
+
def self.with_retries
|
24
|
+
remaining_attempts = 3
|
25
|
+
|
26
|
+
begin
|
27
|
+
remaining_attempts -= 1
|
28
|
+
yield
|
29
|
+
rescue *NetHttpTimeoutErrors.all
|
30
|
+
raise if remaining_attempts == 0
|
31
|
+
|
32
|
+
sleep((ENV["RACK_ENV"] == "test") ? 0 : 5)
|
33
|
+
retry
|
34
|
+
end
|
35
|
+
end
|
14
36
|
end
|
15
37
|
|
16
38
|
def self.get(params)
|
data/lib/version.rb
CHANGED
data/spec/collector_spec.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require File.expand_path(File.join(File.dirname(__FILE__), "spec_helper"))
|
2
2
|
|
3
|
-
describe Dboard::Collector, "register_source" do
|
3
|
+
describe Dboard::Collector, ".register_source" do
|
4
4
|
before do
|
5
5
|
Dboard::Collector.instance.sources.clear
|
6
6
|
end
|
@@ -48,14 +48,14 @@ describe Dboard::Collector, "update_source" do
|
|
48
48
|
Dboard::Collector.instance.sources.clear
|
49
49
|
end
|
50
50
|
|
51
|
-
it "
|
51
|
+
it "collects and publishes data from sources" do
|
52
52
|
new_relic = double
|
53
53
|
allow(new_relic).to receive(:fetch).and_return({ db: "100%" })
|
54
54
|
expect(Dboard::Publisher).to receive(:publish).with(:new_relic, { db: "100%" })
|
55
55
|
Dboard::Collector.instance.update_source(:new_relic, new_relic)
|
56
56
|
end
|
57
57
|
|
58
|
-
it "
|
58
|
+
it "prints out debugging info" do
|
59
59
|
new_relic = double
|
60
60
|
allow(new_relic).to receive(:fetch).and_raise(Exception.new("some error"))
|
61
61
|
expect(Dboard::Collector.instance).to receive(:puts).twice
|
data/spec/publisher_spec.rb
CHANGED
@@ -1,12 +1,31 @@
|
|
1
1
|
require File.expand_path(File.join(File.dirname(__FILE__), "spec_helper"))
|
2
2
|
|
3
|
-
describe "Publisher", "publish" do
|
4
|
-
it "
|
3
|
+
describe "Publisher", ".publish" do
|
4
|
+
it "sends data to the dashboard server" do
|
5
5
|
expect(Dboard::Api::Client).to receive(:post).with("/sources/new_relic", body: { data: { db: "80%" }.to_json }, timeout: 10000)
|
6
6
|
Dboard::Publisher.publish(:new_relic, { db: "80%" })
|
7
7
|
end
|
8
8
|
|
9
|
-
it "
|
9
|
+
it "retries network errors" do
|
10
|
+
stub_request(:post, "http://api.example/sources/new_relic").
|
11
|
+
to_timeout.times(2).
|
12
|
+
to_return({ body: "OK!" })
|
13
|
+
|
14
|
+
Dboard::Publisher.publish(:new_relic, {})
|
15
|
+
end
|
16
|
+
|
17
|
+
it "raises network errors if we run out of retries" do
|
18
|
+
stub_request(:post, "http://api.example/sources/new_relic").
|
19
|
+
to_timeout.times(3).
|
20
|
+
to_return({ body: "OK!" })
|
21
|
+
|
22
|
+
expect {
|
23
|
+
Dboard::Publisher.publish(:new_relic, {})
|
24
|
+
}.to raise_error(Net::OpenTimeout)
|
25
|
+
end
|
26
|
+
|
27
|
+
# 2021-12-07: No idea why we've treated this one specially, but keeping it for now.
|
28
|
+
it "logs socket errors if we run out of retries" do
|
10
29
|
expect(Dboard::Api::Client).to receive(:post).and_raise(SocketError.new("failed to connect"))
|
11
30
|
expect(Dboard::Publisher).to receive(:puts).with("SocketError: failed to connect")
|
12
31
|
Dboard::Publisher.publish(:new_relic, {})
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dboard
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joakim Kolsjö
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-12-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: dalli
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
@@ -25,7 +25,7 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: httparty
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
@@ -53,7 +53,7 @@ dependencies:
|
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: rake
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - ">="
|
@@ -80,20 +80,6 @@ dependencies:
|
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: rspec
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - "~>"
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: '3.9'
|
90
|
-
type: :development
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - "~>"
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: '3.9'
|
97
83
|
description: Dashboard framework
|
98
84
|
email:
|
99
85
|
- joakim.kolsjo@gmail.com
|
@@ -139,7 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
139
125
|
- !ruby/object:Gem::Version
|
140
126
|
version: '0'
|
141
127
|
requirements: []
|
142
|
-
rubygems_version: 3.2.
|
128
|
+
rubygems_version: 3.2.32
|
143
129
|
signing_key:
|
144
130
|
specification_version: 4
|
145
131
|
summary: Dashboard framework
|