dboard 2.0.3 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +5 -2
- data/dboard.gemspec +1 -1
- data/lib/api.rb +19 -3
- data/lib/collector.rb +4 -4
- data/lib/version.rb +1 -1
- data/spec/collector_spec.rb +6 -7
- data/spec/publisher_spec.rb +6 -6
- data/spec/spec_helper.rb +4 -3
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5b304b24b1a81668338947ec710dac13e40154546ef7223bbdd1c0ccf85707d1
|
4
|
+
data.tar.gz: 0b541c61c457f728d1e07e92ddc46579e25f9e228643ab605b7dda5f8410ccbb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 777077451031641618207a7e6e90e50a8eda8cd50e87f142d75826fd2ac5bbe970da2b9fbdd915d8739750274a5ab177b03aeaa77e2cbeac5044b4e3b8d88600
|
7
|
+
data.tar.gz: 3d3b5d8f1920e6ef2ec58c0374aaaebaeb4e6caf329e8da17e2779a909405f7f60ef26c1cd77df63c50a815f897bd220f7d9b4a941a5c50d78104876cd6be29f
|
data/.github/workflows/ci.yml
CHANGED
@@ -13,10 +13,13 @@ jobs:
|
|
13
13
|
|
14
14
|
strategy:
|
15
15
|
matrix:
|
16
|
-
ruby-version:
|
16
|
+
ruby-version:
|
17
|
+
- 3.1
|
18
|
+
- "3.0"
|
19
|
+
- 2.7
|
17
20
|
|
18
21
|
steps:
|
19
|
-
- uses: actions/checkout@
|
22
|
+
- uses: actions/checkout@v3
|
20
23
|
- name: Set up Ruby ${{ matrix.ruby-version }}
|
21
24
|
uses: ruby/setup-ruby@v1
|
22
25
|
with:
|
data/dboard.gemspec
CHANGED
@@ -17,10 +17,10 @@ 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 "net_http_timeout_errors"
|
21
20
|
s.add_dependency "dalli"
|
22
21
|
s.add_dependency "httparty"
|
23
22
|
s.add_dependency "json"
|
23
|
+
s.add_dependency "net_http_timeout_errors"
|
24
24
|
s.add_dependency "rake"
|
25
25
|
s.add_dependency "sinatra"
|
26
26
|
end
|
data/lib/api.rb
CHANGED
@@ -11,10 +11,26 @@ module Dboard
|
|
11
11
|
@@version = nil
|
12
12
|
|
13
13
|
class Client
|
14
|
-
|
14
|
+
class << self
|
15
|
+
attr_accessor :clients
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.endpoints=(endpoints)
|
19
|
+
self.clients = endpoints.map { |config|
|
20
|
+
Class.new {
|
21
|
+
include HTTParty
|
22
|
+
base_uri config.fetch(:base_uri)
|
23
|
+
basic_auth *config.fetch(:basic_auth)
|
24
|
+
}
|
25
|
+
}
|
26
|
+
end
|
15
27
|
|
16
|
-
def self.post(
|
17
|
-
with_retries {
|
28
|
+
def self.post(url, opts)
|
29
|
+
with_retries {
|
30
|
+
self.clients.each do |client|
|
31
|
+
client.post(url, opts)
|
32
|
+
end
|
33
|
+
}
|
18
34
|
end
|
19
35
|
|
20
36
|
private
|
data/lib/collector.rb
CHANGED
@@ -7,16 +7,16 @@ module Dboard
|
|
7
7
|
|
8
8
|
attr_reader :sources
|
9
9
|
|
10
|
-
def self.register_source(key,
|
11
|
-
|
10
|
+
def self.register_source(key, source_instance)
|
11
|
+
instance.register_source(key, source_instance)
|
12
12
|
end
|
13
13
|
|
14
14
|
def self.register_after_update_callback(callback)
|
15
|
-
|
15
|
+
instance.register_after_update_callback(callback)
|
16
16
|
end
|
17
17
|
|
18
18
|
def self.register_error_callback(callback)
|
19
|
-
|
19
|
+
instance.register_error_callback(callback)
|
20
20
|
end
|
21
21
|
|
22
22
|
def self.start
|
data/lib/version.rb
CHANGED
data/spec/collector_spec.rb
CHANGED
@@ -5,17 +5,17 @@ describe Dboard::Collector, ".register_source" do
|
|
5
5
|
Dboard::Collector.instance.sources.clear
|
6
6
|
end
|
7
7
|
|
8
|
+
let(:new_relic) { double(:new_relic) }
|
9
|
+
let(:callback) { double(:callback) }
|
10
|
+
|
8
11
|
it "can register a source" do
|
9
|
-
new_relic = double
|
10
12
|
allow(new_relic).to receive(:update_interval).and_return(5)
|
11
13
|
Dboard::Collector.register_source :new_relic, new_relic
|
12
14
|
expect(Dboard::Collector.instance.sources).to eq({ new_relic: new_relic })
|
13
15
|
end
|
14
16
|
|
15
17
|
it "can register an after update callback" do
|
16
|
-
new_relic = double
|
17
18
|
allow(new_relic).to receive(:fetch).and_return({ db: "100%" })
|
18
|
-
callback = double
|
19
19
|
Dboard::Collector.register_after_update_callback callback
|
20
20
|
|
21
21
|
expect(callback).to receive(:call)
|
@@ -27,10 +27,9 @@ describe Dboard::Collector, ".register_source" do
|
|
27
27
|
end
|
28
28
|
|
29
29
|
it "can register an error callback" do
|
30
|
-
new_relic = double
|
31
30
|
error = RuntimeError.new("error")
|
32
31
|
allow(new_relic).to receive(:fetch).and_raise(error)
|
33
|
-
|
32
|
+
|
34
33
|
Dboard::Collector.register_error_callback callback
|
35
34
|
|
36
35
|
expect(callback).to receive(:call).with(error)
|
@@ -48,15 +47,15 @@ describe Dboard::Collector, "update_source" do
|
|
48
47
|
Dboard::Collector.instance.sources.clear
|
49
48
|
end
|
50
49
|
|
50
|
+
let(:new_relic) { double(:new_relic) }
|
51
|
+
|
51
52
|
it "collects and publishes data from sources" do
|
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
58
|
it "prints out debugging info" do
|
59
|
-
new_relic = double
|
60
59
|
allow(new_relic).to receive(:fetch).and_raise(Exception.new("some error"))
|
61
60
|
expect(Dboard::Collector.instance).to receive(:puts).twice
|
62
61
|
Dboard::Collector.instance.update_source(:new_relic, new_relic)
|
data/spec/publisher_spec.rb
CHANGED
@@ -7,17 +7,17 @@ describe "Publisher", ".publish" do
|
|
7
7
|
end
|
8
8
|
|
9
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!" })
|
10
|
+
stub_request(:post, "http://api.example/sources/new_relic")
|
11
|
+
.to_timeout.times(2)
|
12
|
+
.to_return({ body: "OK!" })
|
13
13
|
|
14
14
|
Dboard::Publisher.publish(:new_relic, {})
|
15
15
|
end
|
16
16
|
|
17
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!" })
|
18
|
+
stub_request(:post, "http://api.example/sources/new_relic")
|
19
|
+
.to_timeout.times(3)
|
20
|
+
.to_return({ body: "OK!" })
|
21
21
|
|
22
22
|
expect {
|
23
23
|
Dboard::Publisher.publish(:new_relic, {})
|
data/spec/spec_helper.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
require "rspec"
|
2
|
-
require
|
2
|
+
require "webmock/rspec"
|
3
3
|
|
4
4
|
ENV["RACK_ENV"] ||= "test"
|
5
5
|
ENV["API_URL"] = "http://api.example"
|
@@ -8,5 +8,6 @@ ENV["API_PASSWORD"] = "test"
|
|
8
8
|
|
9
9
|
require File.expand_path(File.join(File.dirname(__FILE__), "../lib/dboard"))
|
10
10
|
|
11
|
-
Dboard::Api::Client.
|
12
|
-
|
11
|
+
Dboard::Api::Client.endpoints = [
|
12
|
+
{ base_uri: ENV["API_URL"], basic_auth: [ ENV["API_USER"], ENV["API_PASSWORD"] ] },
|
13
|
+
]
|
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: 3.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:
|
11
|
+
date: 2024-06-11 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
|
- - ">="
|
@@ -39,7 +39,7 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: json
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
@@ -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: net_http_timeout_errors
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - ">="
|
@@ -139,7 +139,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
139
139
|
- !ruby/object:Gem::Version
|
140
140
|
version: '0'
|
141
141
|
requirements: []
|
142
|
-
rubygems_version: 3.
|
142
|
+
rubygems_version: 3.5.9
|
143
143
|
signing_key:
|
144
144
|
specification_version: 4
|
145
145
|
summary: Dashboard framework
|