cosmonats 0.6.0 → 0.8.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 (131) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE.txt +21 -169
  3. data/README.md +296 -116
  4. data/lib/cosmo/active_job/adapter.rb +1 -2
  5. data/lib/cosmo/api/counter.rb +18 -15
  6. data/lib/cosmo/api/cron/entry.rb +23 -3
  7. data/lib/cosmo/api/cron.rb +25 -26
  8. data/lib/cosmo/api/job.rb +30 -0
  9. data/lib/cosmo/api/kv.rb +31 -11
  10. data/lib/cosmo/api/registry.rb +68 -0
  11. data/lib/cosmo/api/stats/busy.rb +63 -0
  12. data/lib/cosmo/api/stats/metrics.rb +109 -0
  13. data/lib/cosmo/api/stats/processes.rb +47 -0
  14. data/lib/cosmo/api/stats/totals.rb +27 -0
  15. data/lib/cosmo/api/stats.rb +8 -6
  16. data/lib/cosmo/api/stream.rb +1 -1
  17. data/lib/cosmo/api.rb +3 -2
  18. data/lib/cosmo/batch/counters.rb +19 -0
  19. data/lib/cosmo/batch.rb +15 -8
  20. data/lib/cosmo/cli.rb +46 -10
  21. data/lib/cosmo/client.rb +61 -7
  22. data/lib/cosmo/config/cosmo.yml +58 -0
  23. data/lib/cosmo/config/settings.rb +20 -0
  24. data/lib/cosmo/config.rb +144 -15
  25. data/lib/cosmo/engine.rb +103 -4
  26. data/lib/cosmo/heartbeat.rb +140 -0
  27. data/lib/cosmo/http_server/handler.rb +44 -0
  28. data/lib/cosmo/http_server/health.rb +39 -0
  29. data/lib/cosmo/http_server/ping.rb +23 -0
  30. data/lib/cosmo/http_server.rb +62 -0
  31. data/lib/cosmo/job/data.rb +17 -12
  32. data/lib/cosmo/job/enqueuer.rb +53 -0
  33. data/lib/cosmo/job/failure.rb +52 -0
  34. data/lib/cosmo/job/limit.rb +2 -2
  35. data/lib/cosmo/job/processor.rb +110 -73
  36. data/lib/cosmo/job/requeue.rb +20 -0
  37. data/lib/cosmo/job/stream_filter.rb +54 -0
  38. data/lib/cosmo/job.rb +10 -22
  39. data/lib/cosmo/logger.rb +15 -2
  40. data/lib/cosmo/middleware/busy.rb +15 -0
  41. data/lib/cosmo/middleware/chain.rb +137 -0
  42. data/lib/cosmo/middleware/limit.rb +50 -0
  43. data/lib/cosmo/middleware/metrics.rb +39 -0
  44. data/lib/cosmo/middleware/sentry.rb +61 -0
  45. data/lib/cosmo/middleware/totals.rb +29 -0
  46. data/lib/cosmo/middleware.rb +7 -0
  47. data/lib/cosmo/processor.rb +49 -8
  48. data/lib/cosmo/publisher.rb +1 -13
  49. data/lib/cosmo/railtie.rb +2 -2
  50. data/lib/cosmo/services.rb +69 -0
  51. data/lib/cosmo/stream/message.rb +2 -1
  52. data/lib/cosmo/stream/processor.rb +12 -1
  53. data/lib/cosmo/utils/hash.rb +7 -8
  54. data/lib/cosmo/utils/json.rb +1 -1
  55. data/lib/cosmo/utils/overrides.rb +16 -10
  56. data/lib/cosmo/utils/thread_pool.rb +5 -0
  57. data/lib/cosmo/version.rb +1 -1
  58. data/lib/cosmo/web/assets/app.css +79 -0
  59. data/lib/cosmo/web/chart.rb +98 -0
  60. data/lib/cosmo/web/controllers/crons.rb +8 -0
  61. data/lib/cosmo/web/controllers/jobs.rb +43 -5
  62. data/lib/cosmo/web/controllers/metrics.rb +48 -0
  63. data/lib/cosmo/web/helpers/application.rb +20 -1
  64. data/lib/cosmo/web/views/batches/_table.erb +11 -0
  65. data/lib/cosmo/web/views/batches/index.erb +1 -1
  66. data/lib/cosmo/web/views/jobs/_busy.erb +70 -4
  67. data/lib/cosmo/web/views/jobs/_dead.erb +29 -16
  68. data/lib/cosmo/web/views/jobs/_enqueued.erb +10 -0
  69. data/lib/cosmo/web/views/jobs/_processes.erb +145 -0
  70. data/lib/cosmo/web/views/jobs/_scheduled.erb +1 -1
  71. data/lib/cosmo/web/views/jobs/_stats.erb +4 -0
  72. data/lib/cosmo/web/views/jobs/_tabs.erb +6 -0
  73. data/lib/cosmo/web/views/jobs/busy.erb +1 -1
  74. data/lib/cosmo/web/views/jobs/dead.erb +2 -2
  75. data/lib/cosmo/web/views/jobs/enqueued.erb +1 -1
  76. data/lib/cosmo/web/views/jobs/index.erb +7 -1
  77. data/lib/cosmo/web/views/jobs/scheduled.erb +1 -1
  78. data/lib/cosmo/web/views/layout.erb +1 -1
  79. data/lib/cosmo/web/views/metrics/_chart.erb +36 -0
  80. data/lib/cosmo/web/views/metrics/_panel.erb +13 -0
  81. data/lib/cosmo/web/views/metrics/_table.erb +41 -0
  82. data/lib/cosmo/web/views/metrics/index.erb +17 -0
  83. data/lib/cosmo/web/views/streams/index.erb +1 -1
  84. data/lib/cosmo/web.rb +5 -0
  85. data/lib/cosmo.rb +51 -0
  86. data/sig/cosmo/api/counter.rbs +3 -6
  87. data/sig/cosmo/api/cron/entry.rbs +2 -0
  88. data/sig/cosmo/api/cron.rbs +4 -2
  89. data/sig/cosmo/api/job.rbs +12 -0
  90. data/sig/cosmo/api/kv.rbs +7 -1
  91. data/sig/cosmo/api/registry.rbs +30 -0
  92. data/sig/cosmo/api/stats/busy.rbs +31 -0
  93. data/sig/cosmo/api/stats/metrics.rbs +42 -0
  94. data/sig/cosmo/api/stats/processes.rbs +19 -0
  95. data/sig/cosmo/api/stats/totals.rbs +18 -0
  96. data/sig/cosmo/batch/counters.rbs +10 -0
  97. data/sig/cosmo/batch.rbs +3 -4
  98. data/sig/cosmo/cli.rbs +6 -0
  99. data/sig/cosmo/client.rbs +15 -2
  100. data/sig/cosmo/config/settings.rbs +31 -0
  101. data/sig/cosmo/config.rbs +59 -5
  102. data/sig/cosmo/engine.rbs +29 -0
  103. data/sig/cosmo/heartbeat.rbs +38 -0
  104. data/sig/cosmo/http_server/handler.rbs +17 -0
  105. data/sig/cosmo/http_server/health.rbs +21 -0
  106. data/sig/cosmo/http_server/ping.rbs +14 -0
  107. data/sig/cosmo/http_server.rbs +22 -0
  108. data/sig/cosmo/job/data.rbs +5 -3
  109. data/sig/cosmo/job/enqueuer.rbs +11 -0
  110. data/sig/cosmo/job/failure.rbs +28 -0
  111. data/sig/cosmo/job/processor.rbs +18 -4
  112. data/sig/cosmo/job/requeue.rbs +9 -0
  113. data/sig/cosmo/job/stream_filter.rbs +25 -0
  114. data/sig/cosmo/job.rbs +0 -2
  115. data/sig/cosmo/logger.rbs +6 -0
  116. data/sig/cosmo/middleware/chain.rbs +51 -0
  117. data/sig/cosmo/middleware/sentry.rbs +14 -0
  118. data/sig/cosmo/middleware.rbs +35 -0
  119. data/sig/cosmo/processor.rbs +14 -1
  120. data/sig/cosmo/publisher.rbs +1 -9
  121. data/sig/cosmo/services.rbs +18 -0
  122. data/sig/cosmo/stream/message.rbs +3 -1
  123. data/sig/cosmo/stream/processor.rbs +4 -0
  124. data/sig/cosmo/utils/hash.rbs +2 -3
  125. data/sig/cosmo/utils/thread_pool.rbs +3 -0
  126. data/sig/cosmo.rbs +15 -0
  127. metadata +62 -22
  128. data/lib/cosmo/api/busy.rb +0 -66
  129. data/lib/cosmo/sentry/auto.rb +0 -6
  130. data/lib/cosmo/sentry/job_processor_middleware.rb +0 -66
  131. data/sig/cosmo/api/busy.rbs +0 -35
