-
Notifications
You must be signed in to change notification settings - Fork 116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/http check #156
Open
lremes
wants to merge
55
commits into
WeAreFarmGeek:master
Choose a base branch
from
lremes:feature/http-check
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Feature/http check #156
Changes from 4 commits
Commits
Show all changes
55 commits
Select commit
Hold shift + click to select a range
bdd5cd5
Add HTTP check type
94bb8c6
Add register_http to access methods
37046f6
Fix travis errors where applicable
aa8bbb7
Updated README and Changelog
08b339f
Use `PUT` as the verb for deregistering a service. (#158)
blanquer 78c8ab8
Suggest using X-Consul-Token for ACLs
sixfeetover 575c866
Move ApiOptions methods into Restclient
Annih ec3be3a
Allow to pass ::Diplomat::Configuration object to the Rest Client
Annih 243b9af
Specify StandardError on few rescue statements to make rubocop happy
Annih d6b2975
Support for tokens when registering/unregistering entities on Agent
pierresouchay 70a71b0
Fixed rubocop warnings + Fixed rubocop version
pierresouchay 0b70f62
Depreciate Ruby < 2.3 in travis tests
pierresouchay b320048
Merge pull request #166 from criteo-forks/token_on_registration_dereg…
pierresouchay d753006
Added new unit test for service registration with token
pierresouchay 4f39bfb
New version 2.0.3 with token support for agent registration
pierresouchay 28d41db
Merge pull request #163 from criteo-forks/non_static_configuration
pierresouchay a2b4180
Fixed minor rubocop style warnings after last PR #163
pierresouchay 71c921b
README: Drop defunct badge, use SVG
olleolleolle 985f4b8
CI: Update to current set of Rubies
olleolleolle 621ae1c
Merge pull request #169 from olleolleolle/patch-1
pierresouchay 9acebcb
Merge pull request #160 from sixfeetover/patch-1
pierresouchay 19d9813
Travis: Exempt 2.6.0-rc2 from matrix
olleolleolle 55b7db7
CI: Drop matrix allow_failures - 2.6.0-rc2 passes
olleolleolle 6e1aa66
Merge pull request #170 from olleolleolle/patch-2
pierresouchay e327f81
Added automatic publication of GEM on a branch
pierresouchay 13dacc0
Use bundle v2.0+
pierresouchay acd356e
Do not build with ruby 2.2.x in travis build
pierresouchay e67773f
Bump version to 2.0.4
pierresouchay 688a6c9
Use correct verbs for Check methods.
pierresouchay e388ef0
Updated changelog
pierresouchay 1617f67
Added new link to https://rubygems.org/gems/diplomat
pierresouchay f45b152
Use json_pure if ruby < 1.9.3 to avoid using a compiler
pierresouchay 1fb4560
Updated CHANGELOG.md
pierresouchay 9e90b93
Support for Output in TTL checks
kinnalru 9f332f5
Merge pull request #178 from RnD-Soft/master
pierresouchay 2412de1
Diplomat release 2.0.5 Bugfix release
pierresouchay 95bee47
Updated travis versions of Ruby to use stable 2.6.1
pierresouchay 3229669
simpler convert_to_hash function
ef57278
Merge pull request #176 from robmbrooks/master
pierresouchay 0f80781
Updated changelog
pierresouchay 35c369f
Enable configuration override on each consul api call
tionebsalocin ff4e2f8
Merge pull request #179 from tionebsalocin/options-everywhere
pierresouchay 588eaf0
Adding support for KV flags during lock acquisition.
dudemcbacon 830f1fe
Merge pull request #180 from dudemcbacon/master
pierresouchay 0880966
Avoid having a HTTP 302 if key requested starts with '/' (#181)
pierresouchay f931728
Add some options example in the documentation
tionebsalocin bf5a26b
Changelog for release 2.1.0
pierresouchay 5297bb9
fix syntax error colon instead of =>
Oribracha d415447
BUGFIX release 2.1.1, fixes #186 using #185
pierresouchay 8458296
Bump version number to 2.1.1
pierresouchay fc22b27
Fix raw data usage in kv
tionebsalocin 5f57ca9
BUGFIX release 2.1.2
pierresouchay 34c045f
Add HTTP check type
6c3fc6b
register_http check name parameter is mandatory
a8df947
Merge branch 'feature/http-check' of https://github.com/lremes/diplom…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
# Changelog | ||
|
||
## 2.0.3 | ||
|
||
- 2017-10-06 Lars Remes [[email protected]][1] Support HTTP service checks | ||
|
||
## 2.0.2 | ||
|
||
- 2017-08-23 Trevor Wood [[email protected]][1] Revert the change to single values | ||
|
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
module Diplomat | ||
# Methods for interacting with the Consul check API endpoint | ||
class Check < Diplomat::RestClient | ||
@access_methods = %i[checks register_script register_ttl | ||
@access_methods = %i[checks register_http register_script register_ttl | ||
deregister pass warn fail] | ||
|
||
# Get registered checks | ||
|
@@ -11,7 +11,27 @@ def checks | |
JSON.parse(ret.body) | ||
end | ||
|
||
# Register a check | ||
# Register a HTTP check | ||
# @param check_id [String] the unique id of the check | ||
# @param name [String] the name | ||
# @param notes [String] notes about the check | ||
# @param script [String] command to be run for check | ||
# @param interval [String] frequency (with units) of the check execution | ||
# @param ttl [String] time (with units) to mark a check down | ||
# @return [Integer] Status code | ||
# | ||
def register_http(check_id, name, notes, url, method, header, interval) | ||
ret = @conn.put do |req| | ||
req.url '/v1/agent/check/register' | ||
req.body = JSON.generate( | ||
'ID' => check_id, 'Name' => name, 'Notes' => notes, 'HTTP' => url, 'Method' => method, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. timeout might be interesting as well |
||
'Header' => header, 'Interval' => interval | ||
) | ||
end | ||
ret.status == 200 | ||
end | ||
|
||
# Register a script check | ||
# @param check_id [String] the unique id of the check | ||
# @param name [String] the name | ||
# @param notes [String] notes about the check | ||
|
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 |
---|---|---|
|
@@ -32,6 +32,12 @@ | |
expect(check.register_script('foobar-1', 'Foobar', 'Foobar test', '/script/test', '10s')).to eq(true) | ||
end | ||
|
||
it 'register_http' do | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please also test wrong value for parameters: example:
|
||
faraday.stub(:put).and_return(OpenStruct.new(body: '', status: 200)) | ||
check = Diplomat::Check.new(faraday) | ||
expect(check.register_http('foobar-1', 'Foobar', 'Foobar test', 'localhost', 'GET', {}, '10s')).to eq(true) | ||
end | ||
|
||
it 'register_ttl' do | ||
faraday.stub(:put).and_return(OpenStruct.new(body: '', status: 200)) | ||
check = Diplomat::Check.new(faraday) | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are lots of parameters to this function, would you mind using named parameters instead ?
I would rather use this signature:
since both interval and url are mandatory (see https://www.consul.io/api/agent/check.html#register-check )
It would allow to use only the provided parameters.
It also lacks
header
in ruby documentation as well as calling itheaders
would probably be more accurate (and specify type)