cosmonats 0.7.0 → 0.9.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.
Files changed (147) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +219 -113
  3. data/lib/cosmo/active_job/adapter.rb +1 -2
  4. data/lib/cosmo/api/counter.rb +17 -17
  5. data/lib/cosmo/api/cron/entry.rb +10 -11
  6. data/lib/cosmo/api/cron.rb +6 -3
  7. data/lib/cosmo/api/job.rb +1 -1
  8. data/lib/cosmo/api/kv.rb +3 -3
  9. data/lib/cosmo/api/registry.rb +1 -1
  10. data/lib/cosmo/api/stats/busy.rb +6 -1
  11. data/lib/cosmo/api/stats/metrics.rb +109 -0
  12. data/lib/cosmo/api/stats/processes.rb +14 -4
  13. data/lib/cosmo/api/stats/totals.rb +4 -12
  14. data/lib/cosmo/api/stats.rb +18 -2
  15. data/lib/cosmo/api/stream.rb +7 -2
  16. data/lib/cosmo/batch/counters.rb +19 -0
  17. data/lib/cosmo/batch.rb +6 -6
  18. data/lib/cosmo/cli.rb +21 -5
  19. data/lib/cosmo/client.rb +37 -14
  20. data/lib/cosmo/config/cosmo.yml +58 -0
  21. data/lib/cosmo/config/settings.rb +20 -0
  22. data/lib/cosmo/config.rb +144 -19
  23. data/lib/cosmo/heartbeat.rb +11 -0
  24. data/lib/cosmo/job/data.rb +17 -12
  25. data/lib/cosmo/job/enqueuer.rb +53 -0
  26. data/lib/cosmo/job/limit.rb +2 -2
  27. data/lib/cosmo/job/processor.rb +32 -58
  28. data/lib/cosmo/job/requeue.rb +20 -0
  29. data/lib/cosmo/job.rb +8 -22
  30. data/lib/cosmo/logger.rb +15 -2
  31. data/lib/cosmo/middleware/busy.rb +15 -0
  32. data/lib/cosmo/middleware/chain.rb +137 -0
  33. data/lib/cosmo/middleware/limit.rb +50 -0
  34. data/lib/cosmo/middleware/metrics.rb +39 -0
  35. data/lib/cosmo/{sentry/job_processor_middleware.rb → middleware/sentry.rb} +26 -30
  36. data/lib/cosmo/middleware/totals.rb +29 -0
  37. data/lib/cosmo/middleware.rb +7 -0
  38. data/lib/cosmo/processor.rb +11 -5
  39. data/lib/cosmo/publisher.rb +1 -13
  40. data/lib/cosmo/railtie.rb +2 -2
  41. data/lib/cosmo/services.rb +69 -0
  42. data/lib/cosmo/stream/processor.rb +7 -1
  43. data/lib/cosmo/utils/hash.rb +7 -8
  44. data/lib/cosmo/utils.rb +0 -1
  45. data/lib/cosmo/version.rb +1 -1
  46. data/lib/cosmo/web/assets/app.css +271 -571
  47. data/lib/cosmo/web/assets/app.js +158 -0
  48. data/lib/cosmo/web/assets/fonts/OFL.txt +92 -0
  49. data/lib/cosmo/web/assets/fonts/geist-mono.woff2 +0 -0
  50. data/lib/cosmo/web/assets/fonts/geist.woff2 +0 -0
  51. data/lib/cosmo/web/assets/logo.svg +10 -0
  52. data/lib/cosmo/web/cache.rb +75 -0
  53. data/lib/cosmo/web/chart.rb +122 -0
  54. data/lib/cosmo/web/circuit.rb +55 -0
  55. data/lib/cosmo/web/context.rb +0 -4
  56. data/lib/cosmo/web/controllers/application.rb +16 -0
  57. data/lib/cosmo/web/controllers/batches.rb +1 -0
  58. data/lib/cosmo/web/controllers/crons.rb +17 -2
  59. data/lib/cosmo/web/controllers/jobs.rb +59 -54
  60. data/lib/cosmo/web/controllers/metrics.rb +49 -0
  61. data/lib/cosmo/web/controllers/overview.rb +70 -0
  62. data/lib/cosmo/web/controllers/processes.rb +33 -0
  63. data/lib/cosmo/web/controllers/streams.rb +26 -28
  64. data/lib/cosmo/web/helpers/application.rb +67 -0
  65. data/lib/cosmo/web/renderer.rb +19 -6
  66. data/lib/cosmo/web/throughput.rb +104 -0
  67. data/lib/cosmo/web/views/batches/_table.erb +42 -43
  68. data/lib/cosmo/web/views/batches/index.erb +3 -10
  69. data/lib/cosmo/web/views/crons/_table.erb +32 -53
  70. data/lib/cosmo/web/views/crons/index.erb +2 -9
  71. data/lib/cosmo/web/views/jobs/_args.erb +5 -0
  72. data/lib/cosmo/web/views/jobs/_busy.erb +25 -121
  73. data/lib/cosmo/web/views/jobs/_dead.erb +42 -82
  74. data/lib/cosmo/web/views/jobs/_enqueued.erb +33 -113
  75. data/lib/cosmo/web/views/jobs/_panel.erb +29 -0
  76. data/lib/cosmo/web/views/jobs/_queue_row.erb +18 -0
  77. data/lib/cosmo/web/views/jobs/_queues.erb +20 -0
  78. data/lib/cosmo/web/views/jobs/_scheduled.erb +20 -54
  79. data/lib/cosmo/web/views/jobs/index.erb +4 -17
  80. data/lib/cosmo/web/views/layout.erb +73 -22
  81. data/lib/cosmo/web/views/metrics/_chart.erb +41 -0
  82. data/lib/cosmo/web/views/metrics/_panel.erb +13 -0
  83. data/lib/cosmo/web/views/metrics/_table.erb +25 -0
  84. data/lib/cosmo/web/views/metrics/index.erb +9 -0
  85. data/lib/cosmo/web/views/overview/_badges.erb +3 -0
  86. data/lib/cosmo/web/views/overview/_kpis.erb +19 -0
  87. data/lib/cosmo/web/views/overview/_running.erb +18 -0
  88. data/lib/cosmo/web/views/overview/_throughput.erb +50 -0
  89. data/lib/cosmo/web/views/overview/_workers.erb +25 -0
  90. data/lib/cosmo/web/views/overview/index.erb +28 -0
  91. data/lib/cosmo/web/views/processes/_table.erb +67 -0
  92. data/lib/cosmo/web/views/processes/index.erb +1 -0
  93. data/lib/cosmo/web/views/shared/_pager.erb +22 -0
  94. data/lib/cosmo/web/views/shared/unavailable.erb +7 -0
  95. data/lib/cosmo/web/views/streams/_info.erb +28 -86
  96. data/lib/cosmo/web/views/streams/_list.erb +7 -0
  97. data/lib/cosmo/web/views/streams/_pause_banner.erb +8 -16
  98. data/lib/cosmo/web/views/streams/_stream.erb +52 -0
  99. data/lib/cosmo/web/views/streams/index.erb +3 -11
  100. data/lib/cosmo/web/views/streams/info.erb +3 -11
  101. data/lib/cosmo/web.rb +67 -33
  102. data/lib/cosmo.rb +38 -0
  103. data/sig/cosmo/api/counter.rbs +2 -3
  104. data/sig/cosmo/api/cron/entry.rbs +2 -1
  105. data/sig/cosmo/api/stats/busy.rbs +3 -1
  106. data/sig/cosmo/api/stats/metrics.rbs +42 -0
  107. data/sig/cosmo/api/stats/processes.rbs +3 -0
  108. data/sig/cosmo/api/stats/totals.rbs +3 -2
  109. data/sig/cosmo/api/stats.rbs +4 -0
  110. data/sig/cosmo/api/stream.rbs +2 -0
  111. data/sig/cosmo/batch/counters.rbs +10 -0
  112. data/sig/cosmo/batch.rbs +3 -4
  113. data/sig/cosmo/cli.rbs +2 -0
  114. data/sig/cosmo/client.rbs +4 -1
  115. data/sig/cosmo/config/settings.rbs +31 -0
  116. data/sig/cosmo/config.rbs +59 -5
  117. data/sig/cosmo/heartbeat.rbs +2 -0
  118. data/sig/cosmo/job/data.rbs +5 -3
  119. data/sig/cosmo/job/enqueuer.rbs +11 -0
  120. data/sig/cosmo/job/processor.rbs +3 -5
  121. data/sig/cosmo/job/requeue.rbs +9 -0
  122. data/sig/cosmo/job.rbs +0 -2
  123. data/sig/cosmo/logger.rbs +6 -0
  124. data/sig/cosmo/middleware/chain.rbs +51 -0
  125. data/sig/cosmo/middleware/sentry.rbs +14 -0
  126. data/sig/cosmo/middleware.rbs +35 -0
  127. data/sig/cosmo/processor.rbs +2 -0
  128. data/sig/cosmo/publisher.rbs +1 -9
  129. data/sig/cosmo/services.rbs +18 -0
  130. data/sig/cosmo/stream/processor.rbs +2 -0
  131. data/sig/cosmo/utils/hash.rbs +2 -3
  132. data/sig/cosmo.rbs +11 -0
  133. metadata +60 -20
  134. data/lib/cosmo/sentry/auto.rb +0 -6
  135. data/lib/cosmo/utils/overrides.rb +0 -206
  136. data/lib/cosmo/utils/warnings.rb +0 -17
  137. data/lib/cosmo/web/controllers/actions.rb +0 -16
  138. data/lib/cosmo/web/views/actions/index.erb +0 -7
  139. data/lib/cosmo/web/views/jobs/_processes.erb +0 -131
  140. data/lib/cosmo/web/views/jobs/_stats.erb +0 -73
  141. data/lib/cosmo/web/views/jobs/_tabs.erb +0 -8
  142. data/lib/cosmo/web/views/jobs/busy.erb +0 -18
  143. data/lib/cosmo/web/views/jobs/dead.erb +0 -18
  144. data/lib/cosmo/web/views/jobs/enqueued.erb +0 -18
  145. data/lib/cosmo/web/views/jobs/scheduled.erb +0 -18
  146. data/lib/cosmo/web/views/streams/_stream_row.erb +0 -42
  147. data/lib/cosmo/web/views/streams/_table.erb +0 -25