@@ -0,0 +1,31 @@
1
+ module Cosmo
2
+ module API
3
+ module Stats
4
+ class Busy < Registry
5
+ TTL: ::Integer
6
+ HEARTBEAT: ::Integer
7
+ BUCKET: ::String
8
+
9
+ @messages: Hash[::Integer, Hash[Symbol, untyped]]
10
+ @thread: Thread?
11
+ @worker_id: ::String
12
+
13
+ def initialize: () -> void
14
+
15
+ def with: [T] (untyped message) { () -> T } -> T
16
+
17
+ def add: (untyped message) -> void
18
+
19
+ def delete: (untyped message) -> void
20
+
21
+ def list: (?page: ::Integer?, ?limit: ::Integer) -> Array[Hash[Symbol, untyped]]
22
+
23
+ private
24
+
25
+ def heartbeat_loop: () -> void
26
+
27
+ def worker_id: () -> ::String
28
+ end
29
+ end
30
+ end
31
+ end
@@ -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
@@ -0,0 +1,19 @@
1
+ module Cosmo
2
+ module API
3
+ module Stats
4
+ class Processes < Registry
5
+ TTL: ::Integer
6
+ BUCKET: ::String
7
+ KINDS: Array[::String]
8
+
9
+ def self.kind: (Hash[Symbol, untyped] process) -> ::String
10
+
11
+ def list: (?page: ::Integer?, ?limit: ::Integer) -> Array[Hash[Symbol, untyped]]
12
+
13
+ def register: (::String identity, Hash[Symbol, untyped] info) -> void
14
+
15
+ def unregister: (::String identity) -> void
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,18 @@
1
+ module Cosmo
2
+ module API
3
+ module Stats
4
+ class Totals < Counter
5
+ STREAM_NAME: ::String
6
+ DESCRIPTION: ::String
7
+
8
+ self.@instance: Totals
9
+
10
+ def self.instance: () -> Totals
11
+
12
+ def processed: () -> ::Integer
13
+
14
+ def failed: () -> ::Integer
15
+ end
16
+ end
17
+ end
18
+ end
@@ -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
@@ -8,6 +8,10 @@ module Cosmo
8
8
 
9
9
  def self.banner: () -> ::String
10
10
 
11
+ @argv: Array[::String]?
12
+
13
+ attr_reader argv: Array[::String]?
14
+
11
15
  def run: () -> void
12
16
 
13
17
  private
@@ -16,6 +20,8 @@ module Cosmo
16
20
 
17
21
  def load_config: (Hash[Symbol, untyped] flags) -> void
18
22
 
23
+ def run_init: () -> void
24
+
19
25
  def boot_application: () -> void
20
26
 
21
27
  def require_path: (::String? path) -> void
data/sig/cosmo/client.rbs CHANGED
@@ -1,15 +1,26 @@
1
1
  module Cosmo
2
2
  class Client
3
+ JS_TIMEOUT: ::Integer
4
+ CONNECT_TIMEOUT: ::Integer
5
+
6
+ attr_reader name: ::String
7
+
8
+ def self.default_name: () -> ::String
9
+ def self.js_timeout: () -> ::Integer
10
+ def self.connect_timeout: () -> ::Integer
11
+ def self.program_name: () -> ::String
12
+
3
13
  self.@instance: Client
4
14
  @nc: untyped
5
15
  @js: untyped
16
+ @name: ::String
6
17
 
7
18
  def self.instance: () -> Client
8
19
 
9
20
  attr_reader nc: untyped
10
21
  attr_reader js: untyped
11
22
 
12
- def initialize: (?nats_url: ::String) -> void
23
+ def initialize: (?nats_url: ::String, ?name: ::String) -> void
13
24
 
14
25
  def publish: (::String subject, ::String payload, **untyped params) -> untyped
15
26
 
@@ -43,6 +54,8 @@ module Cosmo
43
54
 
44
55
  def get_message: (::String | Symbol name, **untyped options) -> NATS::JetStream::API::RawStreamMsg
45
56
 
57
+ def last_messages: (::String stream_name, Array[::String] filters) -> Hash[::String, ::String]
58
+
46
59
  def delete_message: (::String name, ::Integer seq) -> Hash[::String, untyped]
