cosmonats 0.8.0 → 0.10.0
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/README.md +73 -22
- data/lib/cosmo/active_job/adapter.rb +2 -0
- data/lib/cosmo/active_job/executor.rb +7 -0
- data/lib/cosmo/active_job/options.rb +6 -0
- data/lib/cosmo/api/batch.rb +26 -0
- data/lib/cosmo/api/counter.rb +52 -4
- data/lib/cosmo/api/cron/entry.rb +34 -20
- data/lib/cosmo/api/cron.rb +24 -10
- data/lib/cosmo/api/job.rb +15 -1
- data/lib/cosmo/api/kv.rb +141 -12
- data/lib/cosmo/api/registry.rb +47 -6
- data/lib/cosmo/api/stats/jobs.rb +84 -0
- data/lib/cosmo/api/stats/metrics.rb +20 -9
- data/lib/cosmo/api/stats/processes.rb +27 -11
- data/lib/cosmo/api/stats/totals.rb +1 -0
- data/lib/cosmo/api/stats.rb +58 -7
- data/lib/cosmo/api/stream.rb +73 -24
- data/lib/cosmo/batch/callback.rb +5 -0
- data/lib/cosmo/batch/dispatcher.rb +4 -4
- data/lib/cosmo/batch.rb +34 -11
- data/lib/cosmo/cli.rb +6 -0
- data/lib/cosmo/client.rb +217 -23
- data/lib/cosmo/config/cosmo.yml +1 -0
- data/lib/cosmo/config/settings.rb +4 -0
- data/lib/cosmo/config.rb +58 -10
- data/lib/cosmo/engine.rb +28 -1
- data/lib/cosmo/heartbeat.rb +12 -3
- data/lib/cosmo/http_server/handler.rb +5 -0
- data/lib/cosmo/http_server/health.rb +2 -0
- data/lib/cosmo/http_server/ping.rb +2 -0
- data/lib/cosmo/http_server.rb +8 -0
- data/lib/cosmo/job/data.rb +12 -1
- data/lib/cosmo/job/enqueuer.rb +100 -1
- data/lib/cosmo/job/limit.rb +5 -1
- data/lib/cosmo/job/processor.rb +56 -21
- data/lib/cosmo/job/setter.rb +53 -0
- data/lib/cosmo/job.rb +71 -2
- data/lib/cosmo/logger.rb +37 -0
- data/lib/cosmo/middleware/chain.rb +12 -0
- data/lib/cosmo/middleware/limit.rb +12 -3
- data/lib/cosmo/middleware/metrics.rb +6 -4
- data/lib/cosmo/middleware/sentry.rb +6 -4
- data/lib/cosmo/middleware/totals.rb +5 -11
- data/lib/cosmo/middleware.rb +0 -1
- data/lib/cosmo/processor.rb +60 -3
- data/lib/cosmo/publisher.rb +8 -0
- data/lib/cosmo/services.rb +7 -2
- data/lib/cosmo/stream/message.rb +5 -0
- data/lib/cosmo/stream/processor.rb +7 -0
- data/lib/cosmo/stream/serializer.rb +4 -0
- data/lib/cosmo/stream.rb +35 -1
- data/lib/cosmo/utils/duration.rb +3 -0
- data/lib/cosmo/utils/hash.rb +12 -0
- data/lib/cosmo/utils/json.rb +8 -0
- data/lib/cosmo/utils/signal.rb +9 -0
- data/lib/cosmo/utils/stopwatch.rb +1 -0
- data/lib/cosmo/utils/string.rb +4 -0
- data/lib/cosmo/utils/thread_pool.rb +8 -0
- data/lib/cosmo/utils/ttl_cache.rb +10 -0
- data/lib/cosmo/utils.rb +0 -1
- data/lib/cosmo/version.rb +1 -1
- data/lib/cosmo/web/assets/app.css +273 -629
- data/lib/cosmo/web/assets/app.js +158 -0
- data/lib/cosmo/web/assets/fonts/OFL.txt +92 -0
- data/lib/cosmo/web/assets/fonts/geist-mono.woff2 +0 -0
- data/lib/cosmo/web/assets/fonts/geist.woff2 +0 -0
- data/lib/cosmo/web/assets/logo.svg +10 -0
- data/lib/cosmo/web/cache.rb +77 -0
- data/lib/cosmo/web/chart.rb +63 -39
- data/lib/cosmo/web/circuit.rb +56 -0
- data/lib/cosmo/web/context.rb +6 -4
- data/lib/cosmo/web/controllers/application.rb +42 -0
- data/lib/cosmo/web/controllers/batches.rb +8 -1
- data/lib/cosmo/web/controllers/crons.rb +24 -3
- data/lib/cosmo/web/controllers/jobs.rb +88 -68
- data/lib/cosmo/web/controllers/metrics.rb +6 -0
- data/lib/cosmo/web/controllers/overview.rb +88 -0
- data/lib/cosmo/web/controllers/processes.rb +36 -0
- data/lib/cosmo/web/controllers/streams.rb +38 -28
- data/lib/cosmo/web/helpers/application.rb +101 -0
- data/lib/cosmo/web/renderer.rb +36 -6
- data/lib/cosmo/web/throughput.rb +104 -0
- data/lib/cosmo/web/views/batches/_table.erb +42 -54
- data/lib/cosmo/web/views/batches/index.erb +3 -10
- data/lib/cosmo/web/views/crons/_table.erb +36 -55
- data/lib/cosmo/web/views/crons/index.erb +2 -9
- data/lib/cosmo/web/views/jobs/_args.erb +5 -0
- data/lib/cosmo/web/views/jobs/_busy.erb +25 -121
- data/lib/cosmo/web/views/jobs/_dead.erb +42 -82
- data/lib/cosmo/web/views/jobs/_enqueued.erb +33 -113
- data/lib/cosmo/web/views/jobs/_panel.erb +34 -0
- data/lib/cosmo/web/views/jobs/_queue_row.erb +18 -0
- data/lib/cosmo/web/views/jobs/_queues.erb +20 -0
- data/lib/cosmo/web/views/jobs/_scheduled.erb +20 -54
- data/lib/cosmo/web/views/jobs/index.erb +4 -17
- data/lib/cosmo/web/views/layout.erb +73 -22
- data/lib/cosmo/web/views/metrics/_chart.erb +37 -32
- data/lib/cosmo/web/views/metrics/_panel.erb +3 -3
- data/lib/cosmo/web/views/metrics/_table.erb +24 -40
- data/lib/cosmo/web/views/metrics/index.erb +8 -16
- data/lib/cosmo/web/views/overview/_badges.erb +3 -0
- data/lib/cosmo/web/views/overview/_kpis.erb +19 -0
- data/lib/cosmo/web/views/overview/_running.erb +18 -0
- data/lib/cosmo/web/views/overview/_throughput.erb +50 -0
- data/lib/cosmo/web/views/overview/_workers.erb +25 -0
- data/lib/cosmo/web/views/overview/index.erb +28 -0
- data/lib/cosmo/web/views/processes/_table.erb +67 -0
- data/lib/cosmo/web/views/processes/index.erb +1 -0
- data/lib/cosmo/web/views/shared/_pager.erb +22 -0
- data/lib/cosmo/web/views/shared/unavailable.erb +7 -0
- data/lib/cosmo/web/views/streams/_info.erb +29 -86
- data/lib/cosmo/web/views/streams/_list.erb +7 -0
- data/lib/cosmo/web/views/streams/_pause_banner.erb +8 -16
- data/lib/cosmo/web/views/streams/_stream.erb +53 -0
- data/lib/cosmo/web/views/streams/index.erb +3 -11
- data/lib/cosmo/web/views/streams/info.erb +3 -11
- data/lib/cosmo/web.rb +73 -35
- data/lib/cosmo.rb +33 -0
- data/sig/cosmo/active_job/adapter.rbs +3 -3
- data/sig/cosmo/active_job/options.rbs +4 -2
- data/sig/cosmo/api/batch.rbs +5 -3
- data/sig/cosmo/api/counter.rbs +16 -6
- data/sig/cosmo/api/cron/entry.rbs +6 -3
- data/sig/cosmo/api/cron.rbs +10 -4
- data/sig/cosmo/api/kv.rbs +21 -4
- data/sig/cosmo/api/registry.rbs +10 -0
- data/sig/cosmo/api/stats/jobs.rbs +34 -0
- data/sig/cosmo/api/stats/metrics.rbs +4 -1
- data/sig/cosmo/api/stats/processes.rbs +9 -1
- data/sig/cosmo/api/stats.rbs +12 -2
- data/sig/cosmo/api/stream.rbs +12 -5
- data/sig/cosmo/batch/callback.rbs +1 -1
- data/sig/cosmo/batch/dispatcher.rbs +1 -1
- data/sig/cosmo/batch.rbs +5 -5
- data/sig/cosmo/cli.rbs +2 -0
- data/sig/cosmo/client.rbs +24 -4
- data/sig/cosmo/config/settings.rbs +6 -0
- data/sig/cosmo/config.rbs +5 -5
- data/sig/cosmo/engine.rbs +5 -0
- data/sig/cosmo/heartbeat.rbs +2 -0
- data/sig/cosmo/job/data.rbs +3 -1
- data/sig/cosmo/job/enqueuer.rbs +12 -0
- data/sig/cosmo/job/processor.rbs +18 -3
- data/sig/cosmo/job/setter.rbs +20 -0
- data/sig/cosmo/job.rbs +10 -4
- data/sig/cosmo/logger.rbs +5 -3
- data/sig/cosmo/middleware.rbs +0 -8
- data/sig/cosmo/processor.rbs +14 -2
- data/sig/cosmo/publisher.rbs +1 -0
- data/sig/cosmo/stream/processor.rbs +4 -0
- data/sig/cosmo/stream.rbs +4 -3
- data/sig/cosmo/utils/hash.rbs +2 -1
- data/sig/cosmo/utils/signal.rbs +5 -5
- data/sig/cosmo/utils/string.rbs +2 -2
- data/sig/cosmo/utils/thread_pool.rbs +1 -1
- data/sig/cosmo/web/cache.rbs +35 -0
- data/sig/cosmo/web/chart.rbs +48 -0
- data/sig/cosmo/web/circuit.rbs +29 -0
- data/sig/cosmo/web/context.rbs +15 -0
- data/sig/cosmo/web/controllers/application.rbs +32 -0
- data/sig/cosmo/web/controllers/batches.rbs +11 -0
- data/sig/cosmo/web/controllers/crons.rbs +23 -0
- data/sig/cosmo/web/controllers/jobs.rbs +47 -0
- data/sig/cosmo/web/controllers/metrics.rbs +21 -0
- data/sig/cosmo/web/controllers/overview.rbs +31 -0
- data/sig/cosmo/web/controllers/processes.rbs +13 -0
- data/sig/cosmo/web/controllers/streams.rbs +27 -0
- data/sig/cosmo/web/helpers/application.rbs +61 -0
- data/sig/cosmo/web/renderer.rbs +33 -0
- data/sig/cosmo/web/throughput.rbs +45 -0
- data/sig/cosmo/web.rbs +25 -0
- data/sig/cosmo.rbs +19 -0
- metadata +53 -23
- data/lib/cosmo/api/stats/busy.rb +0 -63
- data/lib/cosmo/middleware/busy.rb +0 -15
- data/lib/cosmo/utils/overrides.rb +0 -206
- data/lib/cosmo/utils/warnings.rb +0 -17
- data/lib/cosmo/web/controllers/actions.rb +0 -16
- data/lib/cosmo/web/views/actions/index.erb +0 -7
- data/lib/cosmo/web/views/jobs/_processes.erb +0 -145
- data/lib/cosmo/web/views/jobs/_stats.erb +0 -77
- data/lib/cosmo/web/views/jobs/_tabs.erb +0 -14
- data/lib/cosmo/web/views/jobs/busy.erb +0 -18
- data/lib/cosmo/web/views/jobs/dead.erb +0 -18
- data/lib/cosmo/web/views/jobs/enqueued.erb +0 -18
- data/lib/cosmo/web/views/jobs/scheduled.erb +0 -18
- data/lib/cosmo/web/views/streams/_stream_row.erb +0 -42
- data/lib/cosmo/web/views/streams/_table.erb +0 -25
- data/sig/cosmo/api/stats/busy.rbs +0 -31
data/sig/cosmo.rbs
CHANGED
|
@@ -29,6 +29,25 @@ module Cosmo
|
|
|
29
29
|
def initialize: (::String stream_name) -> void
|
|
30
30
|
end
|
|
31
31
|
|
|
32
|
+
class BulkEnqueueError < Error
|
|
33
|
+
attr_reader jids: Array[::String?]
|
|
34
|
+
attr_reader errors: Hash[Integer, StandardError]
|
|
35
|
+
|
|
36
|
+
def initialize: (Array[::String?] jids, Hash[Integer, StandardError] errors) -> void
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
class JobClassNotFoundError < Error
|
|
40
|
+
def initialize: (::String? class_name) -> void
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
class JobInterruptedError < Error
|
|
44
|
+
def initialize: () -> void
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
class JobTimeoutError < Error
|
|
48
|
+
def initialize: (::Integer seconds) -> void
|
|
49
|
+
end
|
|
50
|
+
|
|
32
51
|
class UnknownJobStreamError < Error
|
|
33
52
|
def initialize: (Array[::String] names, Array[::String] configured) -> void
|
|
34
53
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: cosmonats
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.10.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Dmitry Vorotilin
|
|
@@ -43,20 +43,20 @@ dependencies:
|
|
|
43
43
|
requirements:
|
|
44
44
|
- - ">="
|
|
45
45
|
- !ruby/object:Gem::Version
|
|
46
|
-
version: '2.
|
|
46
|
+
version: '2.7'
|
|
47
47
|
- - "<"
|
|
48
48
|
- !ruby/object:Gem::Version
|
|
49
|
-
version: '2.
|
|
49
|
+
version: '2.8'
|
|
50
50
|
type: :runtime
|
|
51
51
|
prerelease: false
|
|
52
52
|
version_requirements: !ruby/object:Gem::Requirement
|
|
53
53
|
requirements:
|
|
54
54
|
- - ">="
|
|
55
55
|
- !ruby/object:Gem::Version
|
|
56
|
-
version: '2.
|
|
56
|
+
version: '2.7'
|
|
57
57
|
- - "<"
|
|
58
58
|
- !ruby/object:Gem::Version
|
|
59
|
-
version: '2.
|
|
59
|
+
version: '2.8'
|
|
60
60
|
description: Lightweight background and stream processing for Ruby
|
|
61
61
|
email:
|
|
62
62
|
- d.vorotilin@gmail.com
|
|
@@ -82,7 +82,7 @@ files:
|
|
|
82
82
|
- lib/cosmo/api/kv.rb
|
|
83
83
|
- lib/cosmo/api/registry.rb
|
|
84
84
|
- lib/cosmo/api/stats.rb
|
|
85
|
-
- lib/cosmo/api/stats/
|
|
85
|
+
- lib/cosmo/api/stats/jobs.rb
|
|
86
86
|
- lib/cosmo/api/stats/metrics.rb
|
|
87
87
|
- lib/cosmo/api/stats/processes.rb
|
|
88
88
|
- lib/cosmo/api/stats/totals.rb
|
|
@@ -109,10 +109,10 @@ files:
|
|
|
109
109
|
- lib/cosmo/job/limit.rb
|
|
110
110
|
- lib/cosmo/job/processor.rb
|
|
111
111
|
- lib/cosmo/job/requeue.rb
|
|
112
|
+
- lib/cosmo/job/setter.rb
|
|
112
113
|
- lib/cosmo/job/stream_filter.rb
|
|
113
114
|
- lib/cosmo/logger.rb
|
|
114
115
|
- lib/cosmo/middleware.rb
|
|
115
|
-
- lib/cosmo/middleware/busy.rb
|
|
116
116
|
- lib/cosmo/middleware/chain.rb
|
|
117
117
|
- lib/cosmo/middleware/limit.rb
|
|
118
118
|
- lib/cosmo/middleware/metrics.rb
|
|
@@ -131,54 +131,67 @@ files:
|
|
|
131
131
|
- lib/cosmo/utils/duration.rb
|
|
132
132
|
- lib/cosmo/utils/hash.rb
|
|
133
133
|
- lib/cosmo/utils/json.rb
|
|
134
|
-
- lib/cosmo/utils/overrides.rb
|
|
135
134
|
- lib/cosmo/utils/signal.rb
|
|
136
135
|
- lib/cosmo/utils/stopwatch.rb
|
|
137
136
|
- lib/cosmo/utils/string.rb
|
|
138
137
|
- lib/cosmo/utils/thread_pool.rb
|
|
139
138
|
- lib/cosmo/utils/ttl_cache.rb
|
|
140
|
-
- lib/cosmo/utils/warnings.rb
|
|
141
139
|
- lib/cosmo/version.rb
|
|
142
140
|
- lib/cosmo/web.rb
|
|
143
141
|
- lib/cosmo/web/assets/app.css
|
|
142
|
+
- lib/cosmo/web/assets/app.js
|
|
143
|
+
- lib/cosmo/web/assets/fonts/OFL.txt
|
|
144
|
+
- lib/cosmo/web/assets/fonts/geist-mono.woff2
|
|
145
|
+
- lib/cosmo/web/assets/fonts/geist.woff2
|
|
144
146
|
- lib/cosmo/web/assets/htmx.2.0.8.min.js.gz
|
|
147
|
+
- lib/cosmo/web/assets/logo.svg
|
|
148
|
+
- lib/cosmo/web/cache.rb
|
|
145
149
|
- lib/cosmo/web/chart.rb
|
|
150
|
+
- lib/cosmo/web/circuit.rb
|
|
146
151
|
- lib/cosmo/web/context.rb
|
|
147
|
-
- lib/cosmo/web/controllers/actions.rb
|
|
148
152
|
- lib/cosmo/web/controllers/application.rb
|
|
149
153
|
- lib/cosmo/web/controllers/batches.rb
|
|
150
154
|
- lib/cosmo/web/controllers/crons.rb
|
|
151
155
|
- lib/cosmo/web/controllers/jobs.rb
|
|
152
156
|
- lib/cosmo/web/controllers/metrics.rb
|
|
157
|
+
- lib/cosmo/web/controllers/overview.rb
|
|
158
|
+
- lib/cosmo/web/controllers/processes.rb
|
|
153
159
|
- lib/cosmo/web/controllers/streams.rb
|
|
154
160
|
- lib/cosmo/web/helpers/application.rb
|
|
155
161
|
- lib/cosmo/web/renderer.rb
|
|
156
|
-
- lib/cosmo/web/
|
|
162
|
+
- lib/cosmo/web/throughput.rb
|
|
157
163
|
- lib/cosmo/web/views/batches/_table.erb
|
|
158
164
|
- lib/cosmo/web/views/batches/index.erb
|
|
159
165
|
- lib/cosmo/web/views/crons/_table.erb
|
|
160
166
|
- lib/cosmo/web/views/crons/index.erb
|
|
167
|
+
- lib/cosmo/web/views/jobs/_args.erb
|
|
161
168
|
- lib/cosmo/web/views/jobs/_busy.erb
|
|
162
169
|
- lib/cosmo/web/views/jobs/_dead.erb
|
|
163
170
|
- lib/cosmo/web/views/jobs/_enqueued.erb
|
|
164
|
-
- lib/cosmo/web/views/jobs/
|
|
171
|
+
- lib/cosmo/web/views/jobs/_panel.erb
|
|
172
|
+
- lib/cosmo/web/views/jobs/_queue_row.erb
|
|
173
|
+
- lib/cosmo/web/views/jobs/_queues.erb
|
|
165
174
|
- lib/cosmo/web/views/jobs/_scheduled.erb
|
|
166
|
-
- lib/cosmo/web/views/jobs/_stats.erb
|
|
167
|
-
- lib/cosmo/web/views/jobs/_tabs.erb
|
|
168
|
-
- lib/cosmo/web/views/jobs/busy.erb
|
|
169
|
-
- lib/cosmo/web/views/jobs/dead.erb
|
|
170
|
-
- lib/cosmo/web/views/jobs/enqueued.erb
|
|
171
175
|
- lib/cosmo/web/views/jobs/index.erb
|
|
172
|
-
- lib/cosmo/web/views/jobs/scheduled.erb
|
|
173
176
|
- lib/cosmo/web/views/layout.erb
|
|
174
177
|
- lib/cosmo/web/views/metrics/_chart.erb
|
|
175
178
|
- lib/cosmo/web/views/metrics/_panel.erb
|
|
176
179
|
- lib/cosmo/web/views/metrics/_table.erb
|
|
177
180
|
- lib/cosmo/web/views/metrics/index.erb
|
|
181
|
+
- lib/cosmo/web/views/overview/_badges.erb
|
|
182
|
+
- lib/cosmo/web/views/overview/_kpis.erb
|
|
183
|
+
- lib/cosmo/web/views/overview/_running.erb
|
|
184
|
+
- lib/cosmo/web/views/overview/_throughput.erb
|
|
185
|
+
- lib/cosmo/web/views/overview/_workers.erb
|
|
186
|
+
- lib/cosmo/web/views/overview/index.erb
|
|
187
|
+
- lib/cosmo/web/views/processes/_table.erb
|
|
188
|
+
- lib/cosmo/web/views/processes/index.erb
|
|
189
|
+
- lib/cosmo/web/views/shared/_pager.erb
|
|
190
|
+
- lib/cosmo/web/views/shared/unavailable.erb
|
|
178
191
|
- lib/cosmo/web/views/streams/_info.erb
|
|
192
|
+
- lib/cosmo/web/views/streams/_list.erb
|
|
179
193
|
- lib/cosmo/web/views/streams/_pause_banner.erb
|
|
180
|
-
- lib/cosmo/web/views/streams/
|
|
181
|
-
- lib/cosmo/web/views/streams/_table.erb
|
|
194
|
+
- lib/cosmo/web/views/streams/_stream.erb
|
|
182
195
|
- lib/cosmo/web/views/streams/index.erb
|
|
183
196
|
- lib/cosmo/web/views/streams/info.erb
|
|
184
197
|
- lib/cosmonats.rb
|
|
@@ -194,7 +207,7 @@ files:
|
|
|
194
207
|
- sig/cosmo/api/kv.rbs
|
|
195
208
|
- sig/cosmo/api/registry.rbs
|
|
196
209
|
- sig/cosmo/api/stats.rbs
|
|
197
|
-
- sig/cosmo/api/stats/
|
|
210
|
+
- sig/cosmo/api/stats/jobs.rbs
|
|
198
211
|
- sig/cosmo/api/stats/metrics.rbs
|
|
199
212
|
- sig/cosmo/api/stats/processes.rbs
|
|
200
213
|
- sig/cosmo/api/stats/totals.rbs
|
|
@@ -220,6 +233,7 @@ files:
|
|
|
220
233
|
- sig/cosmo/job/limit.rbs
|
|
221
234
|
- sig/cosmo/job/processor.rbs
|
|
222
235
|
- sig/cosmo/job/requeue.rbs
|
|
236
|
+
- sig/cosmo/job/setter.rbs
|
|
223
237
|
- sig/cosmo/job/stream_filter.rbs
|
|
224
238
|
- sig/cosmo/logger.rbs
|
|
225
239
|
- sig/cosmo/middleware.rbs
|
|
@@ -242,6 +256,22 @@ files:
|
|
|
242
256
|
- sig/cosmo/utils/string.rbs
|
|
243
257
|
- sig/cosmo/utils/thread_pool.rbs
|
|
244
258
|
- sig/cosmo/utils/ttl_cache.rbs
|
|
259
|
+
- sig/cosmo/web.rbs
|
|
260
|
+
- sig/cosmo/web/cache.rbs
|
|
261
|
+
- sig/cosmo/web/chart.rbs
|
|
262
|
+
- sig/cosmo/web/circuit.rbs
|
|
263
|
+
- sig/cosmo/web/context.rbs
|
|
264
|
+
- sig/cosmo/web/controllers/application.rbs
|
|
265
|
+
- sig/cosmo/web/controllers/batches.rbs
|
|
266
|
+
- sig/cosmo/web/controllers/crons.rbs
|
|
267
|
+
- sig/cosmo/web/controllers/jobs.rbs
|
|
268
|
+
- sig/cosmo/web/controllers/metrics.rbs
|
|
269
|
+
- sig/cosmo/web/controllers/overview.rbs
|
|
270
|
+
- sig/cosmo/web/controllers/processes.rbs
|
|
271
|
+
- sig/cosmo/web/controllers/streams.rbs
|
|
272
|
+
- sig/cosmo/web/helpers/application.rbs
|
|
273
|
+
- sig/cosmo/web/renderer.rbs
|
|
274
|
+
- sig/cosmo/web/throughput.rbs
|
|
245
275
|
homepage: https://github.com/bitsbeam/cosmonats
|
|
246
276
|
licenses:
|
|
247
277
|
- MIT
|
|
@@ -259,14 +289,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
259
289
|
requirements:
|
|
260
290
|
- - ">="
|
|
261
291
|
- !ruby/object:Gem::Version
|
|
262
|
-
version: 3.
|
|
292
|
+
version: 3.2.0
|
|
263
293
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
264
294
|
requirements:
|
|
265
295
|
- - ">="
|
|
266
296
|
- !ruby/object:Gem::Version
|
|
267
297
|
version: '0'
|
|
268
298
|
requirements: []
|
|
269
|
-
rubygems_version: 4.0.
|
|
299
|
+
rubygems_version: 4.0.20
|
|
270
300
|
specification_version: 4
|
|
271
301
|
summary: Lightweight background and stream processing
|
|
272
302
|
test_files: []
|
data/lib/cosmo/api/stats/busy.rb
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require "socket"
|
|
4
|
-
|
|
5
|
-
module Cosmo
|
|
6
|
-
module API
|
|
7
|
-
module Stats
|
|
8
|
-
# Jobs being executed right now, one entry per in-flight message, across all workers.
|
|
9
|
-
class Busy < Registry
|
|
10
|
-
TTL = 70
|
|
11
|
-
HEARTBEAT = 30
|
|
12
|
-
BUCKET = "_cosmobusy"
|
|
13
|
-
|
|
14
|
-
def initialize
|
|
15
|
-
super
|
|
16
|
-
@messages = {}
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def with(message)
|
|
20
|
-
add(message)
|
|
21
|
-
yield
|
|
22
|
-
ensure
|
|
23
|
-
delete(message)
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
def add(message)
|
|
27
|
-
@thread ||= Thread.new { heartbeat_loop }
|
|
28
|
-
meta = message.metadata
|
|
29
|
-
seq = meta.sequence.stream
|
|
30
|
-
entry = { data: message.data, stream: meta.stream, worker: worker_id,
|
|
31
|
-
started_at: Time.now.to_i, delivery: meta.num_delivered }
|
|
32
|
-
@messages[seq] = entry
|
|
33
|
-
put(seq, entry)
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
def delete(message)
|
|
37
|
-
seq = message.metadata.sequence.stream
|
|
38
|
-
@messages.delete(seq)
|
|
39
|
-
remove(seq)
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
def list(...)
|
|
43
|
-
super.map { _1.merge(data: Utils::Json.parse(_1[:data])) }
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
private
|
|
47
|
-
|
|
48
|
-
def heartbeat_loop
|
|
49
|
-
loop do
|
|
50
|
-
sleep(HEARTBEAT)
|
|
51
|
-
@messages.dup.each { |seq, entry| put(seq, entry) rescue StandardError }
|
|
52
|
-
rescue StandardError => e
|
|
53
|
-
Logger.debug "Busy heartbeat error: #{e.class} #{e.message}"
|
|
54
|
-
end
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
def worker_id
|
|
58
|
-
@worker_id ||= "#{Socket.gethostname}-#{::Process.pid}"
|
|
59
|
-
end
|
|
60
|
-
end
|
|
61
|
-
end
|
|
62
|
-
end
|
|
63
|
-
end
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Cosmo
|
|
4
|
-
module Middleware
|
|
5
|
-
# Lists the job on the Web UI's Busy page while it runs.
|
|
6
|
-
class Busy
|
|
7
|
-
# @param _job [Cosmo::Job]
|
|
8
|
-
# @param _data [Hash]
|
|
9
|
-
# @param message [NATS::Msg]
|
|
10
|
-
def call(_job, _data, message, &)
|
|
11
|
-
API::Stats::Busy.instance.with(message, &)
|
|
12
|
-
end
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
end
|
|
@@ -1,206 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
Cosmo::Utils::Warnings.silence do
|
|
4
|
-
unless NATS::JetStream::API::StreamConfig.members.include?(:allow_msg_schedules)
|
|
5
|
-
members = NATS::JetStream::API::StreamConfig.members + %i[allow_msg_counter allow_msg_schedules]
|
|
6
|
-
NATS::JetStream::API::StreamConfig = Struct.new(*members, keyword_init: true) do
|
|
7
|
-
def initialize(opts = {})
|
|
8
|
-
rem = opts.keys - members
|
|
9
|
-
opts.delete_if { |k| rem.include?(k) }
|
|
10
|
-
super
|
|
11
|
-
end
|
|
12
|
-
end
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
unless NATS::JetStream::PubAck.members.include?(:val)
|
|
16
|
-
members = NATS::JetStream::PubAck.members + [:val]
|
|
17
|
-
NATS::JetStream::PubAck = Struct.new(*members, keyword_init: true)
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
# Upstream bug in nats-pure 2.5.0 and 2.6.0 (https://github.com/nats-io/nats-pure.rb):
|
|
22
|
-
# NATS::JetStream::PullSubscription#fetch only assigns its `start_time` local in the
|
|
23
|
-
# `batch > 1` branch, but the final "did we time out" check outside the case statement
|
|
24
|
-
# reads it unconditionally. For `batch == 1` (what Cosmo::Processor always uses),
|
|
25
|
-
# `start_time` is nil there -- normally masked because the `batch == 1` branch has its
|
|
26
|
-
# own timeout check (using a properly-set `t`) that raises first.
|
|
27
|
-
#
|
|
28
|
-
# It only surfaces once two threads call #fetch concurrently on the *same* subscription:
|
|
29
|
-
# @pending_queue/wait_for_msgs_cond are shared per-subscription state, and #dispatch's
|
|
30
|
-
# `wait_for_msgs_cond.signal` wakes exactly one arbitrary waiter -- not necessarily the
|
|
31
|
-
# one whose own request produced that wakeup. A thread woken by someone else's signal
|
|
32
|
-
# finds nothing left in the (already-drained) queue, so it skips its own inner timeout
|
|
33
|
-
# check and falls into the buggy tail check, raising `TypeError: nil can't be coerced
|
|
34
|
-
# into Float` instead of the intended timeout/empty result. Reproduced deterministically
|
|
35
|
-
# with N threads fetching in a loop against the same PullSubscription.
|
|
36
|
-
#
|
|
37
|
-
# Second, separate upstream bug in the same method: the post-wait timeout check below
|
|
38
|
-
# (`raise ... if MonotonicTime.since(t) > timeout`) fires unconditionally, unlike every
|
|
39
|
-
# other timeout check in this method (all guarded with `msgs.empty? &&`). If the unsynchronized
|
|
40
|
-
# pop just above it succeeded in grabbing a real, already-delivered message -- which can happen
|
|
41
|
-
# even after `timeout` has technically elapsed, since #dispatch's signal and this thread actually
|
|
42
|
-
# resuming are two different moments -- that message is already gone from @pending_queue with
|
|
43
|
-
# nowhere else to go, yet gets discarded here and a plain NATS::Timeout raised instead. Callers
|
|
44
|
-
# (including Cosmo::Processor#fetch) treat NATS::Timeout as "no messages", so the message is lost
|
|
45
|
-
# silently: never processed, never acked, and not redelivered until the consumer's ack_wait expires.
|
|
46
|
-
# Reproduces reliably with several threads fetching (batch: 1) concurrently against the same
|
|
47
|
-
# subscription, e.g. Cosmo::Job::Processor's thread pool.
|
|
48
|
-
#
|
|
49
|
-
# Vendored copy of nats-pure's PullSubscription#fetch, kept as close to
|
|
50
|
-
# upstream as possible (two one-line fixes, see comments above), so it's easy to diff against the
|
|
51
|
-
# next nats-pure release and drop once fixed there. Fixed on nats-pure main by the fetch rewrite
|
|
52
|
-
# (#181), recognized by its private #take_pending, in which case this copy is not loaded.
|
|
53
|
-
return if NATS::JetStream.const_get(:PullSubscription).private_method_defined?(:take_pending)
|
|
54
|
-
|
|
55
|
-
# rubocop:disable all
|
|
56
|
-
module NATS
|
|
57
|
-
class JetStream
|
|
58
|
-
module PullSubscription
|
|
59
|
-
def fetch(batch = 1, params = {})
|
|
60
|
-
raise ::NATS::JetStream::Error.new("nats: invalid batch size") if batch < 1
|
|
61
|
-
|
|
62
|
-
t = MonotonicTime.now
|
|
63
|
-
start_time = t # fixes the upstream bug -- see comment above
|
|
64
|
-
timeout = params[:timeout] ||= 5
|
|
65
|
-
expires = (timeout * 1_000_000_000) - 100_000
|
|
66
|
-
next_req = { batch: batch }
|
|
67
|
-
|
|
68
|
-
msgs = []
|
|
69
|
-
case
|
|
70
|
-
when batch == 1
|
|
71
|
-
synchronize do
|
|
72
|
-
unless @pending_queue.empty?
|
|
73
|
-
msg = @pending_queue.pop
|
|
74
|
-
@pending_size -= msg.data.size
|
|
75
|
-
if JS.is_status_msg(msg)
|
|
76
|
-
case msg.header["Status"]
|
|
77
|
-
when JS::Status::NoMsgs then nil
|
|
78
|
-
when JS::Status::RequestTimeout then nil # Skip
|
|
79
|
-
else raise JS.from_msg(msg)
|
|
80
|
-
end
|
|
81
|
-
else
|
|
82
|
-
msgs << msg
|
|
83
|
-
end
|
|
84
|
-
end
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
next_req[:expires] = expires
|
|
88
|
-
if msgs.empty?
|
|
89
|
-
@nc.publish(@jsi.nms, JS.next_req_to_json(next_req), @subject)
|
|
90
|
-
synchronize { wait_for_msgs_cond.wait(timeout) }
|
|
91
|
-
|
|
92
|
-
unless @pending_queue.empty?
|
|
93
|
-
msg = @pending_queue.pop
|
|
94
|
-
@pending_size -= msg.data.size
|
|
95
|
-
msgs << msg
|
|
96
|
-
end
|
|
97
|
-
|
|
98
|
-
raise ::NATS::Timeout.new("nats: fetch timeout") if msgs.empty? && (MonotonicTime.since(t) > timeout)
|
|
99
|
-
|
|
100
|
-
if JS.is_status_msg(msgs.first)
|
|
101
|
-
msg = msgs.first
|
|
102
|
-
case msg.header[JS::Header::Status]
|
|
103
|
-
when JS::Status::RequestTimeout then raise NATS::Timeout.new("nats: fetch request timeout")
|
|
104
|
-
else raise JS.from_msg(msgs.first)
|
|
105
|
-
end
|
|
106
|
-
end
|
|
107
|
-
end
|
|
108
|
-
when batch > 1
|
|
109
|
-
synchronize do
|
|
110
|
-
if batch <= @pending_queue.size
|
|
111
|
-
batch.times do
|
|
112
|
-
msg = @pending_queue.pop
|
|
113
|
-
@pending_size -= msg.data.size
|
|
114
|
-
if JS.is_status_msg(msg)
|
|
115
|
-
case msg.header[JS::Header::Status]
|
|
116
|
-
when JS::Status::NoMsgs, JS::Status::RequestTimeout then next
|
|
117
|
-
else raise JS.from_msg(msg)
|
|
118
|
-
end
|
|
119
|
-
else
|
|
120
|
-
msgs << msg
|
|
121
|
-
end
|
|
122
|
-
end
|
|
123
|
-
return msgs
|
|
124
|
-
end
|
|
125
|
-
end
|
|
126
|
-
|
|
127
|
-
next_req[:no_wait] = true
|
|
128
|
-
@nc.publish(@jsi.nms, JS.next_req_to_json(next_req), @subject)
|
|
129
|
-
|
|
130
|
-
start_time = MonotonicTime.now
|
|
131
|
-
msg = nil
|
|
132
|
-
|
|
133
|
-
synchronize do
|
|
134
|
-
wait_for_msgs_cond.wait(timeout)
|
|
135
|
-
unless @pending_queue.empty?
|
|
136
|
-
msg = @pending_queue.pop
|
|
137
|
-
@pending_size -= msg.data.size
|
|
138
|
-
end
|
|
139
|
-
end
|
|
140
|
-
|
|
141
|
-
if !msg.nil? && JS.is_status_msg(msg)
|
|
142
|
-
case msg.header[JS::Header::Status]
|
|
143
|
-
when JS::Status::NoMsgs
|
|
144
|
-
next_req[:expires] = expires
|
|
145
|
-
next_req.delete(:no_wait)
|
|
146
|
-
@nc.publish(@jsi.nms, JS.next_req_to_json(next_req), @subject)
|
|
147
|
-
when JS::Status::RequestTimeout
|
|
148
|
-
raise NATS::Timeout.new("nats: fetch request timeout")
|
|
149
|
-
else
|
|
150
|
-
raise JS.from_msg(msg)
|
|
151
|
-
end
|
|
152
|
-
else
|
|
153
|
-
msgs << msg unless msg.nil?
|
|
154
|
-
end
|
|
155
|
-
|
|
156
|
-
duration = MonotonicTime.since(start_time)
|
|
157
|
-
raise NATS::Timeout.new("nats: fetch timeout") if msgs.empty? && (duration > timeout)
|
|
158
|
-
|
|
159
|
-
needed = batch - msgs.count
|
|
160
|
-
while (needed > 0) && (MonotonicTime.since(start_time) < timeout)
|
|
161
|
-
duration = MonotonicTime.since(start_time)
|
|
162
|
-
|
|
163
|
-
synchronize do
|
|
164
|
-
if @pending_queue.empty?
|
|
165
|
-
deadline = timeout - duration
|
|
166
|
-
wait_for_msgs_cond.wait(deadline) if deadline > 0
|
|
167
|
-
|
|
168
|
-
duration = MonotonicTime.since(start_time)
|
|
169
|
-
if msgs.empty? && @pending_queue.empty? && (duration > timeout)
|
|
170
|
-
raise NATS::Timeout.new("nats: fetch timeout")
|
|
171
|
-
end
|
|
172
|
-
end
|
|
173
|
-
|
|
174
|
-
unless @pending_queue.empty?
|
|
175
|
-
msg = @pending_queue.pop
|
|
176
|
-
@pending_size -= msg.data.size
|
|
177
|
-
|
|
178
|
-
if JS.is_status_msg(msg)
|
|
179
|
-
case msg.header[JS::Header::Status]
|
|
180
|
-
when JS::Status::NoMsgs, JS::Status::RequestTimeout
|
|
181
|
-
duration = MonotonicTime.since(start_time)
|
|
182
|
-
if duration > timeout
|
|
183
|
-
raise NATS::Timeout.new("nats: fetch timeout") if msgs.empty?
|
|
184
|
-
|
|
185
|
-
return msgs
|
|
186
|
-
end
|
|
187
|
-
else
|
|
188
|
-
raise JS.from_msg(msg)
|
|
189
|
-
end
|
|
190
|
-
else
|
|
191
|
-
msgs << msg
|
|
192
|
-
needed -= 1
|
|
193
|
-
end
|
|
194
|
-
end
|
|
195
|
-
end
|
|
196
|
-
end
|
|
197
|
-
end
|
|
198
|
-
|
|
199
|
-
raise ::NATS::Timeout.new("nats: fetch timeout") if msgs.empty? && (MonotonicTime.since(start_time) > timeout)
|
|
200
|
-
|
|
201
|
-
msgs
|
|
202
|
-
end
|
|
203
|
-
end
|
|
204
|
-
end
|
|
205
|
-
end
|
|
206
|
-
# rubocop:enable all
|
data/lib/cosmo/utils/warnings.rb
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require "cosmo/web/controllers/application"
|
|
4
|
-
|
|
5
|
-
module Cosmo
|
|
6
|
-
class Web
|
|
7
|
-
module Controllers
|
|
8
|
-
class Actions < Application
|
|
9
|
-
def index
|
|
10
|
-
content_for :title, "Actions"
|
|
11
|
-
ok render("actions/index", layout: true)
|
|
12
|
-
end
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
end
|