cosmonats 0.1.4 → 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.
Files changed (69) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +129 -67
  3. data/lib/cosmo/api/busy.rb +66 -0
  4. data/lib/cosmo/api/counter.rb +70 -0
  5. data/lib/cosmo/api/job.rb +46 -0
  6. data/lib/cosmo/api/kv.rb +63 -0
  7. data/lib/cosmo/api/stats.rb +44 -0
  8. data/lib/cosmo/api/stream.rb +123 -0
  9. data/lib/cosmo/api.rb +11 -0
  10. data/lib/cosmo/cli.rb +8 -5
  11. data/lib/cosmo/client.rb +58 -3
  12. data/lib/cosmo/config.rb +13 -38
  13. data/lib/cosmo/engine.rb +1 -1
  14. data/lib/cosmo/job/processor.rb +66 -57
  15. data/lib/cosmo/job.rb +1 -1
  16. data/lib/cosmo/logger.rb +8 -1
  17. data/lib/cosmo/processor.rb +110 -2
  18. data/lib/cosmo/stream/processor.rb +23 -59
  19. data/lib/cosmo/stream.rb +2 -2
  20. data/lib/cosmo/utils/hash.rb +3 -27
  21. data/lib/cosmo/utils/overrides.rb +15 -0
  22. data/lib/cosmo/utils/ttl_cache.rb +44 -0
  23. data/lib/cosmo/utils/warnings.rb +17 -0
  24. data/lib/cosmo/utils.rb +15 -0
  25. data/lib/cosmo/version.rb +1 -1
  26. data/lib/cosmo/web/assets/app.css +477 -0
  27. data/lib/cosmo/web/assets/htmx.2.0.8.min.js.gz +0 -0
  28. data/lib/cosmo/web/context.rb +28 -0
  29. data/lib/cosmo/web/controllers/actions.rb +16 -0
  30. data/lib/cosmo/web/controllers/application.rb +43 -0
  31. data/lib/cosmo/web/controllers/jobs.rb +97 -0
  32. data/lib/cosmo/web/controllers/streams.rb +70 -0
  33. data/lib/cosmo/web/helpers/application.rb +87 -0
  34. data/lib/cosmo/web/renderer.rb +58 -0
  35. data/lib/cosmo/web/views/actions/index.erb +7 -0
  36. data/lib/cosmo/web/views/jobs/_busy.erb +50 -0
  37. data/lib/cosmo/web/views/jobs/_dead.erb +65 -0
  38. data/lib/cosmo/web/views/jobs/_enqueued.erb +60 -0
  39. data/lib/cosmo/web/views/jobs/_scheduled.erb +49 -0
  40. data/lib/cosmo/web/views/jobs/_stats.erb +69 -0
  41. data/lib/cosmo/web/views/jobs/busy.erb +16 -0
  42. data/lib/cosmo/web/views/jobs/dead.erb +17 -0
  43. data/lib/cosmo/web/views/jobs/enqueued.erb +16 -0
  44. data/lib/cosmo/web/views/jobs/index.erb +12 -0
  45. data/lib/cosmo/web/views/jobs/scheduled.erb +17 -0
  46. data/lib/cosmo/web/views/layout.erb +33 -0
  47. data/lib/cosmo/web/views/streams/_info.erb +92 -0
  48. data/lib/cosmo/web/views/streams/_pause_banner.erb +17 -0
  49. data/lib/cosmo/web/views/streams/_stream_row.erb +42 -0
  50. data/lib/cosmo/web/views/streams/_table.erb +25 -0
  51. data/lib/cosmo/web/views/streams/index.erb +11 -0
  52. data/lib/cosmo/web/views/streams/info.erb +11 -0
  53. data/lib/cosmo/web.rb +68 -0
  54. data/lib/cosmo.rb +2 -7
  55. data/sig/cosmo/api/busy.rbs +35 -0
  56. data/sig/cosmo/api/counter.rbs +34 -0
  57. data/sig/cosmo/api/job.rbs +31 -0
  58. data/sig/cosmo/api/kv.rbs +30 -0
  59. data/sig/cosmo/api/stats.rbs +21 -0
  60. data/sig/cosmo/api/stream.rbs +50 -0
  61. data/sig/cosmo/client.rbs +21 -3
  62. data/sig/cosmo/config.rbs +3 -15
  63. data/sig/cosmo/job/processor.rbs +16 -8
  64. data/sig/cosmo/processor.rbs +26 -0
  65. data/sig/cosmo/stream/processor.rbs +4 -10
  66. data/sig/cosmo/utils/hash.rbs +0 -8
  67. data/sig/cosmo/utils/ttl_cache.rbs +20 -0
  68. metadata +62 -3
  69. data/lib/cosmo/defaults.yml +0 -69
