forked from locaweb/heartcheck
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request locaweb#33 from locaweb/add-hash-return
Add a hash of hash response to Heartcheck
- Loading branch information
Showing
10 changed files
with
108 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module Heartcheck | ||
module Formatters | ||
class Base | ||
def format(checks) | ||
checks | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
module Heartcheck | ||
module Formatters | ||
class HashResponse | ||
def format(checks) | ||
checks.each_with_object({}) do |check, response| | ||
name = check.keys.first | ||
result = check.delete(name) | ||
|
||
response[name] = result.merge(check) | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
module Heartcheck | ||
VERSION = '2.0.0'.freeze | ||
VERSION = '2.1.0'.freeze | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
require 'spec_helper' | ||
|
||
describe Heartcheck::Formatters::Base do | ||
describe "#format" do | ||
let(:check_01) { {dummy1: {status: :ok}, time: 1100} } | ||
let(:check_02) { {dummy2: {status: :ok}, time: 100} } | ||
|
||
it "generates a list of with a hashes for every check" do | ||
expect(subject.format([check_01, check_02])).to be_eql([ | ||
{dummy1: {status: :ok}, time: 1100}, | ||
{dummy2: {status: :ok}, time: 100} | ||
]) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
require 'spec_helper' | ||
|
||
describe Heartcheck::Formatters::HashResponse do | ||
describe "#format" do | ||
let(:check_01) { {dummy1: {status: :ok}, time: 1100} } | ||
let(:check_02) { {dummy2: {status: :ok}, time: 100} } | ||
|
||
it "generates a single hash with every check as a key" do | ||
expect(subject.format([check_01, check_02])).to be_eql({ | ||
dummy1: {status: :ok, time: 1100}, | ||
dummy2: {status: :ok, time: 100} | ||
}) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters