robin 0.0.4 → 0.1.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 (225) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +372 -0
  3. data/COPYING +674 -0
  4. data/LICENSE +165 -0
  5. data/README.md +1490 -0
  6. data/assets/favicon.svg +31 -0
  7. data/assets/robin-logo.svg +37 -0
  8. data/assets/robin-mono.svg +12 -0
  9. data/assets/robin-wordmark.svg +4 -0
  10. data/assets/robin.svg +34 -0
  11. data/exe/robin +5 -0
  12. data/ext/robin_resp/extconf.rb +29 -0
  13. data/ext/robin_resp/robin_resp.c +645 -0
  14. data/lib/active_job/queue_adapters/robin_adapter.rb +3 -0
  15. data/lib/generators/robin/install/install_generator.rb +39 -0
  16. data/lib/generators/robin/install/templates/initializer.rb.tt +31 -0
  17. data/lib/generators/robin/install/templates/robin.yml.tt +25 -0
  18. data/lib/generators/robin/job/job_generator.rb +78 -0
  19. data/lib/generators/robin/job/templates/job.rb.tt +13 -0
  20. data/lib/generators/robin/job/templates/job_spec.rb.tt +21 -0
  21. data/lib/generators/robin/job/templates/job_test.rb.tt +21 -0
  22. data/lib/puma/plugin/robin.rb +131 -0
  23. data/lib/robin/active_job.rb +144 -0
  24. data/lib/robin/api.rb +777 -0
  25. data/lib/robin/batch.rb +700 -0
  26. data/lib/robin/cancellation.rb +62 -0
  27. data/lib/robin/cli.rb +325 -0
  28. data/lib/robin/client.rb +355 -21
  29. data/lib/robin/config.rb +454 -4
  30. data/lib/robin/cron.rb +325 -0
  31. data/lib/robin/debounce.rb +108 -0
  32. data/lib/robin/deploy.rb +65 -0
  33. data/lib/robin/embedded.rb +53 -0
  34. data/lib/robin/encryption.rb +147 -0
  35. data/lib/robin/events.rb +60 -0
  36. data/lib/robin/expiry.rb +41 -0
  37. data/lib/robin/fetcher.rb +441 -0
  38. data/lib/robin/gvl.rb +62 -0
  39. data/lib/robin/health.rb +76 -0
  40. data/lib/robin/iterable_job.rb +294 -0
  41. data/lib/robin/job.rb +258 -0
  42. data/lib/robin/job_class.rb +157 -0
  43. data/lib/robin/job_logger.rb +121 -0
  44. data/lib/robin/launcher.rb +658 -0
  45. data/lib/robin/leader.rb +86 -0
  46. data/lib/robin/limiter.rb +639 -0
  47. data/lib/robin/manager.rb +125 -0
  48. data/lib/robin/metrics.rb +303 -0
  49. data/lib/robin/middleware.rb +165 -0
  50. data/lib/robin/opentelemetry.rb +88 -0
  51. data/lib/robin/periodic.rb +327 -0
  52. data/lib/robin/processor.rb +317 -0
  53. data/lib/robin/profiler.rb +140 -0
  54. data/lib/robin/progress.rb +46 -0
  55. data/lib/robin/rails/app_loader.rb +23 -0
  56. data/lib/robin/rails/current_attributes.rb +88 -0
  57. data/lib/robin/rails/error_reporter.rb +31 -0
  58. data/lib/robin/rails/notifications.rb +22 -0
  59. data/lib/robin/rails/railtie.rb +87 -0
  60. data/lib/robin/rails/transactional_push.rb +49 -0
  61. data/lib/robin/rails.rb +23 -0
  62. data/lib/robin/recovery.rb +135 -0
  63. data/lib/robin/redis/connection.rb +639 -0
  64. data/lib/robin/redis/pool.rb +190 -0
  65. data/lib/robin/redis/resp.rb +77 -0
  66. data/lib/robin/reliable_push.rb +153 -0
  67. data/lib/robin/retrier.rb +284 -0
  68. data/lib/robin/scheduler.rb +102 -0
  69. data/lib/robin/scripts.rb +331 -0
  70. data/lib/robin/statsd.rb +135 -0
  71. data/lib/robin/swarm.rb +319 -0
  72. data/lib/robin/systemd.rb +47 -0
  73. data/lib/robin/testing.rb +158 -0
  74. data/lib/robin/top.rb +178 -0
  75. data/lib/robin/unique.rb +198 -0
  76. data/lib/robin/version.rb +5 -0
  77. data/lib/robin/warmup.rb +94 -0
  78. data/lib/robin/web/api.rb +580 -0
  79. data/lib/robin/web/batch_status.rb +44 -0
  80. data/lib/robin/web/dist/assets/ar-y7v9b75f.js +1 -0
  81. data/lib/robin/web/dist/assets/ar-y7v9b75f.js.gz +0 -0
  82. data/lib/robin/web/dist/assets/bricolage-0qmzcpnj.woff2 +0 -0
  83. data/lib/robin/web/dist/assets/cs-df88mq5e.js +1 -0
  84. data/lib/robin/web/dist/assets/cs-df88mq5e.js.gz +0 -0
  85. data/lib/robin/web/dist/assets/da-kemms74g.js +1 -0
  86. data/lib/robin/web/dist/assets/da-kemms74g.js.gz +0 -0
  87. data/lib/robin/web/dist/assets/de-z8kkqg65.js +1 -0
  88. data/lib/robin/web/dist/assets/de-z8kkqg65.js.gz +0 -0
  89. data/lib/robin/web/dist/assets/es-9ahrrn1s.js +1 -0
  90. data/lib/robin/web/dist/assets/es-9ahrrn1s.js.gz +0 -0
  91. data/lib/robin/web/dist/assets/fa-7r0x28nc.js +1 -0
  92. data/lib/robin/web/dist/assets/fa-7r0x28nc.js.gz +0 -0
  93. data/lib/robin/web/dist/assets/favicon-1ebfcc0182.svg +31 -0
  94. data/lib/robin/web/dist/assets/favicon-1ebfcc0182.svg.gz +0 -0
  95. data/lib/robin/web/dist/assets/fr-r7mqf3d9.js +1 -0
  96. data/lib/robin/web/dist/assets/fr-r7mqf3d9.js.gz +0 -0
  97. data/lib/robin/web/dist/assets/he-7t46b6rt.js +1 -0
  98. data/lib/robin/web/dist/assets/he-7t46b6rt.js.gz +0 -0
  99. data/lib/robin/web/dist/assets/hi-zj434tx4.js +1 -0
  100. data/lib/robin/web/dist/assets/hi-zj434tx4.js.gz +0 -0
  101. data/lib/robin/web/dist/assets/it-pqc2m7gm.js +1 -0
  102. data/lib/robin/web/dist/assets/it-pqc2m7gm.js.gz +0 -0
  103. data/lib/robin/web/dist/assets/ja-k9rgm1pj.js +1 -0
  104. data/lib/robin/web/dist/assets/ja-k9rgm1pj.js.gz +0 -0
  105. data/lib/robin/web/dist/assets/ko-bxersv91.js +1 -0
  106. data/lib/robin/web/dist/assets/ko-bxersv91.js.gz +0 -0
  107. data/lib/robin/web/dist/assets/main-anw3f6ba.css +1 -0
  108. data/lib/robin/web/dist/assets/main-anw3f6ba.css.gz +0 -0
  109. data/lib/robin/web/dist/assets/main-pdtvjejb.js +7 -0
  110. data/lib/robin/web/dist/assets/main-pdtvjejb.js.gz +0 -0
  111. data/lib/robin/web/dist/assets/main-zz8zzhwn.js +2 -0
  112. data/lib/robin/web/dist/assets/main-zz8zzhwn.js.gz +0 -0
  113. data/lib/robin/web/dist/assets/nb-fjnc5064.js +1 -0
  114. data/lib/robin/web/dist/assets/nb-fjnc5064.js.gz +0 -0
  115. data/lib/robin/web/dist/assets/nl-9p8b95b6.js +1 -0
  116. data/lib/robin/web/dist/assets/nl-9p8b95b6.js.gz +0 -0
  117. data/lib/robin/web/dist/assets/pl-8xsrdn8n.js +1 -0
  118. data/lib/robin/web/dist/assets/pl-8xsrdn8n.js.gz +0 -0
  119. data/lib/robin/web/dist/assets/pt-BR-650j7cvg.js +1 -0
  120. data/lib/robin/web/dist/assets/pt-BR-650j7cvg.js.gz +0 -0
  121. data/lib/robin/web/dist/assets/robin-ae4a4aedd9.svg +34 -0
  122. data/lib/robin/web/dist/assets/robin-ae4a4aedd9.svg.gz +0 -0
  123. data/lib/robin/web/dist/assets/robin-wordmark-5dde5d8e4b.svg +4 -0
  124. data/lib/robin/web/dist/assets/robin-wordmark-5dde5d8e4b.svg.gz +0 -0
  125. data/lib/robin/web/dist/assets/ru-a9ftyw3d.js +1 -0
  126. data/lib/robin/web/dist/assets/ru-a9ftyw3d.js.gz +0 -0
  127. data/lib/robin/web/dist/assets/sv-j9gqamr1.js +1 -0
  128. data/lib/robin/web/dist/assets/sv-j9gqamr1.js.gz +0 -0
  129. data/lib/robin/web/dist/assets/tr-y9z0q51g.js +1 -0
  130. data/lib/robin/web/dist/assets/tr-y9z0q51g.js.gz +0 -0
  131. data/lib/robin/web/dist/assets/uk-2dr9ew3p.js +1 -0
  132. data/lib/robin/web/dist/assets/uk-2dr9ew3p.js.gz +0 -0
  133. data/lib/robin/web/dist/assets/ur-h25nzq1s.js +1 -0
  134. data/lib/robin/web/dist/assets/ur-h25nzq1s.js.gz +0 -0
  135. data/lib/robin/web/dist/assets/vi-9y2ff1bd.js +1 -0
  136. data/lib/robin/web/dist/assets/vi-9y2ff1bd.js.gz +0 -0
  137. data/lib/robin/web/dist/assets/zh-CN-tbj9mf98.js +1 -0
  138. data/lib/robin/web/dist/assets/zh-CN-tbj9mf98.js.gz +0 -0
  139. data/lib/robin/web/dist/assets/zh-TW-59q8j9vw.js +1 -0
  140. data/lib/robin/web/dist/assets/zh-TW-59q8j9vw.js.gz +0 -0
  141. data/lib/robin/web/dist/index.html +19 -0
  142. data/lib/robin/web/extension.rb +193 -0
  143. data/lib/robin/web/permissions.rb +40 -0
  144. data/lib/robin/web/prometheus.rb +79 -0
  145. data/lib/robin/web/router.rb +150 -0
  146. data/lib/robin/web/static.rb +110 -0
  147. data/lib/robin/web.rb +196 -0
  148. data/lib/robin.rb +258 -8
  149. data/sig/manifest.yaml +9 -0
  150. data/sig/robin/api.rbs +442 -0
  151. data/sig/robin/batch.rbs +292 -0
  152. data/sig/robin/cancellation.rbs +25 -0
  153. data/sig/robin/cli.rbs +102 -0
  154. data/sig/robin/client.rbs +118 -0
  155. data/sig/robin/config.rbs +341 -0
  156. data/sig/robin/cron.rbs +149 -0
  157. data/sig/robin/debounce.rbs +36 -0
  158. data/sig/robin/deploy.rbs +24 -0
  159. data/sig/robin/embedded.rbs +25 -0
  160. data/sig/robin/encryption.rbs +49 -0
  161. data/sig/robin/events.rbs +10 -0
  162. data/sig/robin/expiry.rbs +17 -0
  163. data/sig/robin/fetcher.rbs +134 -0
  164. data/sig/robin/gvl.rbs +39 -0
  165. data/sig/robin/health.rbs +30 -0
  166. data/sig/robin/iterable_job.rbs +99 -0
  167. data/sig/robin/job.rbs +173 -0
  168. data/sig/robin/job_class.rbs +55 -0
  169. data/sig/robin/job_logger.rbs +56 -0
  170. data/sig/robin/launcher.rbs +191 -0
  171. data/sig/robin/leader.rbs +43 -0
  172. data/sig/robin/limiter.rbs +317 -0
  173. data/sig/robin/manager.rbs +54 -0
  174. data/sig/robin/metrics.rbs +122 -0
  175. data/sig/robin/middleware.rbs +106 -0
  176. data/sig/robin/opentelemetry.rbs +51 -0
  177. data/sig/robin/periodic.rbs +81 -0
  178. data/sig/robin/processor.rbs +107 -0
  179. data/sig/robin/profiler.rbs +60 -0
  180. data/sig/robin/progress.rbs +22 -0
  181. data/sig/robin/rails/app_loader.rbs +10 -0
  182. data/sig/robin/rails/current_attributes.rbs +44 -0
  183. data/sig/robin/rails/error_reporter.rbs +21 -0
  184. data/sig/robin/rails/notifications.rbs +9 -0
  185. data/sig/robin/rails/transactional_push.rbs +16 -0
  186. data/sig/robin/rails.rbs +8 -0
  187. data/sig/robin/recovery.rbs +29 -0
  188. data/sig/robin/redis/connection.rbs +224 -0
  189. data/sig/robin/redis/pool.rbs +89 -0
  190. data/sig/robin/redis/resp.rbs +29 -0
  191. data/sig/robin/reliable_push.rbs +77 -0
  192. data/sig/robin/retrier.rbs +72 -0
  193. data/sig/robin/scheduler.rbs +40 -0
  194. data/sig/robin/scripts.rbs +36 -0
  195. data/sig/robin/statsd.rbs +55 -0
  196. data/sig/robin/swarm.rbs +133 -0
  197. data/sig/robin/systemd.rbs +13 -0
  198. data/sig/robin/testing.rbs +80 -0
  199. data/sig/robin/top.rbs +79 -0
  200. data/sig/robin/unique.rbs +72 -0
  201. data/sig/robin/version.rbs +3 -0
  202. data/sig/robin/warmup.rbs +44 -0
  203. data/sig/robin/web/api.rbs +196 -0
  204. data/sig/robin/web/batch_status.rbs +25 -0
  205. data/sig/robin/web/extension.rbs +106 -0
  206. data/sig/robin/web/permissions.rbs +14 -0
  207. data/sig/robin/web/prometheus.rbs +33 -0
  208. data/sig/robin/web/router.rbs +53 -0
  209. data/sig/robin/web/static.rbs +42 -0
  210. data/sig/robin/web.rbs +140 -0
  211. data/sig/robin.rbs +116 -0
  212. data/sig/robin_resp.rbs +55 -0
  213. metadata +274 -44
  214. data/bin/robin +0 -5
  215. data/lib/robin/actions/authenticate.rb +0 -38
  216. data/lib/robin/actions/empty_tweet.rb +0 -7
  217. data/lib/robin/actions/followers.rb +0 -22
  218. data/lib/robin/actions/help.rb +0 -16
  219. data/lib/robin/actions/home_timeline.rb +0 -9
  220. data/lib/robin/actions/new_tweet.rb +0 -11
  221. data/lib/robin/actions/unknown_flag.rb +0 -11
  222. data/lib/robin/actions/user_timeline.rb +0 -19
  223. data/lib/robin/args_parser.rb +0 -70
  224. data/lib/robin/pin_authenticator.rb +0 -31
  225. data/lib/robin/user.rb +0 -36
