cosmonats 0.1.4 → 0.2.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 +8 -7
- data/lib/cosmo/api/busy.rb +66 -0
- data/lib/cosmo/api/counter.rb +70 -0
- data/lib/cosmo/api/job.rb +46 -0
- data/lib/cosmo/api/kv.rb +63 -0
- data/lib/cosmo/api/stats.rb +44 -0
- data/lib/cosmo/api/stream.rb +110 -0
- data/lib/cosmo/api.rb +11 -0
- data/lib/cosmo/cli.rb +6 -4
- data/lib/cosmo/client.rb +33 -2
- data/lib/cosmo/config.rb +8 -6
- data/lib/cosmo/defaults.yml +31 -30
- data/lib/cosmo/job/processor.rb +52 -18
- data/lib/cosmo/job.rb +1 -1
- data/lib/cosmo/logger.rb +4 -0
- data/lib/cosmo/processor.rb +1 -1
- data/lib/cosmo/utils/overrides.rb +15 -0
- data/lib/cosmo/utils/warnings.rb +17 -0
- data/lib/cosmo/utils.rb +14 -0
- data/lib/cosmo/version.rb +1 -1
- data/lib/cosmo/web/assets/app.css +431 -0
- data/lib/cosmo/web/assets/htmx.2.0.8.min.js.gz +0 -0
- data/lib/cosmo/web/context.rb +28 -0
- data/lib/cosmo/web/controllers/actions.rb +16 -0
- data/lib/cosmo/web/controllers/application.rb +43 -0
- data/lib/cosmo/web/controllers/jobs.rb +97 -0
- data/lib/cosmo/web/controllers/streams.rb +44 -0
- data/lib/cosmo/web/helpers/application.rb +76 -0
- data/lib/cosmo/web/renderer.rb +58 -0
- data/lib/cosmo/web/views/actions/index.erb +7 -0
- data/lib/cosmo/web/views/jobs/_busy.erb +50 -0
- data/lib/cosmo/web/views/jobs/_dead.erb +65 -0
- data/lib/cosmo/web/views/jobs/_enqueued.erb +60 -0
- data/lib/cosmo/web/views/jobs/_scheduled.erb +49 -0
- data/lib/cosmo/web/views/jobs/_stats.erb +69 -0
- data/lib/cosmo/web/views/jobs/busy.erb +16 -0
- data/lib/cosmo/web/views/jobs/dead.erb +17 -0
- data/lib/cosmo/web/views/jobs/enqueued.erb +16 -0
- data/lib/cosmo/web/views/jobs/index.erb +12 -0
- data/lib/cosmo/web/views/jobs/scheduled.erb +17 -0
- data/lib/cosmo/web/views/layout.erb +33 -0
- data/lib/cosmo/web/views/streams/_info.erb +89 -0
- data/lib/cosmo/web/views/streams/_table.erb +42 -0
- data/lib/cosmo/web/views/streams/index.erb +11 -0
- data/lib/cosmo/web/views/streams/info.erb +11 -0
- data/lib/cosmo/web.rb +66 -0
- data/lib/cosmo.rb +2 -7
- data/sig/cosmo/api/busy.rbs +35 -0
- data/sig/cosmo/api/counter.rbs +34 -0
- data/sig/cosmo/api/job.rbs +31 -0
- data/sig/cosmo/api/kv.rbs +30 -0
- data/sig/cosmo/api/stats.rbs +21 -0
- data/sig/cosmo/api/stream.rbs +44 -0
- data/sig/cosmo/client.rbs +13 -3
- metadata +58 -2
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<section>
|
|
2
|
+
<header></header>
|
|
3
|
+
|
|
4
|
+
<div hx-get="<%= url_for('/jobs/_stats') %>"
|
|
5
|
+
hx-trigger="load, every 5s"
|
|
6
|
+
hx-swap="innerHTML">
|
|
7
|
+
<div class="alert alert-info">Loading statistics…</div>
|
|
8
|
+
</div>
|
|
9
|
+
|
|
10
|
+
<div id="content"
|
|
11
|
+
hx-get="<%= url_for('/jobs/_enqueued', stream_name: @stream_name) %>"
|
|
12
|
+
hx-trigger="load"
|
|
13
|
+
hx-swap="innerHTML">
|
|
14
|
+
<div class="alert alert-info">Loading enqueued jobs…</div>
|
|
15
|
+
</div>
|
|
16
|
+
</section>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<section>
|
|
2
|
+
<header></header>
|
|
3
|
+
|
|
4
|
+
<div hx-get="<%= url_for('/jobs/_stats') %>"
|
|
5
|
+
hx-trigger="load, every 5s"
|
|
6
|
+
hx-swap="innerHTML">
|
|
7
|
+
<div class="alert alert-info">Loading statistics…</div>
|
|
8
|
+
</div>
|
|
9
|
+
|
|
10
|
+
<div id="content">
|
|
11
|
+
<div hx-get="<%= url_for('/jobs/_scheduled') %>"
|
|
12
|
+
hx-trigger="load, every 5s"
|
|
13
|
+
hx-swap="innerHTML">
|
|
14
|
+
<div class="alert alert-info">Loading scheduled jobs…</div>
|
|
15
|
+
</div>
|
|
16
|
+
</div>
|
|
17
|
+
</section>
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
|
+
<title>Cosmo<%= " — #{h(content_for :title)}" if content_for?(:title) %></title>
|
|
7
|
+
<script src="<%= url_for('/assets/htmx.min.js.gz') %>" defer></script>
|
|
8
|
+
<link rel="stylesheet" href="<%= url_for('/assets/app.css') %>">
|
|
9
|
+
</head>
|
|
10
|
+
<body>
|
|
11
|
+
<header>
|
|
12
|
+
<div class="container">
|
|
13
|
+
<nav class="nav">
|
|
14
|
+
<a href="<%= url_for('/jobs') %>" class="navbar-brand">🚀 Cosmo</a>
|
|
15
|
+
<ul class="nav-list">
|
|
16
|
+
<li>
|
|
17
|
+
<a href="<%= url_for('/jobs') %>" class="<%= "active" if current_page?('/jobs') %>">Jobs</a>
|
|
18
|
+
</li>
|
|
19
|
+
<li>
|
|
20
|
+
<a href="<%= url_for('/streams') %>" class="<%= "active" if current_page?('/streams') %>">Streams</a>
|
|
21
|
+
</li>
|
|
22
|
+
<li>
|
|
23
|
+
<a href="<%= url_for('/actions') %>" class="<%= "active" if current_page?('/actions') %>">Actions</a>
|
|
24
|
+
</li>
|
|
25
|
+
</ul>
|
|
26
|
+
</nav>
|
|
27
|
+
</div>
|
|
28
|
+
</header>
|
|
29
|
+
<main class="container">
|
|
30
|
+
<%= content_for :view %>
|
|
31
|
+
</main>
|
|
32
|
+
</body>
|
|
33
|
+
</html>
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
<div class="cards-container">
|
|
2
|
+
<article class="stat-card">
|
|
3
|
+
<h3><%= format_numbers(@state.messages) %></h3>
|
|
4
|
+
<p>Messages</p>
|
|
5
|
+
</article>
|
|
6
|
+
<article class="stat-card">
|
|
7
|
+
<h3><%= format_bytes(@state.bytes) %></h3>
|
|
8
|
+
<p>Size</p>
|
|
9
|
+
</article>
|
|
10
|
+
<article class="stat-card">
|
|
11
|
+
<h3><%= @state.consumer_count %></h3>
|
|
12
|
+
<p>Consumers</p>
|
|
13
|
+
</article>
|
|
14
|
+
<article class="stat-card">
|
|
15
|
+
<h3><%= format_numbers(@state.first_seq) + " → " + format_numbers(@state.last_seq) %></h3>
|
|
16
|
+
<p>Sequence Range</p>
|
|
17
|
+
</article>
|
|
18
|
+
</div>
|
|
19
|
+
|
|
20
|
+
<div class="nav">
|
|
21
|
+
<a href="<%= url_for('/streams') %>"
|
|
22
|
+
hx-get="<%= url_for('/streams') %>"
|
|
23
|
+
hx-target="#content"
|
|
24
|
+
hx-push-url="true"
|
|
25
|
+
class="btn">Back to Streams</a>
|
|
26
|
+
</div>
|
|
27
|
+
|
|
28
|
+
<h2>Configuration</h2>
|
|
29
|
+
<div class="table-container">
|
|
30
|
+
<table>
|
|
31
|
+
<tbody>
|
|
32
|
+
<tr>
|
|
33
|
+
<th>Name</th>
|
|
34
|
+
<td>
|
|
35
|
+
<code><%= h(@name) %></code>
|
|
36
|
+
</td>
|
|
37
|
+
</tr>
|
|
38
|
+
<tr>
|
|
39
|
+
<th>Retention</th>
|
|
40
|
+
<td>
|
|
41
|
+
<code><%= h(@config.retention.to_s) %></code>
|
|
42
|
+
</td>
|
|
43
|
+
</tr>
|
|
44
|
+
<tr>
|
|
45
|
+
<th>Storage</th>
|
|
46
|
+
<td>
|
|
47
|
+
<code><%= h(@config.storage.to_s) %></code>
|
|
48
|
+
</td>
|
|
49
|
+
</tr>
|
|
50
|
+
<tr>
|
|
51
|
+
<th>Discard Policy</th>
|
|
52
|
+
<td>
|
|
53
|
+
<code><%= h(@config.discard.to_s) %></code>
|
|
54
|
+
</td>
|
|
55
|
+
</tr>
|
|
56
|
+
<tr>
|
|
57
|
+
<th>Max Consumers</th>
|
|
58
|
+
<td>
|
|
59
|
+
<code><%= @config.max_consumers || "Unlimited" %></code>
|
|
60
|
+
</td>
|
|
61
|
+
</tr>
|
|
62
|
+
<tr>
|
|
63
|
+
<th>Max Messages</th>
|
|
64
|
+
<td>
|
|
65
|
+
<code><%= @config.max_msgs || "Unlimited" %></code>
|
|
66
|
+
</td>
|
|
67
|
+
</tr>
|
|
68
|
+
<tr>
|
|
69
|
+
<th>Max Bytes</th>
|
|
70
|
+
<td>
|
|
71
|
+
<code><%= @config.max_bytes&.positive? ? format_bytes(@config.max_bytes) : "Unlimited" %></code>
|
|
72
|
+
</td>
|
|
73
|
+
</tr>
|
|
74
|
+
<tr>
|
|
75
|
+
<th>Max Age</th>
|
|
76
|
+
<td>
|
|
77
|
+
<code><%= @config.max_age&.positive? ? "#{@config.max_age}ns" : "Unlimited" %></code>
|
|
78
|
+
</td>
|
|
79
|
+
</tr>
|
|
80
|
+
</tbody>
|
|
81
|
+
</table>
|
|
82
|
+
</div>
|
|
83
|
+
|
|
84
|
+
<h2>Subjects</h2>
|
|
85
|
+
<div class="subjects" style="margin-top: var(--space-2x);">
|
|
86
|
+
<% Array(@config.subjects).each do |sub| -%>
|
|
87
|
+
<div class="subject-tag" style="padding: var(--space) var(--space-2x); font-size: 1rem;"><%= h(sub) %></div>
|
|
88
|
+
<% end -%>
|
|
89
|
+
</div>
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
<% if @streams.empty? -%>
|
|
2
|
+
<div class="alert alert-info">No streams found</div>
|
|
3
|
+
<% else -%>
|
|
4
|
+
<div class="table-container">
|
|
5
|
+
<table>
|
|
6
|
+
<thead>
|
|
7
|
+
<tr>
|
|
8
|
+
<th>Name</th>
|
|
9
|
+
<th>Messages</th>
|
|
10
|
+
<th>Size</th>
|
|
11
|
+
<th>Consumers</th>
|
|
12
|
+
<th>Subjects</th>
|
|
13
|
+
<th>Sequence</th>
|
|
14
|
+
</tr>
|
|
15
|
+
</thead>
|
|
16
|
+
<tbody>
|
|
17
|
+
<% @streams.each do |s| -%>
|
|
18
|
+
<tr>
|
|
19
|
+
<td>
|
|
20
|
+
<a href="<%= url_for('/streams/info', { name: u(s[:name]) }) %>"
|
|
21
|
+
hx-get="<%= url_for('/streams/info', { name: u(s[:name]) }) %>"
|
|
22
|
+
hx-target="#content"
|
|
23
|
+
hx-push-url="true"
|
|
24
|
+
class="stream-link"><%= h(s[:name]) %></a>
|
|
25
|
+
</td>
|
|
26
|
+
<td><%= format_numbers(s[:messages]) %></td>
|
|
27
|
+
<td><%= format_bytes(s[:bytes]) %></td>
|
|
28
|
+
<td><%= s[:consumer_count] %></td>
|
|
29
|
+
<td>
|
|
30
|
+
<div class="subjects">
|
|
31
|
+
<% (s[:subjects] || []).each do |sub| -%>
|
|
32
|
+
<span class="subject-tag"><%= h(sub) %></span>
|
|
33
|
+
<% end -%>
|
|
34
|
+
</div>
|
|
35
|
+
</td>
|
|
36
|
+
<td><code><%= format_numbers(s[:first_seq]) %> → <%= format_numbers(s[:last_seq]) %></code></td>
|
|
37
|
+
</tr>
|
|
38
|
+
<% end -%>
|
|
39
|
+
</tbody>
|
|
40
|
+
</table>
|
|
41
|
+
</div>
|
|
42
|
+
<% end -%>
|
data/lib/cosmo/web.rb
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "rack"
|
|
4
|
+
require "json"
|
|
5
|
+
require "erb"
|
|
6
|
+
require "cosmo/web/context"
|
|
7
|
+
require "cosmo/web/renderer"
|
|
8
|
+
require "cosmo/web/controllers/application"
|
|
9
|
+
require "cosmo/web/controllers/jobs"
|
|
10
|
+
require "cosmo/web/controllers/streams"
|
|
11
|
+
require "cosmo/web/controllers/actions"
|
|
12
|
+
|
|
13
|
+
module Cosmo
|
|
14
|
+
class Web
|
|
15
|
+
include Renderer
|
|
16
|
+
|
|
17
|
+
def self.call(env)
|
|
18
|
+
new.call(env)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def call(env) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
|
|
22
|
+
@request = Rack::Request.new(env)
|
|
23
|
+
path = @request.path_info
|
|
24
|
+
method = @request.request_method
|
|
25
|
+
|
|
26
|
+
response = case [method.downcase.to_sym, path]
|
|
27
|
+
in [:get, "/"] then redirect_to("/jobs")
|
|
28
|
+
in [:get, "/jobs"] then [Controllers::Jobs, :index]
|
|
29
|
+
in [:get, "/jobs/scheduled"] then [Controllers::Jobs, :scheduled]
|
|
30
|
+
in [:get, "/jobs/dead"] then [Controllers::Jobs, :dead]
|
|
31
|
+
in [:get, "/jobs/busy"] then [Controllers::Jobs, :busy]
|
|
32
|
+
in [:get, "/jobs/enqueued"] then [Controllers::Jobs, :enqueued]
|
|
33
|
+
in [:patch, %r{/jobs/retry/\d+}] then [Controllers::Jobs, :retry]
|
|
34
|
+
in [:delete, %r{/jobs/delete/\d+}] then [Controllers::Jobs, :delete]
|
|
35
|
+
in [:get, "/jobs/_stats"] then [Controllers::Jobs, :_stats]
|
|
36
|
+
in [:get, "/jobs/_scheduled"] then [Controllers::Jobs, :_scheduled]
|
|
37
|
+
in [:get, "/jobs/_dead"] then [Controllers::Jobs, :_dead]
|
|
38
|
+
in [:get, "/jobs/_busy"] then [Controllers::Jobs, :_busy]
|
|
39
|
+
in [:get, "/jobs/_enqueued"] then [Controllers::Jobs, :_enqueued]
|
|
40
|
+
in [:get, "/streams"] then [Controllers::Streams, :index]
|
|
41
|
+
in [:get, "/streams/info"] then [Controllers::Streams, :info]
|
|
42
|
+
in [:get, "/streams/_table"] then [Controllers::Streams, :_table]
|
|
43
|
+
in [:get, "/streams/_info"] then [Controllers::Streams, :_info]
|
|
44
|
+
in [:get, "/actions"] then [Controllers::Actions, :index]
|
|
45
|
+
in [:get, "/assets/htmx.min.js.gz"] then serve("htmx.2.0.8.min.js.gz",
|
|
46
|
+
"application/javascript",
|
|
47
|
+
{ "content-encoding" => "gzip" })
|
|
48
|
+
in [:get, "/assets/app.css"] then serve("app.css", "text/css")
|
|
49
|
+
in [:get, "/favicon.ico"] then no_content
|
|
50
|
+
else not_found
|
|
51
|
+
end
|
|
52
|
+
handler(response)
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
private
|
|
56
|
+
|
|
57
|
+
def handler(response)
|
|
58
|
+
if response[0].is_a?(Class)
|
|
59
|
+
controller, action = response
|
|
60
|
+
return controller.new(@request).send(action)
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
response
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
data/lib/cosmo.rb
CHANGED
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require "cosmo/utils
|
|
4
|
-
require "cosmo/utils/json"
|
|
5
|
-
require "cosmo/utils/string"
|
|
6
|
-
require "cosmo/utils/signal"
|
|
7
|
-
require "cosmo/utils/stopwatch"
|
|
8
|
-
require "cosmo/utils/thread_pool"
|
|
9
|
-
|
|
3
|
+
require "cosmo/utils"
|
|
10
4
|
require "cosmo/client"
|
|
11
5
|
require "cosmo/publisher"
|
|
12
6
|
require "cosmo/processor"
|
|
@@ -17,6 +11,7 @@ require "cosmo/job"
|
|
|
17
11
|
require "cosmo/stream"
|
|
18
12
|
require "cosmo/cli"
|
|
19
13
|
require "cosmo/engine"
|
|
14
|
+
require "cosmo/api"
|
|
20
15
|
|
|
21
16
|
module Cosmo
|
|
22
17
|
class Error < StandardError; end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
module Cosmo
|
|
2
|
+
module API
|
|
3
|
+
class Busy
|
|
4
|
+
TTL: ::Integer
|
|
5
|
+
HEARTBEAT: ::Integer
|
|
6
|
+
BUCKET: ::String
|
|
7
|
+
|
|
8
|
+
self.@instance: Busy
|
|
9
|
+
@messages: Hash[::Integer, ::String]
|
|
10
|
+
@kv: KV
|
|
11
|
+
@thread: Thread?
|
|
12
|
+
@worker_id: ::String
|
|
13
|
+
|
|
14
|
+
def self.instance: () -> Busy
|
|
15
|
+
|
|
16
|
+
def initialize: () -> void
|
|
17
|
+
|
|
18
|
+
def with: (untyped message) { () -> void } -> void
|
|
19
|
+
|
|
20
|
+
def add: (untyped message) -> void
|
|
21
|
+
|
|
22
|
+
def delete: (untyped message) -> void
|
|
23
|
+
|
|
24
|
+
def list: (?limit: ::Integer) -> Array[Hash[Symbol, untyped]]
|
|
25
|
+
|
|
26
|
+
def size: () -> ::Integer
|
|
27
|
+
|
|
28
|
+
private
|
|
29
|
+
|
|
30
|
+
def heartbeat_loop: () -> void
|
|
31
|
+
|
|
32
|
+
def worker_id: () -> ::String
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
module Cosmo
|
|
2
|
+
module API
|
|
3
|
+
class Counter
|
|
4
|
+
STREAM_NAME: ::String
|
|
5
|
+
|
|
6
|
+
self.@instance: Counter
|
|
7
|
+
@namespace: ::String
|
|
8
|
+
|
|
9
|
+
def self.instance: () -> Counter
|
|
10
|
+
|
|
11
|
+
def initialize: (::String namespace) -> void
|
|
12
|
+
|
|
13
|
+
def with: () { () -> bool } -> void
|
|
14
|
+
|
|
15
|
+
def increment: (Symbol key, ?by: ::Integer) -> ::Integer
|
|
16
|
+
alias incr increment
|
|
17
|
+
|
|
18
|
+
def decrement: (Symbol key, ?by: ::Integer) -> ::Integer
|
|
19
|
+
alias decr decrement
|
|
20
|
+
|
|
21
|
+
def reset: (Symbol key) -> untyped
|
|
22
|
+
|
|
23
|
+
def get: (Symbol key) -> ::Integer
|
|
24
|
+
|
|
25
|
+
private
|
|
26
|
+
|
|
27
|
+
def publish: (Symbol key, ::String value) -> ::Integer
|
|
28
|
+
|
|
29
|
+
def subject: (Symbol key) -> ::String
|
|
30
|
+
|
|
31
|
+
def client: () -> Client
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
module Cosmo
|
|
2
|
+
module API
|
|
3
|
+
class Job
|
|
4
|
+
@stream: ::String
|
|
5
|
+
@message: untyped
|
|
6
|
+
@data: Hash[Symbol, untyped]?
|
|
7
|
+
|
|
8
|
+
attr_reader message: untyped
|
|
9
|
+
|
|
10
|
+
def initialize: (::String stream, untyped message) -> void
|
|
11
|
+
|
|
12
|
+
def data: () -> Hash[Symbol, untyped]?
|
|
13
|
+
|
|
14
|
+
def seq: () -> (::Integer | ::String)
|
|
15
|
+
|
|
16
|
+
def headers: () -> Hash[::String, ::String]?
|
|
17
|
+
|
|
18
|
+
def execute_at: () -> ::Integer?
|
|
19
|
+
|
|
20
|
+
def x_stream: () -> ::String?
|
|
21
|
+
|
|
22
|
+
def x_subject: () -> ::String?
|
|
23
|
+
|
|
24
|
+
def subject: () -> ::String
|
|
25
|
+
|
|
26
|
+
def stream: () -> ::String
|
|
27
|
+
|
|
28
|
+
def timestamp: () -> ::String?
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
module Cosmo
|
|
2
|
+
module API
|
|
3
|
+
class KV
|
|
4
|
+
@name: ::String
|
|
5
|
+
@options: Hash[Symbol, untyped]
|
|
6
|
+
@kv: untyped
|
|
7
|
+
|
|
8
|
+
def initialize: (::String name, ?Hash[Symbol, untyped]? options) -> void
|
|
9
|
+
|
|
10
|
+
def set: (::String | ::Integer key, ::String value) -> untyped
|
|
11
|
+
|
|
12
|
+
def get: (::String | ::Integer key) -> ::String?
|
|
13
|
+
|
|
14
|
+
def delete: (::String | ::Integer key) -> untyped
|
|
15
|
+
|
|
16
|
+
def keys: (?::String? subject, ?limit: ::Integer) -> Array[::String]
|
|
17
|
+
|
|
18
|
+
def purge: (::String | ::Integer key) -> untyped
|
|
19
|
+
|
|
20
|
+
def clean: () -> untyped
|
|
21
|
+
|
|
22
|
+
def count: () -> ::Integer
|
|
23
|
+
alias size count
|
|
24
|
+
|
|
25
|
+
private
|
|
26
|
+
|
|
27
|
+
def kv: () -> untyped
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
module Cosmo
|
|
2
|
+
module API
|
|
3
|
+
module Stats
|
|
4
|
+
def self.summary: () -> Hash[Symbol, ::Integer]
|
|
5
|
+
|
|
6
|
+
def self.processed: () -> ::Integer
|
|
7
|
+
|
|
8
|
+
def self.failed: () -> ::Integer
|
|
9
|
+
|
|
10
|
+
def self.busy: () -> ::Integer
|
|
11
|
+
|
|
12
|
+
def self.enqueued: () -> ::Integer
|
|
13
|
+
|
|
14
|
+
def self.retries: () -> ::Integer
|
|
15
|
+
|
|
16
|
+
def self.scheduled: () -> ::Integer
|
|
17
|
+
|
|
18
|
+
def self.dead: () -> ::Integer
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
module Cosmo
|
|
2
|
+
module API
|
|
3
|
+
class Stream
|
|
4
|
+
LIMIT: ::Integer
|
|
5
|
+
|
|
6
|
+
self.@client: Client
|
|
7
|
+
@name: ::String
|
|
8
|
+
@offset: ::Integer
|
|
9
|
+
|
|
10
|
+
def self.all: () -> Array[Stream]
|
|
11
|
+
|
|
12
|
+
def self.jobs: () -> Array[Stream]
|
|
13
|
+
|
|
14
|
+
def self.client: () -> Client
|
|
15
|
+
|
|
16
|
+
attr_reader name: ::String
|
|
17
|
+
|
|
18
|
+
def initialize: (::String name) -> void
|
|
19
|
+
|
|
20
|
+
def info: () -> Hash[Symbol, untyped]
|
|
21
|
+
|
|
22
|
+
def offset: (::Integer) -> self
|
|
23
|
+
|
|
24
|
+
def total: () -> ::Integer
|
|
25
|
+
alias size total
|
|
26
|
+
|
|
27
|
+
def retries: () -> ::Integer
|
|
28
|
+
|
|
29
|
+
def each: (?from: ::Integer?) { (Job) -> void } -> void
|
|
30
|
+
|
|
31
|
+
def messages: (?page: ::Integer?, ?limit: ::Integer?) -> Array[Job]
|
|
32
|
+
|
|
33
|
+
def message: (::Integer seq) -> Job?
|
|
34
|
+
|
|
35
|
+
def retry: (::Integer seq) -> void
|
|
36
|
+
|
|
37
|
+
def delete: (::Integer seq) -> untyped
|
|
38
|
+
|
|
39
|
+
private
|
|
40
|
+
|
|
41
|
+
def client: () -> Client
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
data/sig/cosmo/client.rbs
CHANGED
|
@@ -19,11 +19,21 @@ module Cosmo
|
|
|
19
19
|
|
|
20
20
|
def create_stream: (::String | Symbol name, Hash[Symbol, untyped] config) -> untyped
|
|
21
21
|
|
|
22
|
-
def delete_stream: (::String | Symbol name, Hash[Symbol, untyped] params) -> untyped
|
|
22
|
+
def delete_stream: (::String | Symbol name, ?Hash[Symbol, untyped] params) -> untyped
|
|
23
23
|
|
|
24
|
-
def list_streams: -> Array[::String]
|
|
24
|
+
def list_streams: () -> Array[::String]
|
|
25
25
|
|
|
26
|
-
def
|
|
26
|
+
def list_consumers: (::String stream_name) -> Array[Hash[::String, untyped]]
|
|
27
|
+
|
|
28
|
+
def get_message: (::String | Symbol name, **untyped options) -> NATS::JetStream::API::RawStreamMsg
|
|
29
|
+
|
|
30
|
+
def delete_message: (::String name, ::Integer seq) -> Hash[::String, untyped]
|
|
31
|
+
|
|
32
|
+
def purge: (::String stream_name, ::String? subject) -> ::Integer?
|
|
33
|
+
|
|
34
|
+
def consumer_info: (::String stream_name, ::String consumer_name) -> NATS::JetStream::API::ConsumerInfo
|
|
35
|
+
|
|
36
|
+
def kv: (::String name, **untyped opts) -> NATS::KeyValue
|
|
27
37
|
|
|
28
38
|
def close: -> void
|
|
29
39
|
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.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Dmitry Vorotilin
|
|
@@ -37,6 +37,20 @@ dependencies:
|
|
|
37
37
|
- - "~>"
|
|
38
38
|
- !ruby/object:Gem::Version
|
|
39
39
|
version: '2.5'
|
|
40
|
+
- !ruby/object:Gem::Dependency
|
|
41
|
+
name: rack
|
|
42
|
+
requirement: !ruby/object:Gem::Requirement
|
|
43
|
+
requirements:
|
|
44
|
+
- - "~>"
|
|
45
|
+
- !ruby/object:Gem::Version
|
|
46
|
+
version: '3.0'
|
|
47
|
+
type: :runtime
|
|
48
|
+
prerelease: false
|
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
50
|
+
requirements:
|
|
51
|
+
- - "~>"
|
|
52
|
+
- !ruby/object:Gem::Version
|
|
53
|
+
version: '3.0'
|
|
40
54
|
description: Lightweight background and stream processing for Ruby
|
|
41
55
|
email:
|
|
42
56
|
- d.vorotilin@gmail.com
|
|
@@ -49,6 +63,13 @@ files:
|
|
|
49
63
|
- README.md
|
|
50
64
|
- bin/cosmo
|
|
51
65
|
- lib/cosmo.rb
|
|
66
|
+
- lib/cosmo/api.rb
|
|
67
|
+
- lib/cosmo/api/busy.rb
|
|
68
|
+
- lib/cosmo/api/counter.rb
|
|
69
|
+
- lib/cosmo/api/job.rb
|
|
70
|
+
- lib/cosmo/api/kv.rb
|
|
71
|
+
- lib/cosmo/api/stats.rb
|
|
72
|
+
- lib/cosmo/api/stream.rb
|
|
52
73
|
- lib/cosmo/cli.rb
|
|
53
74
|
- lib/cosmo/client.rb
|
|
54
75
|
- lib/cosmo/config.rb
|
|
@@ -65,15 +86,50 @@ files:
|
|
|
65
86
|
- lib/cosmo/stream/message.rb
|
|
66
87
|
- lib/cosmo/stream/processor.rb
|
|
67
88
|
- lib/cosmo/stream/serializer.rb
|
|
89
|
+
- lib/cosmo/utils.rb
|
|
68
90
|
- lib/cosmo/utils/hash.rb
|
|
69
91
|
- lib/cosmo/utils/json.rb
|
|
92
|
+
- lib/cosmo/utils/overrides.rb
|
|
70
93
|
- lib/cosmo/utils/signal.rb
|
|
71
94
|
- lib/cosmo/utils/stopwatch.rb
|
|
72
95
|
- lib/cosmo/utils/string.rb
|
|
73
96
|
- lib/cosmo/utils/thread_pool.rb
|
|
97
|
+
- lib/cosmo/utils/warnings.rb
|
|
74
98
|
- lib/cosmo/version.rb
|
|
99
|
+
- lib/cosmo/web.rb
|
|
100
|
+
- lib/cosmo/web/assets/app.css
|
|
101
|
+
- lib/cosmo/web/assets/htmx.2.0.8.min.js.gz
|
|
102
|
+
- lib/cosmo/web/context.rb
|
|
103
|
+
- lib/cosmo/web/controllers/actions.rb
|
|
104
|
+
- lib/cosmo/web/controllers/application.rb
|
|
105
|
+
- lib/cosmo/web/controllers/jobs.rb
|
|
106
|
+
- lib/cosmo/web/controllers/streams.rb
|
|
107
|
+
- lib/cosmo/web/helpers/application.rb
|
|
108
|
+
- lib/cosmo/web/renderer.rb
|
|
109
|
+
- lib/cosmo/web/views/actions/index.erb
|
|
110
|
+
- lib/cosmo/web/views/jobs/_busy.erb
|
|
111
|
+
- lib/cosmo/web/views/jobs/_dead.erb
|
|
112
|
+
- lib/cosmo/web/views/jobs/_enqueued.erb
|
|
113
|
+
- lib/cosmo/web/views/jobs/_scheduled.erb
|
|
114
|
+
- lib/cosmo/web/views/jobs/_stats.erb
|
|
115
|
+
- lib/cosmo/web/views/jobs/busy.erb
|
|
116
|
+
- lib/cosmo/web/views/jobs/dead.erb
|
|
117
|
+
- lib/cosmo/web/views/jobs/enqueued.erb
|
|
118
|
+
- lib/cosmo/web/views/jobs/index.erb
|
|
119
|
+
- lib/cosmo/web/views/jobs/scheduled.erb
|
|
120
|
+
- lib/cosmo/web/views/layout.erb
|
|
121
|
+
- lib/cosmo/web/views/streams/_info.erb
|
|
122
|
+
- lib/cosmo/web/views/streams/_table.erb
|
|
123
|
+
- lib/cosmo/web/views/streams/index.erb
|
|
124
|
+
- lib/cosmo/web/views/streams/info.erb
|
|
75
125
|
- lib/cosmonats.rb
|
|
76
126
|
- sig/cosmo.rbs
|
|
127
|
+
- sig/cosmo/api/busy.rbs
|
|
128
|
+
- sig/cosmo/api/counter.rbs
|
|
129
|
+
- sig/cosmo/api/job.rbs
|
|
130
|
+
- sig/cosmo/api/kv.rbs
|
|
131
|
+
- sig/cosmo/api/stats.rbs
|
|
132
|
+
- sig/cosmo/api/stream.rbs
|
|
77
133
|
- sig/cosmo/cli.rbs
|
|
78
134
|
- sig/cosmo/client.rbs
|
|
79
135
|
- sig/cosmo/config.rbs
|
|
@@ -119,7 +175,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
119
175
|
- !ruby/object:Gem::Version
|
|
120
176
|
version: '0'
|
|
121
177
|
requirements: []
|
|
122
|
-
rubygems_version:
|
|
178
|
+
rubygems_version: 4.0.8
|
|
123
179
|
specification_version: 4
|
|
124
180
|
summary: Lightweight background and stream processing
|
|
125
181
|
test_files: []
|