cosmonats 0.2.0 → 0.3.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.
data/sig/cosmo/client.rbs CHANGED
@@ -21,18 +21,26 @@ module Cosmo
21
21
 
22
22
  def delete_stream: (::String | Symbol name, ?Hash[Symbol, untyped] params) -> untyped
23
23
 
24
- def list_streams: () -> Array[::String]
24
+ def update_stream: (::String | Symbol name, Hash[Symbol, untyped] config) -> untyped
25
+
26
+ def list_streams: () -> Array[Hash[::String, untyped]]
27
+
28
+ def pause_stream: (::String name) -> void
29
+
30
+ def unpause_stream: (::String name) -> void
31
+
32
+ def stream_paused?: (::String name) -> bool
25
33
 
26
34
  def list_consumers: (::String stream_name) -> Array[Hash[::String, untyped]]
27
35
 
36
+ def consumer_info: (::String stream_name, ::String consumer_name) -> NATS::JetStream::API::ConsumerInfo
37
+
28
38
  def get_message: (::String | Symbol name, **untyped options) -> NATS::JetStream::API::RawStreamMsg
29
39
 
30
40
  def delete_message: (::String name, ::Integer seq) -> Hash[::String, untyped]
31
41
 
32
42
  def purge: (::String stream_name, ::String? subject) -> ::Integer?
33
43
 
34
- def consumer_info: (::String stream_name, ::String consumer_name) -> NATS::JetStream::API::ConsumerInfo
35
-
36
44
  def kv: (::String name, **untyped opts) -> NATS::KeyValue
37
45
 
38
46
  def close: -> void
data/sig/cosmo/config.rbs CHANGED
@@ -1,17 +1,14 @@
1
1
  module Cosmo
2
- class Config
2
+ class Config < ::Hash[Symbol, untyped]
3
3
  NANO: Integer
4
4
  DEFAULT_PATH: ::String
5
5
 
6
6
  self.@instance: Config
7
- self.@system: Hash[Symbol, untyped]
8
- @config: Hash[Symbol, untyped]?
9
- @system: Hash[Symbol, untyped]
10
- @defaults: Hash[Symbol, untyped]
7
+ self.@internal: Hash[Symbol, untyped]
11
8
 
12
9
  def self.instance: () -> Config
13
10
 
14
- def self.system: () -> Hash[Symbol, untyped]
11
+ def self.internal: () -> Hash[Symbol, untyped]
15
12
 
16
13
  def self.parse_file: (::String path) -> Hash[Symbol, untyped]
17
14
 
@@ -31,15 +28,6 @@ module Cosmo
31
28
 
32
29
  def self.load: (?::String? path) -> void
33
30
 
34
- def initialize: () -> void
35
-
36
- def []: (Symbol key) -> untyped
37
-
38
- def fetch: (Symbol key, ?untyped default) -> untyped
39
-
40
- def dig: (*Symbol keys) -> untyped
41
-
42
- def to_h: () -> Hash[Symbol, untyped]
43
31
 
44
32
  def set: (*untyped) -> untyped
45
33
 
@@ -1,23 +1,31 @@
1
1
  module Cosmo
2
2
  module Job
3
3
  class Processor < ::Cosmo::Processor
4
- @weights: Array[Symbol]
4
+ private
5
5
 
6
- def initialize: (Utils::ThreadPool pool, untyped running, Hash[Symbol, untyped] options) -> void
6
+ def setup: () -> void
7
7
 
8
- private
8
+ def schedule_loop: () -> void
9
9
 
10
- def run_loop: () -> void
10
+ def scheduler?: () -> bool
11
11
 
12
- def setup: () -> void
12
+ def consumers: () -> Array[untyped]
13
13
 
14
- def work_loop: () -> void
14
+ def fetch_subjects: (Hash[Symbol, untyped] config) -> untyped
15
15
 
16
- def schedule_loop: () -> void
16
+ def fetch_timeout: (Hash[Symbol, untyped] config) -> Float
17
17
 
18
- def process: (Array[untyped] messages) -> void
18
+ def process: (Array[untyped] messages, untyped processor) -> void
19
19
 
20
20
  def handle_failure: (untyped message, Hash[Symbol, untyped] data) -> void
21
+
22
+ def subscribe: (Symbol stream_name, Hash[Symbol, untyped] config) -> [untyped, Hash[Symbol, untyped], nil]
23
+
24
+ def drop_message: (untyped message, Hash[Symbol, untyped] data) -> void
25
+
26
+ def move_message: (untyped message, ?Hash[Symbol, untyped]? data) -> void
27
+
28
+ def with_stats: (untyped message) { () -> untyped } -> void
21
29
  end
22
30
  end
23
31
  end
@@ -1,24 +1,46 @@
1
1
  module Cosmo