47
60
 
48
61
  def purge: (::String stream_name, ::String? subject) -> ::Integer?
@@ -55,6 +68,6 @@ module Cosmo
55
68
 
56
69
  def ephemeral_subscribe: (::String | Array[::String] subject, Hash[Symbol, untyped] config) -> untyped
57
70
 
58
- def create_kv_with_msg_ttl: (::String name, **untyped opts) -> untyped
71
+ def create_kv_with_msg_ttl: (::String name, ?replicas: Integer, **untyped opts) -> untyped
59
72
  end
60
73
  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
data/sig/cosmo/engine.rbs CHANGED
@@ -6,16 +6,45 @@ module Cosmo
6
6
  @concurrency: Integer
7
7
  @pool: Utils::ThreadPool
8
8
  @running: untyped
9
+ @quiet: untyped
9
10
  @processors: Array[Processor]
11
+ @http_server: HTTPServer?
12
+ @heartbeat: Heartbeat?
10
13
 
11
14
  def self.run: (*untyped) -> void
12
15
 
16
+ def self.processors_for: ((::String | Symbol)? type) -> Array[Class]
17
+
13
18
  def self.instance: () -> Engine
14
19
 
20
+ attr_reader concurrency: Integer
21
+
15
22
  def initialize: () -> void
16
23
 
17
24
  def run: (::String? type, Hash[Symbol, untyped] options) -> void
18
25
 
26
+ def running?: () -> bool
27
+
28
+ def state: () -> ::String
29
+
30
+ def busy: () -> Integer
31
+
32
+ def subscriptions: () -> Hash[Symbol, Array[::String]]
33
+
19
34
  def shutdown: () -> void
35
+
36
+ private
37
+
38
+ def start_http_server: () -> void
39
+
40
+ def handle_shutdown: (Utils::Signal handler) -> Symbol
41
+
42
+ def quiet: () -> void
43
+
44
+ def unquiet: () -> void
45
+
46
+ def drain_and_exit: (Utils::Signal handler) -> void
47
+
48
+ def dump_threads: () -> void
20
49
  end
21
50
  end
@@ -0,0 +1,38 @@
1
+ module Cosmo
2
+ class Heartbeat
3
+ INTERVAL: ::Integer
4
+
5
+ @engine: Engine
6
+ @options: Hash[Symbol, untyped]
7
+ @started_at: ::Integer
8
+ @thread: Thread?
9
+ @identity: ::String
10
+ @static_info: Hash[Symbol, untyped]
11
+
12
+ def initialize: (Engine engine, ?options: Hash[Symbol, untyped]) -> void
13
+
14
+ def start: () -> self
15
+
16
+ def stop: () -> void
17
+
18
+ def beat: () -> void
19
+
20
+ def flush: () -> void
21
+
22
+ def identity: () -> ::String
23
+
24
+ def info: () -> Hash[Symbol, untyped]
25
+
26
+ private
27
+
28
+ def static_info: () -> Hash[Symbol, untyped]
29
+
30
+ def nats_info: () -> Hash[Symbol, untyped]
31
+
32
+ def rtt: (untyped connection) -> ::Float?
33
+
34
+ def rss: () -> ::Integer?
35
+
36
+ def processes: () -> API::Stats::Processes
37
+ end
38
+ end
@@ -0,0 +1,17 @@
1
+ module Cosmo
2
+ class HTTPServer
3
+ class Handler < ::WEBrick::HTTPServlet::AbstractServlet
4
+ @app: untyped
5
+
6
+ def initialize: (untyped server, untyped app) -> void
7
+
8
+ def service: (untyped req, untyped res) -> void
9
+
10
+ private
11
+
12
+ def env_for: (untyped req) -> Hash[String, untyped]
13
+
14
+ def write_headers: (untyped res, Hash[String, untyped] headers) -> void
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,21 @@
1
+ module Cosmo
2
+ class HTTPServer
3
+ class Health
4
+ PATH: String
5
+ HEADERS: Hash[String, String]
6
+
7
+ @app: untyped
8
+ @check: ^() -> Hash[Symbol, bool]
9
+
10
+ def initialize: (untyped app, ?check: (^() -> Hash[Symbol, bool])?) -> void
11
+
12
+ def call: (Hash[String, untyped] env) -> [Integer, Hash[String, String], Array[String]]
13
+
14
+ private
15
+
16
+ def default_check: () -> Hash[Symbol, bool]
17
+
18
+ def nats_connected?: () -> bool
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,14 @@
1
+ module Cosmo
2
+ class HTTPServer
3
+ class Ping
4
+ PATH: String
5
+ HEADERS: Hash[String, String]
6
+
7
+ @app: untyped
8
+
9
+ def initialize: (untyped app) -> void
10
+
11
+ def call: (Hash[String, untyped] env) -> [Integer, Hash[String, String], Array[String]]
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,22 @@
1
+ module Cosmo
2
+ class HTTPServer
3
+ DEFAULT_HOST: String
4
+ NOT_FOUND: [Integer, Hash[String, String], Array[String]]
5
+
6
+ @app: untyped
7
+ @host: String
8
+ @port: Integer
9
+ @server: untyped
10
+ @thread: Thread?
11
+
12
+ def self.app: () -> untyped
13
+
14
+ def initialize: (?untyped app, port: Integer, ?host: String) -> void
15
+
16
+ def start: () -> self
17
+
18
+ def stop: () -> void
19
+
20
+ def port: () -> Integer
21
+ end
22
+ end
@@ -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
@@ -0,0 +1,28 @@
1
+ module Cosmo
2
+ module Job
3
+ class Failure
4
+ HEADER_LIMIT: Integer
5
+ BACKTRACE_LINES: Integer
6
+ BACKTRACE_SEPARATOR: String
7
+
8
+ @exception: Exception
9
+ @backtrace: ::String?
10
+
11
+ def self.headers: (Exception exception) -> Hash[::String, ::String]
12
+
13
+ def initialize: (Exception exception) -> void
14
+
15
+ def headers: () -> Hash[::String, ::String]
16
+
17
+ private
18
+
19
+ def name: () -> ::String
20
+
21
+ def message: () -> ::String
22
+
23
+ def backtrace: () -> ::String
24
+
25
+ def single_line: (untyped value) -> ::String
26
+ end
27
+ end
28
+ end
@@ -1,13 +1,27 @@
1
1
  module Cosmo