@@ -1,13 +1,12 @@
1
1
  module Cosmo
2
2
  module API
3
3
  class Counter
4
- STREAM_NAME: ::String
5
- STREAM_CONFIG: Hash[Symbol, untyped]
6
-
7
4
  @namespace: ::String
8
5
 
9
6
  def self.setup!: () -> void
10
7
 
8
+ def self.stream_config: () -> Hash[Symbol, untyped]
9
+
11
10
  def initialize: (::String namespace) -> void
12
11
 
13
12
  def increment: (Symbol key, ?by: ::Integer) -> ::Integer
@@ -19,7 +19,8 @@ module Cosmo
19
19
  def schedule_subject: () -> ::String
20
20
  def target_subject: () -> ::String
21
21
  def dispatch_subject: () -> ::String
22
- def schedule_headers: () -> Hash[::String, ::String]
22
+ def schedule: () -> Hash[Symbol, ::String]
23
+ def headers: () -> Hash[::String, ::String]
23
24
  def job_name: () -> ::String
24
25
  def job_payload: () -> ::String
25
26
  def as_json: () -> Hash[Symbol, untyped]
@@ -12,7 +12,7 @@ module Cosmo
12
12
 
13
13
  def initialize: () -> void
14
14
 
15
- def with: (untyped message) { () -> void } -> void
15
+ def with: [T] (untyped message) { () -> T } -> T
16
16
 