data/sig/robin/api.rbs ADDED
@@ -0,0 +1,442 @@
1
+ module Robin
2
+ # Cluster-wide counts, in one round trip.
3
+ class Stats
4
+ @config: Config
5
+
6
+ attr_reader processed: Integer
7
+ attr_reader failed: Integer
8
+ attr_reader scheduled_size: Integer
9
+ attr_reader retry_size: Integer
10
+ attr_reader dead_size: Integer
11
+ attr_reader processes_size: Integer
12
+ attr_reader workers_size: Integer
13
+ attr_reader enqueued: Integer
14
+
15
+ # Each queue's size, largest first.
16
+ attr_reader queues: Hash[String, Integer]
17
+
18
+ # Seconds the default queue's oldest job has waited.
19
+ attr_reader default_queue_latency: Float
20
+
21
+ def initialize: (?config: Config) -> void
22
+
23
+ # Reads them all, in one round trip.
24
+ def fetch: () -> self
25
+
26
+ def to_h: () -> Hash[String, Integer | Float]
27
+
28
+ # Daily processed/failed counts ("YYYY-MM-DD" => count) for the last
29
+ # +days+ days.
30
+ def history: (?days: Integer, ?now: Time) -> Hash[String, Hash[String, Integer]]
31
+
32
+ # Resets counters ("processed", "failed"); returns how many it deleted.
33
+ def reset: (*String names) -> Integer
34
+ end
35
+
36
+ # A queue's jobs, next to run first.
37
+ class Queue
38
+ include Enumerable[JobRecord]
39
+
40
+ PAGE: Integer
41
+
42
+ FIND_SLICE: Integer
43
+
44
+ def self.all: (?config: Config) -> Array[Queue]
45
+
46
+ # Seconds the oldest job (its raw JSON) has been waiting.
47
+ def self.latency_of: (String? raw, ?Integer now) -> Float
48
+
49
+ # The names of the paused queues.
50
+ def self.paused: (?config: Config) -> Array[String]
51
+
52
+ @config: Config
53
+ @key: String
54
+
55
+ attr_reader name: String
56
+
57
+ def initialize: (?_ToS name, ?config: Config) -> void
58
+
59
+ def size: () -> Integer
60
+
61
+ def latency: () -> Float
62
+
63
+ def paused?: () -> bool
64
+
65
+ def pause!: () -> Integer
66
+
67
+ def unpause!: () -> Integer
68
+
69
+ # Jobs from next-to-run to most recently pushed.
70
+ def each: () { (JobRecord job) -> void } -> void
71
+ | () -> Enumerator[JobRecord, void]
72
+
73
+ # A page of jobs: page 1 holds the jobs that will run next.
74
+ def page: (Integer number, ?per_page: Integer) -> Array[JobRecord]
75
+
76
+ # Finds a job by jid.
77
+ def find_job: (String jid) -> JobRecord?
78
+
79
+ # Deletes every job of class +klass+; returns how many.
80
+ def delete_by_class: (_ToS klass) -> Integer
81
+
82
+ # Deletes +jobs+ (read from this queue); returns how many.
83
+ def delete_jobs: (Array[JobRecord] jobs) -> Integer
84
+
85
+ def clear: () -> true
86
+
87
+ alias delete clear
88
+
89
+ # Name, size, latency and whether it's paused, in one round trip.
90
+ def to_h: () -> Hash[String, String | Integer | Float | bool]
91
+
92
+ private
93
+
94
+ def page_command: (Integer offset) -> Redis::command
95
+
96
+ # A job read from the queue.
97
+ def record: (String raw) -> JobRecord
98
+ end
99
+
100
+ # A job as stored in Redis.
101
+ class JobRecord
102
+ @config: Config
103
+
104
+ # The job's hash.
105
+ attr_reader item: job_hash
106
+
107
+ # The job's JSON.
108
+ attr_reader value: String
109
+
110
+ attr_reader queue: String?
111
+
112
+ def initialize: (String | job_hash value, ?String? queue, ?config: Config) -> void
113
+
114
+ def []: (String key) -> json
115
+
116
+ # The job's class name.
117
+ def klass: () -> String
118
+
119
+ # The class users care about (unwraps ActiveJob).
120
+ def display_class: () -> String?
121
+
122
+ def args: () -> Array[json]
123
+
124
+ # The arguments to show: an ActiveJob's own, and encrypted ones hidden.
125
+ def display_args: () -> Array[json]
126
+
127
+ def jid: () -> String
128
+
129
+ def bid: () -> String?
130
+
131
+ def tags: () -> Array[String]
132
+
133
+ def error_class: () -> String?
134
+
135
+ def error_message: () -> String?
136
+
137
+ # The backtrace stored with the last failure.
138
+ def error_backtrace: () -> Array[String]?
139
+
140
+ # How many times the job has failed.
141
+ def failures: () -> Integer
142
+
143
+ def created_at: () -> Time?
144
+
145
+ def enqueued_at: () -> Time?
146
+
147
+ def failed_at: () -> Time?
148
+
149
+ def retried_at: () -> Time?
150
+
151
+ # Epoch ms since when the job has been ready to run.
152
+ def waiting_since: () -> (Integer | Float | nil)
153
+
154
+ def latency: () -> Float
155
+
156
+ def delete: () -> bool
157
+
158
+ def to_h: () -> Hash[String, json]
159
+
160
+ private
161
+
162
+ def ms_time: (Integer | Float | nil time) -> Time?
163
+
164
+ def parse: (String raw) -> job_hash
165
+ end
166
+
167
+ # A job in the schedule, retry or dead set.
168
+ class SortedEntry < JobRecord
169
+ # Its score in the set: when it's due (or died), in epoch seconds.
170
+ attr_reader score: Float
171
+
172
+ attr_reader parent: JobSet
173
+
174
+ def initialize: (JobSet parent, String | Float | Integer score, String value) -> void
175
+
176
+ # When the job is due (or, in the dead set, died).
177
+ def at: () -> Time
178
+
179
+ # "<score>-<jid>", as the dashboard names it.
180
+ def id: () -> String
181
+
182
+ def delete: () -> bool
183
+
184
+ # Pushes the job onto its queue now; false if it's gone from the set.
185
+ def add_to_queue: () -> bool
186
+
187
+ alias retry! add_to_queue
188
+
189
+ # The job without its time in the set.
190
+ def bare_item: () -> job_hash
191
+
192
+ # The job #add_to_queue pushes.
193
+ def queued_item: () -> job_hash
194
+
195
+ def reschedule: (time at) -> Array[Redis::reply]
196
+
197
+ # Moves the job to the dead set; false if it's gone from the set.
198
+ def kill!: () -> bool
199
+
200
+ def to_h: () -> Hash[String, json]
201
+
202
+ private
203
+
204
+ # Removes it, then yields the job; false if it was gone.
205
+ def remove_and: () { (job_hash item) -> void } -> bool
206
+ end
207
+
208
+ # A sorted set of jobs: the schedule, retry or dead set.
209
+ class JobSet
210
+ include Enumerable[SortedEntry]
211
+
212
+ PAGE: Integer
213
+
214
+ attr_reader name: String
215
+ attr_reader key: String
216
+ attr_reader config: Config
217
+
218
+ def initialize: (String name, ?config: Config) -> void
219
+
220
+ def size: () -> Integer
221
+
222
+ def clear: () -> Integer
223
+
224
+ # Adds a job (a payload hash or its JSON) due at +at+.
225
+ def schedule: (time at, job_hash | String payload) -> Integer
226
+
227
+ # Iterates by score: soonest first, or latest first with +reverse+.
228
+ def each: (?reverse: bool) { (SortedEntry entry) -> void } -> void
229
+ | (?reverse: bool) -> Enumerator[SortedEntry, void]
230
+
231
+ def page: (Integer number, ?per_page: Integer, ?reverse: bool) -> Array[SortedEntry]
232
+
233
+ # A #page and the set's size, in one round trip.
234
+ def page_and_size: (Integer number, per_page: Integer, reverse: bool) -> [Array[SortedEntry], Integer]
235
+
236
+ # Up to +limit+ entries whose JSON contains +term+, soonest first.
237
+ def scan: (_ToS term, ?limit: Integer) -> Array[SortedEntry]
238
+
239
+ def find_job: (String jid) -> SortedEntry?
240
+
241
+ # Entries with exactly this score (and optionally jid).
242
+ def fetch: (_ToS score, ?String? jid) -> Array[SortedEntry]
243
+
244
+ # Looks up by the "<score>-<jid>" ids used in the web UI.
245
+ def find_by_id: (String id) -> SortedEntry?
246
+
247
+ def delete_entry: (SortedEntry entry) -> bool
248
+
249
+ def delete_by_jid: (_ToS score, String jid) -> bool
250
+
251
+ # Looks up several "<score>-<jid>" ids in one round trip.
252
+ def find_all_by_id: (Array[String] ids) -> Array[SortedEntry]
253
+
254
+ # Removes +entries+ and returns those it removed.
255
+ def take: (Array[SortedEntry] entries) -> Array[SortedEntry]
256
+
257
+ # Deletes +entries+; returns how many.
258
+ def delete_entries: (Array[SortedEntry] entries) -> Integer
259
+
260
+ # Pushes +entries+ onto their queues now; returns how many.
261
+ def retry_entries: (Array[SortedEntry] entries) -> Integer
262
+
263
+ # Runs the block's pushes of +taken+ together; puts +taken+ back in the
264
+ # set if the block raises.
265
+ def pushing: [T] (Array[SortedEntry] taken) { () -> T } -> T
266
+
267
+ # Moves +entries+ to the dead set; returns how many.
268
+ def kill_entries: (Array[SortedEntry] entries) -> Integer
269
+
270
+ # Yields the entries in the set now to a block that removes each one
271
+ # and returns truthy if it did. Returns how many it removed.
272
+ def drain: () { (SortedEntry entry) -> boolish } -> Integer
273
+
274
+ # Like #drain, a page at a time: the block returns how many it removed.
275
+ def drain_pages: () { (Array[SortedEntry] page) -> Integer } -> Integer
276
+
277
+ private
278
+
279
+ def range: (Integer start, Integer count, bool reverse) -> Array[SortedEntry]
280
+
281
+ def range_command: (Integer start, Integer count, bool reverse) -> Redis::command
282
+
283
+ def entries_from: (Redis::reply raw) -> Array[SortedEntry]
284
+
285
+ # An entry read from the set.
286
+ def entry: (String score, String value) -> SortedEntry
287
+ end
288
+
289
+ class ScheduledSet < JobSet
290
+ def initialize: (?config: Config) -> void
291
+ end
292
+
293
+ class RetrySet < JobSet
294
+ def initialize: (?config: Config) -> void
295
+
296
+ # Pushes every entry back onto its queue; returns how many.
297
+ def retry_all: () -> Integer
298
+
299
+ # Moves every entry to the dead set; returns how many.
300
+ def kill_all: () -> Integer
301
+ end
302
+
303
+ class DeadSet < JobSet
304
+ def initialize: (?config: Config) -> void
305
+
306
+ # Adds a job's JSON to the dead set (trimming it), acknowledging +ack+
307
+ # in the same transaction; +notify+ runs the death handlers.
308
+ def kill: (String raw, ?ack: Fetcher::UnitOfWork?, ?notify: bool) -> true
309
+
310
+ def retry_all: () -> Integer
311
+
312
+ # Queues what #kill sends into +tx+ (a transaction).
313
+ def queue_kill: (Redis::Pipeline tx, String raw, Fetcher::UnitOfWork? ack) -> void
314
+ end
315
+
316
+ # A running Robin process, as its heartbeat left it.
317
+ class ProcessRecord
318
+ # Remote signals, named like the Unix signals that do the same.
319
+ SIGNALS: Hash[String, String]
320
+
321
+ @config: Config
322
+ @quiet: bool
323
+ @leader: bool
324
+
325
+ attr_reader identity: String
326
+
327
+ # What the process says about itself (hostname, pid, capsules...).
328
+ attr_reader info: Hash[String, json]
329
+
330
+ # How many jobs it's running.
331
+ attr_reader busy: Integer
332
+
333
+ # Its last heartbeat, in epoch ms.
334
+ attr_reader beat: Integer
335
+
336
+ # Its resident memory, in KB.
337
+ attr_reader rss: Integer
338
+
339
+ # Its last Redis round trip, in microseconds.
340
+ attr_reader rtt_us: Integer
341
+
342
+ # GVL contention over its last heartbeat interval, as a percentage, or
343
+ # nil where it isn't measured.
344
+ attr_reader gvl_contention: Float?
345
+
346
+ def initialize: (String identity, Hash[String, String] data, ?config: Config) -> void
347
+
348
+ def []: (String key) -> json
349
+
350
+ # Epoch ms.
351
+ def started_at: () -> Integer?
352
+
353
+ def quiet?: () -> bool
354
+
355
+ def leader?: () -> bool
356
+
357
+ def quiet!: () -> true
358
+
359
+ def stop!: () -> true
360
+
361
+ def dump_threads: () -> true
362
+
363
+ # Has the process run +count+ workers in +capsule+.
364
+ def resize!: (Integer count, ?capsule: String) -> true
365
+
366
+ def to_h: () -> Hash[String, json]
367
+
368
+ private
369
+
370
+ def signal: (String name) -> true
371
+
372
+ def send_signal: (String signal) -> true
373
+ end
374
+
375
+ # The running processes.
376
+ class ProcessSet
377
+ include Enumerable[ProcessRecord]
378
+
379
+ @config: Config
380
+
381
+ def initialize: (?config: Config) -> void
382
+
383
+ def each: () { (ProcessRecord process) -> void } -> void
384
+ | () -> Enumerator[ProcessRecord, void]
385
+
386
+ def size: () -> Integer
387
+
388
+ def total_concurrency: () -> Integer
389
+
390
+ def total_rss_kb: () -> Integer
391
+
392
+ # The leader's identity, if there is one.
393
+ def leader: () -> String?
394
+
395
+ private
396
+
397
+ # A process read from Redis.
398
+ def record: (String identity, Hash[String, String] data) -> ProcessRecord
399
+ end
400
+
401
+ # Finds where a job is by jid.
402
+ class JobLocator
403
+ # Where => set.
404
+ SETS: Hash[String, singleton(ScheduledSet) | singleton(RetrySet) | singleton(DeadSet)]
405
+
406
+ QUEUE_LIMIT: Integer
407
+
408
+ @config: Config
409
+
410
+ def initialize: (?config: Config) -> void
411
+
412
+ # Where the job is: hashes with "where" ("busy", "scheduled",
413
+ # "retries", "dead" or "queue") and "job" (a JobRecord), plus the
414
+ # process ("identity", "thread") or the "queue".
415
+ def locate: (String jid) -> Array[Hash[String, untyped]]
416
+
417
+ private
418
+
419
+ def busy: (String jid) -> Array[Hash[String, untyped]]
420
+
421
+ def sets: (String jid) -> Array[Hash[String, untyped]]
422
+
423
+ def queued: (String jid) -> Array[Hash[String, untyped]]
424
+ end
425
+
426
+ # Jobs currently running across the cluster.
427
+ class WorkSet
428
+ include Enumerable[[String, String, Hash[String, json]]]
429
+
430
+ @config: Config
431
+
432
+ def initialize: (?config: Config) -> void
433
+
434
+ # Yields (identity, thread name, {"queue", "payload" (the job hash),
435
+ # "run_at" (epoch ms)}).
436
+ def each: () { (String identity, String thread, Hash[String, json] work) -> void } -> void
437
+ | () { ([String, String, Hash[String, json]] row) -> void } -> void
438
+ | () -> Enumerator[[String, String, Hash[String, json]], void]
439
+
440
+ def size: () -> Integer
441
+ end
442
+ end