cronitor 2.0.0 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.rubocop.yml +15 -0
- data/.travis.yml +2 -0
- data/Gemfile +2 -0
- data/README.md +23 -17
- data/Rakefile +2 -0
- data/bin/console +1 -0
- data/cronitor.gemspec +8 -6
- data/lib/cronitor.rb +12 -12
- data/lib/cronitor/error.rb +2 -0
- data/lib/cronitor/version.rb +3 -1
- metadata +26 -26
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 1f6ea3528a80a4d2cb84314c86bb5f55431706aa46c9a5ca787860e8823f7bbd
|
4
|
+
data.tar.gz: 3467ef223aafddbab324b924fdc5552922f12310f959d32b7137eedf2ea42b98
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a54a8268d276563c0c90cc6101ccf7db4e6aa725568b08bd7581c4d7c745fee78e5245ad51e4ac3d752370048bf09151b315f5eb3c829c345f1c81e9e1ff8fbf
|
7
|
+
data.tar.gz: 8db8d9075d2daf231b54dbc2d0276448e5e39e07e0a9996ff8d8087e65f20971e105344d75f4b36812fd8a549d0f477a9dc78fd6231234f4cb932f5f182d76ed
|
data/.rubocop.yml
ADDED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Cronitor
|
2
2
|
|
3
|
-
[![Travis](https://img.shields.io/travis/evertrue/cronitor.svg)](https://
|
3
|
+
[![Travis](https://img.shields.io/travis/evertrue/cronitor.svg)](https://travis-ci.org/evertrue/cronitor)
|
4
4
|
[![Gem Version](https://badge.fury.io/rb/cronitor.svg)](https://badge.fury.io/rb/cronitor)
|
5
5
|
|
6
6
|
[Cronitor](https://cronitor.io/) is a service for heartbeat-style monitoring of just about anything that can send an HTTP request.
|
@@ -29,11 +29,16 @@ Or install it yourself as:
|
|
29
29
|
|
30
30
|
A Cronitor monitor (hereafter referred to only as a monitor for brevity) is created if it does not already exist, and its ID returned.
|
31
31
|
|
32
|
+
Please see the [Cronitor Monitor API docs](https://cronitor.io/docs/monitor-api) for details of all the possible monitor options.
|
33
|
+
|
34
|
+
Example of creating a heartbeat monitor:
|
35
|
+
|
32
36
|
```ruby
|
33
37
|
require 'cronitor'
|
34
38
|
|
35
39
|
monitor_options = {
|
36
40
|
name: 'My Fancy Monitor',
|
41
|
+
type: 'heartbeat', # Optional: the gem defaults to this; the other value, 'healthcheck', is not yet supported by this gem
|
37
42
|
notifications: {
|
38
43
|
emails: ['test@example.com'],
|
39
44
|
slack: [],
|
@@ -43,29 +48,21 @@ monitor_options = {
|
|
43
48
|
},
|
44
49
|
rules: [
|
45
50
|
{
|
46
|
-
rule_type: '
|
47
|
-
|
48
|
-
|
51
|
+
rule_type: 'run_ping_not_received',
|
52
|
+
value: 5,
|
53
|
+
time_unit: 'seconds'
|
49
54
|
}
|
50
55
|
],
|
51
56
|
note: 'A human-friendly description of this monitor'
|
52
57
|
}
|
58
|
+
|
59
|
+
# The token parameter is optional; if omittted, ENV['CRONITOR_TOKEN'] will be used
|
53
60
|
my_monitor = Cronitor.new token: 'api_token', opts: monitor_options
|
54
61
|
```
|
55
62
|
|
56
|
-
|
63
|
+
### Updating an existing monitor
|
57
64
|
|
58
|
-
|
59
|
-
monitor_options = {
|
60
|
-
rules: [
|
61
|
-
{
|
62
|
-
rule_type: 'not_run_in',
|
63
|
-
duration: 5
|
64
|
-
time_unit: 'seconds',
|
65
|
-
human_readable: 'not_run_in 5 seconds'
|
66
|
-
}
|
67
|
-
],
|
68
|
-
```
|
65
|
+
Currently this gem does not support updating or deleting an existing monitor.
|
69
66
|
|
70
67
|
### Pinging a Monitor
|
71
68
|
|
@@ -79,7 +76,9 @@ my_monitor.ping 'fail', 'A short description of the failure'
|
|
79
76
|
|
80
77
|
### Pinging a monitor when you have a Cronitor code
|
81
78
|
|
82
|
-
You may already have the code for a monitor, in which case, the expense of `Cronitor.
|
79
|
+
You may already have the code for a monitor, in which case, the expense of `Cronitor.create` may seem unnecessary (since it makes an HTTP request to check if a monitor exists, and you already know it does).
|
80
|
+
|
81
|
+
Cronitor does not require a token for pinging a monitor unless you have enabled Ping API authentication in your account settings. At the moment, this gem does not support Ping API auth.
|
83
82
|
|
84
83
|
In that case:
|
85
84
|
|
@@ -102,3 +101,10 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
102
101
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
103
102
|
4. Push to the branch (`git push origin my-new-feature`)
|
104
103
|
5. Create a new Pull Request
|
104
|
+
|
105
|
+
## Release a new version
|
106
|
+
|
107
|
+
The `bump` gem makes this easy:
|
108
|
+
|
109
|
+
1. `rake bump:(major|minor|patch|pre)`
|
110
|
+
2. `rake release`
|
data/Rakefile
CHANGED
data/bin/console
CHANGED
data/cronitor.gemspec
CHANGED
@@ -1,4 +1,6 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
lib = File.expand_path('lib', __dir__)
|
2
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
5
|
require 'cronitor/version'
|
4
6
|
|
@@ -18,11 +20,11 @@ Gem::Specification.new do |spec|
|
|
18
20
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
21
|
spec.require_paths = ['lib']
|
20
22
|
|
21
|
-
spec.add_development_dependency '
|
22
|
-
spec.add_development_dependency '
|
23
|
-
spec.add_development_dependency 'rspec', '~> 3.3'
|
23
|
+
spec.add_development_dependency 'bump', '~> 0.1'
|
24
|
+
spec.add_development_dependency 'bundler'
|
24
25
|
spec.add_development_dependency 'pry', '~> 0.10'
|
25
|
-
spec.add_development_dependency '
|
26
|
+
spec.add_development_dependency 'rake'
|
27
|
+
spec.add_development_dependency 'rspec', '~> 3.3'
|
26
28
|
spec.add_development_dependency 'sinatra', '~> 2.0'
|
27
|
-
spec.add_development_dependency '
|
29
|
+
spec.add_development_dependency 'webmock', '~> 3.1'
|
28
30
|
end
|
data/lib/cronitor.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'cronitor/version'
|
2
4
|
require 'cronitor/error'
|
3
5
|
require 'json'
|
@@ -6,8 +8,8 @@ require 'uri'
|
|
6
8
|
|
7
9
|
class Cronitor
|
8
10
|
attr_accessor :token, :opts, :code
|
9
|
-
API_URL = 'https://cronitor.io/
|
10
|
-
PING_URL = 'https://cronitor.link'
|
11
|
+
API_URL = 'https://cronitor.io/v3'
|
12
|
+
PING_URL = 'https://cronitor.link'
|
11
13
|
|
12
14
|
def initialize(token: ENV['CRONITOR_TOKEN'], opts: {}, code: nil)
|
13
15
|
@token = token
|
@@ -24,8 +26,14 @@ class Cronitor
|
|
24
26
|
|
25
27
|
if @opts
|
26
28
|
@opts = symbolize_keys @opts
|
29
|
+
|
27
30
|
exists? @opts[:name] if @opts.key? :name
|
28
|
-
|
31
|
+
|
32
|
+
# README: Per Cronitor API v2, we need to specify a type. The "heartbeat"
|
33
|
+
# type corresponds to what the v1 API offered by default
|
34
|
+
# We allow other values to be injected, and let the API handle
|
35
|
+
# any errors.
|
36
|
+
@opts[:type] = 'heartbeat' unless @opts[:type]
|
29
37
|
end
|
30
38
|
|
31
39
|
create if @code.nil?
|
@@ -61,6 +69,7 @@ class Cronitor
|
|
61
69
|
return false unless response.is_a? Net::HTTPSuccess
|
62
70
|
|
63
71
|
@code = JSON.parse(response.body).fetch 'code'
|
72
|
+
@opts = JSON.parse(response.body)
|
64
73
|
|
65
74
|
true
|
66
75
|
end
|
@@ -81,15 +90,6 @@ class Cronitor
|
|
81
90
|
valid? response
|
82
91
|
end
|
83
92
|
|
84
|
-
def human_readable(rules)
|
85
|
-
rules.each do |rule|
|
86
|
-
unless rule[:human_readable]
|
87
|
-
rule[:human_readable] = "#{rule[:rule_type]} #{rule[:duration]} " \
|
88
|
-
"#{rule[:time_unit]}"
|
89
|
-
end
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
93
|
private
|
94
94
|
|
95
95
|
def valid?(response)
|
data/lib/cronitor/error.rb
CHANGED
data/lib/cronitor/version.rb
CHANGED
metadata
CHANGED
@@ -1,85 +1,85 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cronitor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeff Byrnes
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-02-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: bump
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '1
|
19
|
+
version: '0.1'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '1
|
26
|
+
version: '0.1'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: pry
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '0.10'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '0.10'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: rake
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '0
|
61
|
+
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - "
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '0
|
68
|
+
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: rspec
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '3.
|
75
|
+
version: '3.3'
|
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
|
-
version: '3.
|
82
|
+
version: '3.3'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: sinatra
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -95,19 +95,19 @@ dependencies:
|
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '2.0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
|
-
name:
|
98
|
+
name: webmock
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: '
|
103
|
+
version: '3.1'
|
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
|
-
version: '
|
110
|
+
version: '3.1'
|
111
111
|
description:
|
112
112
|
email:
|
113
113
|
- thejeffbyrnes@gmail.com
|
@@ -118,6 +118,7 @@ files:
|
|
118
118
|
- ".editorconfig"
|
119
119
|
- ".gitignore"
|
120
120
|
- ".rspec"
|
121
|
+
- ".rubocop.yml"
|
121
122
|
- ".travis.yml"
|
122
123
|
- Gemfile
|
123
124
|
- LICENSE.txt
|
@@ -147,8 +148,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
147
148
|
- !ruby/object:Gem::Version
|
148
149
|
version: '0'
|
149
150
|
requirements: []
|
150
|
-
|
151
|
-
rubygems_version: 2.6.13
|
151
|
+
rubygems_version: 3.1.2
|
152
152
|
signing_key:
|
153
153
|
specification_version: 4
|
154
154
|
summary: An interface for the Cronitor API
|