17
17
  def add: (untyped message) -> void
18
18
 
@@ -20,6 +20,8 @@ module Cosmo
20
20
 
21
21
  def list: (?page: ::Integer?, ?limit: ::Integer) -> Array[Hash[Symbol, untyped]]
22
22
 
23
+ def by_stream: () -> Hash[::String, ::Integer]
24
+
23
25
  private
24
26
 
25
27
  def heartbeat_loop: () -> void
@@ -0,0 +1,42 @@
1
+ module Cosmo
2
+ module API
3
+ module Stats
4
+ class Metrics < Counter
5
+ STREAM_NAME: ::String
6
+ DESCRIPTION: ::String
7
+ DAY: Integer
8
+
9
+ self.@instance: Metrics
10
+
11
+ @lock: Thread::Mutex
12
+ @buffer: Hash[[::String, ::String], Hash[Symbol, Numeric]]
13
+
14
+ def self.instance: () -> Metrics
15
+
16
+ def self.stream_config: () -> Hash[Symbol, untyped]
17
+
18
+ def initialize: () -> void
19
+
20
+ def record: (::String job_class, ?exec_ms: Numeric?, ?wait_ms: Numeric?, ?failed: bool) -> void
21
+
22
+ def flush: () -> void
23
+
24
+ def summary: (?days: Integer) -> Array[Hash[Symbol, untyped]]
25
+
26
+ def daily: (?::String? job_class, ?days: Integer) -> Array[Hash[Symbol, untyped]]
27
+
28
+ private
29
+
30
+ def buffer: () -> Hash[[::String, ::String], Hash[Symbol, Numeric]]
31
+
32
+ def read: (Integer days) -> Array[[[::String, ::String, Symbol], Integer]]
33
+
34
+ def dates: (Integer days) -> Array[::String]
35
+
36
+ def row: (Hash[Symbol, Numeric] sums) -> Hash[Symbol, untyped]
37
+
38
+ def average: (Numeric total, Numeric count) -> Float?
39
+ end
40
+ end
41
+ end
42
+ end
@@ -4,6 +4,9 @@ module Cosmo
4
4
  class Processes < Registry