2
2
  class Processor
3
+ STREAM_PAUSED_RECHECK_TTL: Float
4
+ STREAMS_PAUSED_IDLE_SLEEP: Float
5
+ STREAM_EMPTY_BACKOFF_MAX: Float
6
+
3
7
  @pool: Utils::ThreadPool
4
8
  @running: untyped
5
9
  @consumers: Array[untyped]
10
+ @threads: Array[Thread]
11
+ @cache: Utils::TTLCache
6
12
  @options: Hash[Symbol, untyped]
13
+ @locks: Hash[::String, Mutex]
14
+ @consumer_state: untyped
7
15
 
8
16
  def self.run: (*untyped) -> Processor
9
17
 
18
+ attr_reader consumers: Array[untyped]
19
+
10
20
  def initialize: (Utils::ThreadPool pool, untyped running, Hash[Symbol, untyped] options) -> void
11
21
 
12
22
  def run: () -> void
13
23
 
24
+ def stop: (?::Integer | ::Float timeout) -> void
25
+
14
26
  private
15
27
 
16
28
  def run_loop: () -> void
17
29
 
30
+ def work_loop: () -> void
31
+
32
+ def schedule_loop: () -> void
33
+
34
+ def scheduler?: () -> bool
35
+
18
36
  def setup: () -> void
19
37
 
20
38
  def process: (*untyped) -> void
21
39
 
40
+ def fetch_timeout: (Hash[Symbol, untyped] config) -> Float
41
+
42
+ def fetch_subjects: (Hash[Symbol, untyped] config) -> untyped
43
+
22
44
  def running?: () -> bool
23
45
 
24
46
  def fetch: (untyped subscription, batch_size: Integer, timeout: Float) ?{ (Array[untyped]) -> void } -> void
@@ -26,5 +48,9 @@ module Cosmo
26
48
  def client: () -> Client
27
49
 
28
50
  def stopwatch: () -> Utils::Stopwatch
51
+
52
+ def lock: (::String stream_name) { () -> void } -> void
53
+
54
+ def consumer_state: () -> untyped
29
55
  end
30
56
  end
@@ -3,27 +3,21 @@ module Cosmo
3
3
  class Processor < ::Cosmo::Processor
4
4
  @configs: Array[Hash[Symbol, untyped]]
5
5
 
6
- def initialize: (Utils::ThreadPool pool, untyped running, Hash[Symbol, untyped] options) -> void
7
-
8
6
  private
9
7
 
10
- def run_loop: () -> void
11
-
12
8
  def setup: () -> void
13
9
 
14
- def convert_timeout: (Numeric) -> Float
15
-
16
- def work_loop: () -> void
17
-
18
10
  def process: (Array[untyped] messages, untyped processor) -> void
19
11
 
20
- def setup_configs: () -> void
12
+ def fetch_subjects: (Hash[Symbol, untyped] config) -> untyped
21
13
 
22
- def setup_consumers: () -> void
14
+ def fetch_timeout: (Hash[Symbol, untyped] config) -> Float
23
15
 
24
16
  def static_config: -> Array[Hash[Symbol, untyped]]
25
17
 
26
18
  def dynamic_config: -> Array[Hash[Symbol, untyped]]
19
+
20
+ def subscribe: (Symbol? stream_name, Hash[Symbol, untyped] config) -> [untyped, Hash[Symbol, untyped], untyped]
27
21
  end
28
22
  end
29
23
  end
@@ -5,21 +5,13 @@ module Cosmo
5
5
 
6
6
  def self.dup: [T] (T hash) -> T
7
7
 
8
- def self.keys?: (::Hash[untyped, untyped] hash, *untyped keys) -> bool
9
-
10
8
  def self.set: (::Hash[untyped, untyped] hash, *untyped keys, value: untyped) -> untyped
11
9
 
12
- def self.merge: (::Hash[untyped, untyped] hash1, ::Hash[untyped, untyped]? hash2) -> ::Hash[untyped, untyped]
13
-
14
10
  def symbolize_keys!: (untyped obj) -> (::Hash[Symbol, untyped] | Array[untyped] | untyped)
15
11
 
16
12
  def dup: [T] (T hash) -> T
17
13
 
18
- def keys?: (::Hash[untyped, untyped] hash, *untyped keys) -> bool
19
-
20
14
  def set: (::Hash[untyped, untyped] hash, *untyped keys, value: untyped) -> untyped
21
-
22
- def merge: (::Hash[untyped, untyped] hash1, ::Hash[untyped, untyped]? hash2) -> ::Hash[untyped, untyped]
23
15
  end
24
16
  end
25
17
  end
