crontinel 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +2 -6
- data/lib/crontinel/version.rb +1 -1
- data/lib/crontinel.rb +50 -37
- metadata +3 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 18bb86bacae7e02a65730ce4ff84bb7bbf231a6e92d19378a8ed520dc170ff3b
|
|
4
|
+
data.tar.gz: 0e1ff726c6e9b11ce2aa76a2a38b8828ec5ce64c345583157f3d3060930cfb32
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 187e1174b555e0467a08c10e6cfc77c7456035323e04ce49265d8d9a94e0ce209d0ab0b28c9d5b98429d85ac963ac9eb6b8db3688559a8f5a68955d81e6321dc
|
|
7
|
+
data.tar.gz: 8d899142abd4ec21c1db01cb2ab430b1ad6a2523d8925d40ce5a88e1301490b3d1773a4c6b9f67bc02f5854c0cc316d34b35ee5ce4953e6ddad529f38e037482
|
data/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes will be documented in this file.
|
|
4
4
|
|
|
5
|
+
## [0.1.1] - 2026-11-17
|
|
6
|
+
|
|
7
|
+
- `Crontinel.client` reads `CRONTINEL_API_KEY` and `CRONTINEL_API_URL` when no argument is given
|
|
8
|
+
- `task_started` no longer records a finished run; it sends nothing
|
|
9
|
+
- `task_failed` always sends exit code 1
|
|
10
|
+
|
|
5
11
|
## [0.1.0] - 2026-04-18
|
|
6
12
|
|
|
7
13
|
- Initial release
|
data/README.md
CHANGED
|
@@ -23,12 +23,9 @@ gem install crontinel
|
|
|
23
23
|
```ruby
|
|
24
24
|
require "crontinel"
|
|
25
25
|
|
|
26
|
-
# Configure with your API key
|
|
26
|
+
# Configure with your API key (or set CRONTINEL_API_KEY and call Crontinel.client)
|
|
27
27
|
client = Crontinel.client(api_key: "your_api_key_here")
|
|
28
28
|
|
|
29
|
-
# Record a cron job starting
|
|
30
|
-
client.task_started(name: "send-daily-summary")
|
|
31
|
-
|
|
32
29
|
# Do your work...
|
|
33
30
|
result = send_daily_summary
|
|
34
31
|
|
|
@@ -42,7 +39,6 @@ client.task_finished(name: "send-daily-summary", duration_ms: 520)
|
|
|
42
39
|
client = Crontinel.client(api_key: ENV["CRONTINEL_API_KEY"])
|
|
43
40
|
|
|
44
41
|
begin
|
|
45
|
-
client.task_started(name: "process-invoices")
|
|
46
42
|
process_invoices
|
|
47
43
|
client.task_finished(name: "process-invoices", duration_ms: 3200)
|
|
48
44
|
rescue => e
|
|
@@ -87,7 +83,7 @@ Create a new Crontinel client.
|
|
|
87
83
|
|
|
88
84
|
### `#task_started(name:, output: nil)`
|
|
89
85
|
|
|
90
|
-
|
|
86
|
+
Does nothing. Crontinel records a run when it ends, so call `task_finished` or `task_failed`.
|
|
91
87
|
|
|
92
88
|
### `#task_finished(name:, output: nil, duration_ms: nil)`
|
|
93
89
|
|
data/lib/crontinel/version.rb
CHANGED
data/lib/crontinel.rb
CHANGED
|
@@ -81,6 +81,8 @@ module Crontinel
|
|
|
81
81
|
|
|
82
82
|
def initialize(api_key: nil, endpoint: nil)
|
|
83
83
|
@config = Config.new
|
|
84
|
+
@config.api_key = ENV.fetch("CRONTINEL_API_KEY", nil)
|
|
85
|
+
@config.endpoint = ENV["CRONTINEL_API_URL"] if ENV["CRONTINEL_API_URL"]
|
|
84
86
|
@config.api_key = api_key if api_key
|
|
85
87
|
@config.endpoint = endpoint if endpoint
|
|
86
88
|
yield @config if block_given?
|
|
@@ -92,59 +94,59 @@ module Crontinel
|
|
|
92
94
|
# Record a scheduled task completing successfully
|
|
93
95
|
def task_finished(name:, output: nil, duration_ms: nil)
|
|
94
96
|
mcp_call("notify/schedule_run", {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
97
|
+
command: name,
|
|
98
|
+
exit_code: 0,
|
|
99
|
+
duration_ms: duration_ms,
|
|
100
|
+
output: output,
|
|
101
|
+
ran_at: Time.now.utc.iso8601(3),
|
|
102
|
+
app: "ruby"
|
|
103
|
+
})
|
|
102
104
|
end
|
|
103
105
|
|
|
104
106
|
# Record a scheduled task failing
|
|
105
107
|
def task_failed(name:, error: nil, output: nil, duration_ms: nil)
|
|
106
108
|
mcp_call("notify/schedule_run", {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
109
|
+
command: name,
|
|
110
|
+
exit_code: 1,
|
|
111
|
+
duration_ms: duration_ms,
|
|
112
|
+
output: output || error,
|
|
113
|
+
ran_at: Time.now.utc.iso8601(3),
|
|
114
|
+
app: "ruby"
|
|
115
|
+
})
|
|
114
116
|
end
|
|
115
117
|
|
|
116
118
|
# Record a queue worker heartbeat / processed batch
|
|
117
|
-
def worker_heartbeat(name:, status: "running", jobs_processed: nil, jobs_failed: nil, memory_mb: nil)
|
|
119
|
+
def worker_heartbeat(name:, status: "running", jobs_processed: nil, jobs_failed: nil, memory_mb: nil) # rubocop:disable Lint/UnusedMethodArgument
|
|
118
120
|
mcp_call("notify/queue_processed", {
|
|
119
121
|
queue: name,
|
|
120
122
|
processed: jobs_processed || 0,
|
|
121
123
|
failed: jobs_failed || 0,
|
|
122
124
|
ran_at: Time.now.utc.iso8601(3),
|
|
123
|
-
app: "ruby"
|
|
125
|
+
app: "ruby"
|
|
124
126
|
}.compact)
|
|
125
127
|
end
|
|
126
128
|
|
|
127
129
|
# Send a custom event
|
|
128
130
|
def event(key:, message:, state: "info", metadata: {})
|
|
129
131
|
mcp_call("notify/event", {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
132
|
+
key: key,
|
|
133
|
+
message: message,
|
|
134
|
+
state: state,
|
|
135
|
+
metadata: metadata,
|
|
136
|
+
ran_at: Time.now.utc.iso8601(3),
|
|
137
|
+
app: "ruby"
|
|
138
|
+
})
|
|
137
139
|
end
|
|
138
140
|
|
|
139
141
|
# Send a Horizon snapshot
|
|
140
142
|
def horizon_snapshot(supervisors:, failed_jobs_per_minute: 0, paused: false)
|
|
141
143
|
mcp_call("notify/horizon_snapshot", {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
144
|
+
supervisors: supervisors,
|
|
145
|
+
failed_jobs_per_minute: failed_jobs_per_minute,
|
|
146
|
+
paused: paused,
|
|
147
|
+
ran_at: Time.now.utc.iso8601(3),
|
|
148
|
+
app: "ruby"
|
|
149
|
+
})
|
|
148
150
|
end
|
|
149
151
|
|
|
150
152
|
# ── Query methods (uses MCP tools/call) ───────────────────
|
|
@@ -152,19 +154,19 @@ module Crontinel
|
|
|
152
154
|
# List all scheduled jobs
|
|
153
155
|
def scheduled_jobs
|
|
154
156
|
result = mcp_call("tools/call", { name: "list_scheduled_jobs", arguments: {} })
|
|
155
|
-
(result
|
|
157
|
+
parse_content(result).map { |r| TaskRun.new(r) }
|
|
156
158
|
end
|
|
157
159
|
|
|
158
160
|
# Get status for a specific cron command
|
|
159
161
|
def cron_status(command:)
|
|
160
162
|
result = mcp_call("tools/call", { name: "get_cron_status", arguments: { command: command } })
|
|
161
|
-
(result
|
|
163
|
+
parse_content(result).first
|
|
162
164
|
end
|
|
163
165
|
|
|
164
166
|
# List recent alerts
|
|
165
167
|
def recent_alerts(hours: 24)
|
|
166
168
|
result = mcp_call("tools/call", { name: "list_recent_alerts", arguments: { hours: hours } })
|
|
167
|
-
(result
|
|
169
|
+
parse_content(result)
|
|
168
170
|
end
|
|
169
171
|
|
|
170
172
|
# Check if Crontinel is reachable (direct HTTP, not MCP)
|
|
@@ -176,8 +178,10 @@ module Crontinel
|
|
|
176
178
|
end
|
|
177
179
|
|
|
178
180
|
# ── Backward-compatible aliases ───────────────────────────
|
|
179
|
-
|
|
180
|
-
|
|
181
|
+
# Crontinel records a run when it ends, so there is nothing to send at the start.
|
|
182
|
+
# Kept so existing calls keep working; it used to record a finished run by mistake.
|
|
183
|
+
def task_started(name: nil, output: nil) # rubocop:disable Lint/UnusedMethodArgument
|
|
184
|
+
nil
|
|
181
185
|
end
|
|
182
186
|
|
|
183
187
|
def task_runs(name:, limit: 10)
|
|
@@ -190,15 +194,23 @@ module Crontinel
|
|
|
190
194
|
|
|
191
195
|
private
|
|
192
196
|
|
|
197
|
+
def parse_content(result)
|
|
198
|
+
(result["content"] || []).flat_map do |c|
|
|
199
|
+
JSON.parse(c["text"])
|
|
200
|
+
rescue StandardError
|
|
201
|
+
[]
|
|
202
|
+
end
|
|
203
|
+
end
|
|
204
|
+
|
|
193
205
|
# Unified MCP JSON-RPC call against /api/mcp
|
|
194
|
-
def mcp_call(method, params = {})
|
|
206
|
+
def mcp_call(method, params = {}) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
|
195
207
|
uri = URI("#{@config.endpoint}/api/mcp")
|
|
196
208
|
|
|
197
209
|
body = {
|
|
198
210
|
jsonrpc: "2.0",
|
|
199
211
|
id: (Time.now.to_f * 1000).to_i,
|
|
200
212
|
method: method,
|
|
201
|
-
params: params
|
|
213
|
+
params: params
|
|
202
214
|
}
|
|
203
215
|
|
|
204
216
|
req = Net::HTTP::Post.new(uri)
|
|
@@ -219,6 +231,7 @@ module Crontinel
|
|
|
219
231
|
if data["error"]
|
|
220
232
|
raise NetworkError, "Crontinel RPC error: #{data["error"]["code"]}: #{data["error"]["message"]}"
|
|
221
233
|
end
|
|
234
|
+
|
|
222
235
|
data["result"]
|
|
223
236
|
else
|
|
224
237
|
raise NetworkError, "Crontinel API error: #{response.code} #{response.message}"
|
|
@@ -265,7 +278,7 @@ module Crontinel
|
|
|
265
278
|
yield config
|
|
266
279
|
config
|
|
267
280
|
end
|
|
268
|
-
|
|
281
|
+
alias setup configure
|
|
269
282
|
|
|
270
283
|
def config
|
|
271
284
|
@config ||= Configuration.new
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: crontinel
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Harun R Rayhan
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies: []
|
|
13
12
|
description: |
|
|
14
13
|
Crontinel monitors your cron jobs, background workers, and scheduled tasks.
|
|
@@ -33,7 +32,6 @@ metadata:
|
|
|
33
32
|
source_code_uri: https://github.com/crontinel/ruby
|
|
34
33
|
changelog_uri: https://github.com/crontinel/ruby/blob/main/CHANGELOG.md
|
|
35
34
|
bug_tracker_uri: https://github.com/crontinel/ruby/issues
|
|
36
|
-
post_install_message:
|
|
37
35
|
rdoc_options: []
|
|
38
36
|
require_paths:
|
|
39
37
|
- lib
|
|
@@ -48,8 +46,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
48
46
|
- !ruby/object:Gem::Version
|
|
49
47
|
version: '0'
|
|
50
48
|
requirements: []
|
|
51
|
-
rubygems_version:
|
|
52
|
-
signing_key:
|
|
49
|
+
rubygems_version: 4.0.23
|
|
53
50
|
specification_version: 4
|
|
54
51
|
summary: Crontinel monitoring SDK for Ruby — track cron jobs and background workers
|
|
55
52
|
test_files: []
|