5
5
  TTL: ::Integer
6
6
  BUCKET: ::String
7
+ KINDS: Array[::String]
8
+
9
+ def self.kind: (Hash[Symbol, untyped] process) -> ::String
7
10
 
8
11
  def list: (?page: ::Integer?, ?limit: ::Integer) -> Array[Hash[Symbol, untyped]]
9
12
 
@@ -2,12 +2,13 @@ module Cosmo
2
2
  module API
3
3
  module Stats
4
4
  class Totals < Counter
5
+ STREAM_NAME: ::String
6
+ DESCRIPTION: ::String
7
+
5
8
  self.@instance: Totals
6
9
 
7
10
  def self.instance: () -> Totals
8
11
 
9
- def with: () { () -> bool } -> void
10
-
11
12
  def processed: () -> ::Integer
12
13
 
13
14
  def failed: () -> ::Integer
@@ -16,6 +16,10 @@ module Cosmo
16
16
  def self.scheduled: () -> ::Integer
17
17
 
18
18
  def self.dead: () -> ::Integer
19
+
20
+ def self.queues: () -> Array[Hash[Symbol, untyped]]
21
+
22
+ def self.queue: (Stream stream, ?Hash[::String, ::Integer] busy) -> Hash[Symbol, untyped]
19
23
  end
20
24
  end
21
25
  end
@@ -26,6 +26,8 @@ module Cosmo
26
26
 
27
27
  def retries: () -> ::Integer
28
28
 
29
+ def consumers: () -> Array[Hash[::String, untyped]]
30
+
29
31
  def each: () { (Job) -> void } -> void
30
32
 
31
33
  def messages: (?page: ::Integer?, ?limit: ::Integer?) -> Array[Job]
@@ -0,0 +1,10 @@
1
+ module Cosmo
2
+ class Batch
3
+ class Counters < API::Counter
4
+ STREAM_NAME: ::String
5
+ DESCRIPTION: ::String
6
+
7
+ def self.stream_config: () -> Hash[Symbol, untyped]
8
+ end
9
+ end
10
+ end
data/sig/cosmo/batch.rbs CHANGED
@@ -3,17 +3,16 @@ module Cosmo
3
3
  extend Dispatcher
4
4
 
5
5
  BUCKET: ::String
6
- DEFAULT_EXPIRY: ::String
7
6
  EVENTS: ::Array[Symbol]
8
7
 
9
- self.@counter: API::Counter
8
+ self.@counter: Batch::Counters
10
9
  self.@kv: API::KV
11
10
 
12
11
  def self.current: () -> Batch?
13
12
 
14
13
  def self.notify: (::String bid, ::String jid, success: bool) -> void
15
14
 
16
- def self.counter: () -> API::Counter
15
+ def self.counter: () -> Batch::Counters
17
16
 
18
17
  def self.kv: () -> API::KV
19
18
 
@@ -36,7 +35,7 @@ module Cosmo
36
35
 
37
36
  private
38
37
 
39
- def counter: () -> API::Counter
38
+ def counter: () -> Batch::Counters
40
39
 
41
40
  def kv: () -> API::KV
42
41
 
data/sig/cosmo/cli.rbs CHANGED
@@ -20,6 +20,8 @@ module Cosmo
20
20
 
21
21
  def load_config: (Hash[Symbol, untyped] flags) -> void
22
22
 
23
+ def run_init: () -> void
24
+
23
25
  def boot_application: () -> void
24
26
 
25
27
  def require_path: (::String? path) -> void
data/sig/cosmo/client.rbs CHANGED
@@ -2,6 +2,7 @@ module Cosmo
2
2
  class Client
3
3
  JS_TIMEOUT: ::Integer
4
4
  CONNECT_TIMEOUT: ::Integer