@@ -0,0 +1,20 @@
1
+ module Cosmo
2
+ module Utils
3
+ class TTLCache
4
+ @store: ::Hash[untyped, [untyped, ::Time?]]
5
+
6
+ def initialize: () -> void
7
+
8
+ def set: (untyped key, untyped value, ?ttl: Numeric?) -> untyped
9
+
10
+ def get: (untyped key) -> untyped
11
+
12
+ def fetch: (untyped key, ?ttl: Numeric?) { () -> untyped } -> untyped
13
+
14
+ private
15
+
16
+ def key?: (untyped key) -> bool
17
+ end
18
+ end
19
+ end
20
+
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.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dmitry Vorotilin
@@ -73,7 +73,6 @@ files:
73
73
  - lib/cosmo/cli.rb
74
74
  - lib/cosmo/client.rb
75
75
  - lib/cosmo/config.rb
76
- - lib/cosmo/defaults.yml
77
76
  - lib/cosmo/engine.rb
78
77
  - lib/cosmo/job.rb
79
78
  - lib/cosmo/job/data.rb
@@ -94,6 +93,7 @@ files:
94
93
  - lib/cosmo/utils/stopwatch.rb
95
94
  - lib/cosmo/utils/string.rb
96
95
  - lib/cosmo/utils/thread_pool.rb
96
+ - lib/cosmo/utils/ttl_cache.rb
97
97
  - lib/cosmo/utils/warnings.rb
98
98
  - lib/cosmo/version.rb
99
99
  - lib/cosmo/web.rb
@@ -119,6 +119,8 @@ files:
119
119
  - lib/cosmo/web/views/jobs/scheduled.erb
120
120
  - lib/cosmo/web/views/layout.erb
121
121
  - lib/cosmo/web/views/streams/_info.erb
122
+ - lib/cosmo/web/views/streams/_pause_banner.erb
123
+ - lib/cosmo/web/views/streams/_stream_row.erb
122
124
  - lib/cosmo/web/views/streams/_table.erb
123
125
  - lib/cosmo/web/views/streams/index.erb
124
126
  - lib/cosmo/web/views/streams/info.erb
@@ -151,6 +153,7 @@ files:
151
153
  - sig/cosmo/utils/stopwatch.rbs
152
154
  - sig/cosmo/utils/string.rbs
153
155
  - sig/cosmo/utils/thread_pool.rbs
156
+ - sig/cosmo/utils/ttl_cache.rbs
154
157
  homepage: https://github.com/bitsbeam/cosmonats
155
158
  licenses:
156
159
  - LGPL-3.0
@@ -175,7 +178,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
175
178
  - !ruby/object:Gem::Version
176
179
  version: '0'
177
180
  requirements: []
178
- rubygems_version: 4.0.8
181
+ rubygems_version: 4.0.12
179
182
  specification_version: 4
180
183
  summary: Lightweight background and stream processing
181
184
  test_files: []
@@ -1,70 +0,0 @@
1
- timeout: 25
2
- max_retries: &max_retries 3
3
- concurrency: &concurrency 1
4
-
5
- consumers:
6
- jobs:
7
- critical:
8
- <<: &config
9
- ack_policy: explicit # each individual message must be acknowledged
10
- max_deliver: *max_retries # max number of times a message delivery will be attempted
11
- max_ack_pending: 3 # maximum number of messages w/o ack
12
- ack_wait: 60 # duration server waits for ack of message once it's delivered
13
- subject: jobs.%{name}.>
14
- priority: 50
15
- high:
16
- <<: *config
17
- priority: 30
18
- default:
19
- <<: *config
20
- priority: 15
21
- low:
22
- <<: *config
23
- priority: 5
24
- scheduled:
25
- <<: *config
26
- max_deliver: 1
27
- max_ack_pending: 100
28
- ack_wait: 10
29
-
30
- setup:
31
- jobs:
32
- critical:
33
- <<: &config
34
- storage: file
35
- retention: workqueue
36
- duplicate_window: 120 # 2m
37
- discard: old
38
- allow_direct: true
39
- subjects:
40
- - jobs.%{name}.>
41
- description: Very critical priority jobs
42
- high:
43
- <<: *config
44
- description: Higher priority jobs
45
- default:
46
- <<: *config
47
- description: Default priority jobs
48
- low:
49
- <<: *config
50
- description: Lower priority jobs
51
- scheduled:
52
- <<: *config
53
- description: Scheduled jobs
54
- dead:
55
- <<: *config
56
- retention: limits
57
- max_msgs: 10000
58
- max_age: 604800 # 7d
59
- description: Broken jobs (DLQ)
60
-
61
- development:
62
- verbose: false
63
- concurrency: *concurrency
64
-
65
- staging:
66
- verbose: true
67
- concurrency: 3
68
-
69
- production:
70
- concurrency: 3