@@ -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.1.4
4
+ version: 0.3.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,10 +63,16 @@ 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
55
- - lib/cosmo/defaults.yml
56
76
  - lib/cosmo/engine.rb
57
77
  - lib/cosmo/job.rb
58
78
  - lib/cosmo/job/data.rb
@@ -65,15 +85,53 @@ files:
65
85
  - lib/cosmo/stream/message.rb
66
86
  - lib/cosmo/stream/processor.rb
67
87
  - lib/cosmo/stream/serializer.rb
88
+ - lib/cosmo/utils.rb
68
89
  - lib/cosmo/utils/hash.rb
69
90
  - lib/cosmo/utils/json.rb
91
+ - lib/cosmo/utils/overrides.rb
70
92
  - lib/cosmo/utils/signal.rb
71
93
  - lib/cosmo/utils/stopwatch.rb
72
94
  - lib/cosmo/utils/string.rb
73
95
  - lib/cosmo/utils/thread_pool.rb
96
+ - lib/cosmo/utils/ttl_cache.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/_pause_banner.erb
123
+ - lib/cosmo/web/views/streams/_stream_row.erb
124
+ - lib/cosmo/web/views/streams/_table.erb
125
+ - lib/cosmo/web/views/streams/index.erb
126
+ - lib/cosmo/web/views/streams/info.erb
75
127
  - lib/cosmonats.rb
76
128
  - sig/cosmo.rbs
129
+ - sig/cosmo/api/busy.rbs
130
+ - sig/cosmo/api/counter.rbs
131
+ - sig/cosmo/api/job.rbs
132
+ - sig/cosmo/api/kv.rbs
133
+ - sig/cosmo/api/stats.rbs
134
+ - sig/cosmo/api/stream.rbs
77
135
  - sig/cosmo/cli.rbs
78
136
  - sig/cosmo/client.rbs
79
137
  - sig/cosmo/config.rbs
@@ -95,6 +153,7 @@ files:
95
153
  - sig/cosmo/utils/stopwatch.rbs
96
154
  - sig/cosmo/utils/string.rbs
97
155
  - sig/cosmo/utils/thread_pool.rbs
156
+ - sig/cosmo/utils/ttl_cache.rbs
98
157
  homepage: https://github.com/bitsbeam/cosmonats
99
158
  licenses:
100
159
  - LGPL-3.0
@@ -119,7 +178,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
119
178
  - !ruby/object:Gem::Version
120
179
  version: '0'
121
180
  requirements: []
122
- rubygems_version: 3.6.9
181
+ rubygems_version: 4.0.12
123
182
  specification_version: 4
124
183
  summary: Lightweight background and stream processing
125
184
  test_files: []
@@ -1,69 +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
- streams:
31
- critical:
32
- <<: &config
33
- storage: file
34
- retention: workqueue
35
- duplicate_window: 120 # 2m
36
- discard: old
37
- allow_direct: true
38
- subjects:
39
- - jobs.%{name}.>
40
- description: Very critical priority jobs
41
- high:
42
- <<: *config
43
- description: Higher priority jobs
44
- default:
45
- <<: *config
46
- description: Default priority jobs
47
- low:
48
- <<: *config
49
- description: Lower priority jobs
50
- scheduled:
51
- <<: *config
52
- description: Scheduled jobs
53
- dead:
54
- <<: *config
55
- retention: limits
56
- max_msgs: 10000
57
- max_age: 604800 # 7d
58
- description: Broken jobs (DLQ)
59
-
60
- development:
61
- verbose: false
62
- concurrency: 1
63
-
64
- staging:
65
- verbose: true
66
- concurrency: 3
67
-
68
- production:
69
- concurrency: 3