5
+ MAX_RECONNECT_ATTEMPTS: ::Integer
5
6
 
6
7
  attr_reader name: ::String
7
8
 
@@ -54,6 +55,8 @@ module Cosmo
54
55
 
55
56
  def get_message: (::String | Symbol name, **untyped options) -> NATS::JetStream::API::RawStreamMsg
56
57
 
58
+ def last_messages: (::String stream_name, Array[::String] filters) -> Hash[::String, ::String]
59
+
57
60
  def delete_message: (::String name, ::Integer seq) -> Hash[::String, untyped]
58
61
 
59
62
  def purge: (::String stream_name, ::String? subject) -> ::Integer?
@@ -66,6 +69,6 @@ module Cosmo
66
69
 
67
70
  def ephemeral_subscribe: (::String | Array[::String] subject, Hash[Symbol, untyped] config) -> untyped
68
71
 
69
- def create_kv_with_msg_ttl: (::String name, **untyped opts) -> untyped
72
+ def create_kv_with_msg_ttl: (::String name, ?replicas: Integer, **untyped opts) -> untyped
70
73
  end
71
74
  end
@@ -0,0 +1,31 @@
1
+ module Cosmo
2
+ class Config < ::Hash[Symbol, untyped]
3
+ class Scheduled
4
+ attr_accessor enabled: bool
5
+
6
+ def self.new: (enabled: bool) -> Scheduled
7
+ end
8
+
9
+ class Dead
10
+ attr_accessor enabled: bool
11
+ attr_accessor max_age: Numeric | ::String
12
+ attr_accessor max_msgs: Integer
13
+ attr_accessor max_bytes: Integer
14
+
15
+ def self.new: (enabled: bool, max_age: Numeric | ::String, max_msgs: Integer, max_bytes: Integer) -> Dead
16
+ end
17
+
18
+ class Batches
19
+ attr_accessor expiry: Numeric | ::String
20
+
21
+ def self.new: (expiry: Numeric | ::String) -> Batches
22
+ end
23
+
24
+ class Metrics
25
+ attr_accessor enabled: bool
26
+ attr_accessor retention: Numeric | ::String
27
+
28
+ def self.new: (enabled: bool, retention: Numeric | ::String) -> Metrics
29
+ end
30
+ end
31
+ end
data/sig/cosmo/config.rbs CHANGED
@@ -2,6 +2,8 @@ module Cosmo
2
2
  class Config < ::Hash[Symbol, untyped]
3
3
  NANO: Integer
4
4
  DEFAULT_PATH: ::String
5
+ DEFAULTS_FILE: ::String
6
+ SERVICE_STREAMS: Array[Symbol]
5
7
 
6
8
  self.@instance: Config
7
9
  self.@internal: Hash[Symbol, untyped]
@@ -12,8 +14,14 @@ module Cosmo
12
14
 
13
15
  def self.to_ns: (Numeric seconds) -> ::Integer
14
16
 
17
+ def self.read: (::String path) -> Hash[Symbol, untyped]
18
+
15
19
  def self.parse_file: (::String path) -> Hash[Symbol, untyped]
16
20
 
21
+ def self.build: (Hash[Symbol, untyped] user) -> Hash[Symbol, untyped]
22
+
23
+ def self.validate!: (Hash[Symbol, untyped] config) -> void
24
+
17
25
  def self.normalize!: (Hash[Symbol, untyped] config) -> void
18
26
 
19
27
  def self.deliver_policy: (Symbol | ::String | Time start_position) -> Hash[Symbol, ::String]
@@ -24,15 +32,61 @@ module Cosmo
24
32
 
25
33
  def self.dig: (*Symbol keys) -> untyped
26
34
 