2
2
  module Job
3
3
  class Processor < ::Cosmo::Processor
4
+ DISPATCH_HEADERS: ::Array[::String]
5
+
4
6
  @weights: Array[Symbol]?
5
7
 
8
+ def self.validate_options!: (Hash[Symbol, untyped] options) -> void
9
+
10
+ def subscriptions: () -> Array[::String]
11
+
6
12
  private
7
13
 
8
14
  def setup: () -> void
9
15
 
16
+ def log_subscriptions: () -> void
17
+
18
+ def scheduled_config: () -> Hash[Symbol, untyped]?
19
+
20
+ def consumer_name: (::String | Symbol stream_name) -> ::String
21
+
10
22
  def schedule_loop: () -> void
23
+ def scheduled_by: (untyped message) -> ::String?
24
+ def enqueued_at: (untyped message) -> ::Time
11
25
 
12
26
  def scheduler?: () -> bool
13
27
 
@@ -37,13 +51,13 @@ module Cosmo
37
51
 
38
52
  def drop_message: (untyped message, Hash[Symbol, untyped] data) -> void
39
53
 
40
- def move_message: (untyped message, ?Hash[Symbol, untyped]? data) -> void
54
+ def reject_message: (untyped message, Exception error, ?Hash[Symbol, untyped]? data) -> void
41
55
 
42
- def with_stats: (untyped message) { () -> untyped } -> void
56
+ def error_context: (untyped message, Hash[Symbol, untyped]? data, ?source: Symbol) -> Hash[Symbol, untyped]
43
57
 
44
- 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
45
59
 
46
- 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
47
61
  end
48
62
  end
49
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
@@ -0,0 +1,25 @@
1
+ module Cosmo
2
+ module Job
3
+ class StreamFilter
4
+ SCHEDULED: Symbol
5
+ ENV_NAME: ::String
6
+
7
+ @names: Array[::String]
8
+ @configured: Array[::String]?
9
+
10
+ def self.from: (Array[::String]? names) -> StreamFilter
11
+
12
+ def initialize: (Array[::String]? names) -> void
13
+
14
+ def all?: () -> bool
15
+
16
+ def include?: (::String | Symbol stream_name) -> bool
17
+
18
+ def validate!: () -> StreamFilter
19
+
20
+ private
21
+
22
+ def configured: () -> Array[::String]
23
+ end
24
+ end
25
+ 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