27
- def self.to_h: () -> Hash[Symbol, untyped]
35
+ def self.load: (?::String? path, ?overrides: Hash[Symbol, untyped]?) -> void
36
+
37
+ def self.replicas: () -> Integer
38
+
39
+ def self.scheduled: () -> Scheduled
40
+
41
+ def self.dead: () -> Dead
42
+
43
+ def self.batches: () -> Batches
44
+
45
+ def self.metrics: () -> Metrics
46
+
47
+ def self.server_middleware: () ?{ (Middleware::Chain chain) -> void } -> Middleware::Chain
48
+
49
+ def self.client_middleware: () ?{ (Middleware::Chain chain) -> void } -> Middleware::Chain
50
+
51
+ def self.error_handlers: () -> Array[untyped]
52
+
53
+ @server_middleware: Middleware::Chain
54
+
55
+ def load: (?::String? path, ?overrides: Hash[Symbol, untyped]?) -> void
56
+
57
+ def server_middleware: () ?{ (Middleware::Chain chain) -> void } -> Middleware::Chain
58
+
59
+ @client_middleware: Middleware::Chain
60
+
61
+ def client_middleware: () ?{ (Middleware::Chain chain) -> void } -> Middleware::Chain
62
+
63
+ @error_handlers: Array[untyped]
64
+
65
+ def error_handlers: () -> Array[untyped]
66
+
67
+ @replicas: Integer?
68
+ @scheduled: Scheduled
69
+ @dead: Dead
70
+ @batches: Batches
71
+
72
+ attr_writer replicas: Integer
73
+
74
+ def replicas: () -> Integer
75
+
76
+ def scheduled: () -> Scheduled
77
+
78
+ def dead: () -> Dead
79
+
80
+ def batches: () -> Batches
28
81
 
29
- def self.set: (*untyped) -> untyped
82
+ @metrics: Metrics
30
83
 
31
- def self.load: (?::String? path) -> void
84
+ def metrics: () -> Metrics
32
85
 
86
+ def logger: () -> untyped
33
87
 
34
- def set: (*untyped) -> untyped
88
+ def logger=: (untyped logger) -> void
35
89
 
36
- def load: (?::String? path) -> void
90
+ def log_level=: (Symbol | ::String | Integer level) -> void
37
91
  end
38
92
  end
@@ -17,6 +17,8 @@ module Cosmo
17
17
 
18
18
  def beat: () -> void
19
19
 
20
+ def flush: () -> void
21
+
20
22
  def identity: () -> ::String
21
23
 
22
24
  def info: () -> Hash[Symbol, untyped]
@@ -17,16 +17,18 @@ module Cosmo
17
17
 
18
18
  def stream: (?target: bool) -> Symbol
19
19
 
20
- def subject: (?target: bool) -> Array[::String]
20
+ def subject: () -> ::String
21
+
22
+ def headers: () -> Hash[::String, untyped]
21
23
 
22
24
  def as_json: () -> { jid: ::String, class: ::String, args: Array[untyped], retry: Integer, dead: bool }
23
25
 
24
26
  def to_json: (*untyped _args) -> ::String?
25
27
 
26
- def to_args: () -> [::String, ::String, Hash[Symbol, untyped]]
27
-
28
28
  private
29
29
 
30
+ def subject_for: (Symbol | ::String stream) -> ::String
31
+
30
32
  def validate!: () -> void
31
33
 
32
34
  def retries: () -> Integer
@@ -0,0 +1,11 @@
1
+ module Cosmo
2
+ module Job
3
+ module Enqueuer
4
+ def self.enqueue: (::String class_name, Array[untyped] args, Hash[Symbol, untyped] options, ?batch: Batch?) -> ::String?
5
+
6
+ def self.pipe: (::String class_name, Data data) -> bool
7
+
8
+ def self.publish: (Data data, Hash[Symbol, untyped] payload) -> untyped
9
+ end
10
+ end
11
+ end
@@ -53,13 +53,11 @@ module Cosmo
53
53
 
54
54
  def reject_message: (untyped message, Exception error, ?Hash[Symbol, untyped]? data) -> void
55
55
 
56
- def move_message: (untyped message, ?Hash[Symbol, untyped]? data, ?Exception? exception) -> void
57
-
58
- def with_stats: (untyped message) { () -> untyped } -> void
56
+ def error_context: (untyped message, Hash[Symbol, untyped]? data, ?source: Symbol) -> Hash[Symbol, untyped]
59
57
 
60
- def acquire_concurrency_slot: (untyped worker_class, untyped message, Hash[Symbol, untyped] data) -> (::String | false)
58
+ def move_message: (untyped message, ?Hash[Symbol, untyped]? data, ?Exception? exception) -> void
61
59
 
62
- def perform_job: (untyped job_instance, data: Hash[Symbol, untyped], message: untyped, ?duration: Float?) -> untyped
60
+ def perform_job: (untyped job_instance, data: Hash[Symbol, untyped], message: untyped) -> untyped
63
61
  end
64
62
  end
65
63
  end
@@ -0,0 +1,9 @@
1
+ module Cosmo
2
+ module Job
3
+ class Requeue < StandardError
4
+ attr_reader delay: Numeric
5
+
6
+ def initialize: (?Numeric delay) -> void
7
+ end
8
+ end
9
+ end
data/sig/cosmo/job.rbs CHANGED
@@ -31,8 +31,6 @@ module Cosmo
31
31
  private
32
32
 
33
33
  def client: () -> Client
34
-
35
- def publish: (Data data, Batch? batch) -> void
36
34
  end
37
35
 
38
36
  attr_accessor jid: ::String
data/sig/cosmo/logger.rbs CHANGED
@@ -45,5 +45,11 @@ module Cosmo
45
45
  def self.without: (*Symbol) -> nil
46
46
 
47
47
  def self.instance: () -> untyped
48
+
49
+ def self.instance=: (untyped logger) -> void
50
+
51
+ def self.level=: (Symbol | ::String | Integer level) -> void
52
+
53
+ def self.coerce_level: (Symbol | ::String | Integer level) -> Integer
48
54
  end
49
55
  end
@@ -0,0 +1,51 @@
1
+ module Cosmo
2
+ module Middleware
3
+ class Chain
4
+ include Enumerable[Entry]
5
+
6
+ class Entry
7
+ attr_accessor klass: Class
8
+ attr_accessor args: Array[untyped]
9
+ attr_accessor kwargs: Hash[Symbol, untyped]
10
+
11
+ def self.new: (Class klass, Array[untyped] args, Hash[Symbol, untyped] kwargs) -> Entry
12
+
13
+ def build: () -> untyped
14
+ end
15
+
16
+ @entries: Array[Entry]
17
+
18
+ def initialize: () ?{ (Chain chain) -> void } -> void
19
+
20
+ def each: () { (Entry entry) -> void } -> Array[Entry]
21
+
22
+ def add: (Class klass, *untyped args, **untyped kwargs) -> Chain
23
+
24
+ def prepend: (Class klass, *untyped args, **untyped kwargs) -> Chain
25
+
26
+ def insert_before: (Class existing, Class klass, *untyped args, **untyped kwargs) -> Chain
27
+
28
+ def insert_after: (Class existing, Class klass, *untyped args, **untyped kwargs) -> Chain
29
+
30
+ def remove: (Class klass) -> Chain
31
+
32
+ def exists?: (Class klass) -> bool
33
+
34
+ alias include? exists?
35
+
36
+ def empty?: () -> bool
37
+
38
+ def clear: () -> Chain
39
+
40
+ def invoke: (*untyped args) { () -> untyped } -> untyped
41
+
42
+ private
43
+
44
+ def traverse: (Array[untyped] chain, Integer position, Array[untyped] args) { () -> untyped } -> untyped
45
+
46
+ def index: (Class klass) -> Integer?
47
+
48
+ def take: (Class klass, Array[untyped] args, Hash[Symbol, untyped] kwargs) -> Entry
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,14 @@
1
+ module Cosmo
2
+ module Middleware
3
+ class Sentry
4
+ NAME_PREFIX: ::String
5
+ OP_NAME: ::String
6
+ SPAN_ORIGIN: ::String
7
+ STATUS_OK: ::Integer
8
+ STATUS_FAIL: ::Integer
9
+ ERROR_HANDLER: ^(Exception error, Hash[Symbol, untyped] context) -> void
10
+
11
+ def call: (untyped job, Hash[Symbol, untyped] data, untyped message) { () -> untyped } -> untyped
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,35 @@
1
+ module Cosmo
2
+ module Middleware
3
+ class Limit
4
+ def call: (untyped job, Hash[Symbol, untyped] data, untyped message) { () -> untyped } -> untyped
5
+
6
+ private
7
+
8
+ def acquire: (untyped job_class, Hash[Symbol, untyped] data) -> ::String?
9
+
10
+ def timeout: (Numeric? duration) { () -> untyped } -> untyped
11
+ end
12
+
13
+ class Busy
14
+ def call: (untyped job, Hash[Symbol, untyped] data, untyped message) { () -> untyped } -> untyped
15
+ end
16
+
17
+ class Metrics
18
+ def call: (untyped job, Hash[Symbol, untyped] data, untyped message) { () -> untyped } -> untyped
19
+
20
+ private
21
+
22
+ def job_name: (untyped job, Hash[Symbol, untyped] data) -> ::String
23
+
24
+ def clock: () -> Float
25
+ end
26
+
27
+ class Totals
28
+ def call: (untyped job, Hash[Symbol, untyped] data, untyped message) { () -> untyped } -> untyped
29
+
30
+ private
31
+
32
+ def increment: (Symbol key) -> void
33
+ end
34
+ end
35
+ end
@@ -60,5 +60,7 @@ module Cosmo
60
60
  def stopwatch: () -> Utils::Stopwatch
61
61
 
62
62
  def consumer_state: () -> untyped
63
+
64
+ def backoff_key: (Hash[Symbol, untyped] config) -> String
63
65
  end
64
66
  end
@@ -4,18 +4,10 @@ module Cosmo
4
4
 
5
5
  def self.instance: () -> Publisher
6
6
 
7
- def self.publish: (::String subject, untyped data, ?serializer: Module?, **untyped options) -> bool
8
-
9
- def self.publish_job: (Job::Data data) -> ::String
10
-
11
- def self.publish_batch: (::String subject, Array[untyped] batch, **untyped options) -> void
7
+ def self.publish: (::String subject, untyped data, ?serializer: Module?, **untyped options) -> untyped
12
8
 
13
9
  def initialize: () -> void
14
10
 
15
11
  def publish: (::String subject, untyped data, ?serializer: Module?, **untyped options) -> untyped
16
-
17
- def publish_job: (Job::Data data) -> ::String
18
-
19
- def publish_batch: (::String subject, Array[untyped] batch, **untyped options) -> void
20
12
  end
21
13
  end
@@ -0,0 +1,18 @@
1
+ module Cosmo
2
+ module Services
3
+ SCHEDULED: ::String
4
+ DEAD: ::String
5
+ METADATA: Hash[::String, ::String]
6
+ RETENTION_CHANGE: Integer
7
+
8
+ def self.scheduled_stream: () -> Hash[Symbol, untyped]?
9
+
10
+ def self.scheduled_consumer: () -> Hash[Symbol, untyped]?
11
+
12
+ def self.dead_stream: () -> Hash[Symbol, untyped]?
13
+
14
+ def self.setup!: () -> Array[::String]
15
+
16
+ def self.setup_stream: (::String name, Hash[Symbol, untyped] config) -> void
17
+ end
18
+ end
@@ -13,6 +13,8 @@ module Cosmo
13
13
 
14
14
  def fetch_subjects: (Hash[Symbol, untyped] config) -> untyped
15
15
 
16
+ def backoff_key: (Hash[Symbol, untyped] config) -> String
17
+
16
18
  def fetch_timeout: (Hash[Symbol, untyped] config) -> Float
17
19
 
18
20
  def static_config: -> Array[Hash[Symbol, untyped]]
@@ -7,15 +7,14 @@ module Cosmo
7
7
 
8
8
  def self.dup: [T] (T hash) -> T
9
9
 
10
- def self.set: (::Hash[untyped, untyped] hash, *untyped keys, value: untyped) -> untyped
11
-
12
10
  def symbolize_keys!: (untyped obj) -> (::Hash[Symbol, untyped] | Array[untyped] | untyped)
13
11
 
14
12
  def stringify_keys: (untyped obj) -> (::Hash[String, untyped] | Array[untyped] | untyped)
15
13
 
14
+ def deep_merge: (::Hash[untyped, untyped] base, ::Hash[untyped, untyped] other) -> ::Hash[untyped, untyped]
15
+
16
16
  def dup: [T] (T hash) -> T
17
17
 
18
- def set: (::Hash[untyped, untyped] hash, *untyped keys, value: untyped) -> untyped
19
18
  end
20
19
  end
21
20
  end
data/sig/cosmo.rbs CHANGED
@@ -1,6 +1,10 @@
1
1
  module Cosmo
2
2
  VERSION: ::String
3
3
 
4
+ def self.configure: () { (Config config) -> void } -> void
5
+
6
+ def self.handle_error: (Exception error, Hash[Symbol, untyped] context) -> void
7
+
4
8
  class Error < StandardError
5
9
  end
6
10
 
@@ -10,10 +14,17 @@ module Cosmo
10
14
  class NotImplementedError < Error
11
15
  end
12
16
 
17
+ class ConfigError < Error
18
+ end
19
+
13
20
  class ConfigNotFoundError < Error
14
21
  def initialize: (::String config_file) -> void
15
22
  end
16
23
 
24
+ class SchedulingDisabledError < Error
25
+ def initialize: () -> void
26
+ end
27
+
17
28
  class StreamNotFoundError < Error
18
29
  def initialize: (::String stream_name) -> void
19
30
  end