robin 0.1.0-java

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 (217) 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/java/robin_resp/Blocking.java +27 -0
  13. data/ext/java/robin_resp/NativeIO.java +229 -0
  14. data/ext/java/robin_resp/NativeRESP.java +279 -0
  15. data/ext/java/robin_resp/NativeSlots.java +133 -0
  16. data/ext/java/robin_resp/RobinRespService.java +32 -0
  17. data/lib/active_job/queue_adapters/robin_adapter.rb +3 -0
  18. data/lib/generators/robin/install/install_generator.rb +39 -0
  19. data/lib/generators/robin/install/templates/initializer.rb.tt +31 -0
  20. data/lib/generators/robin/install/templates/robin.yml.tt +25 -0
  21. data/lib/generators/robin/job/job_generator.rb +78 -0
  22. data/lib/generators/robin/job/templates/job.rb.tt +13 -0
  23. data/lib/generators/robin/job/templates/job_spec.rb.tt +21 -0
  24. data/lib/generators/robin/job/templates/job_test.rb.tt +21 -0
  25. data/lib/puma/plugin/robin.rb +131 -0
  26. data/lib/robin/active_job.rb +144 -0
  27. data/lib/robin/api.rb +777 -0
  28. data/lib/robin/batch.rb +700 -0
  29. data/lib/robin/cancellation.rb +62 -0
  30. data/lib/robin/cli.rb +325 -0
  31. data/lib/robin/client.rb +372 -0
  32. data/lib/robin/config.rb +461 -0
  33. data/lib/robin/cron.rb +325 -0
  34. data/lib/robin/debounce.rb +108 -0
  35. data/lib/robin/deploy.rb +65 -0
  36. data/lib/robin/embedded.rb +53 -0
  37. data/lib/robin/encryption.rb +147 -0
  38. data/lib/robin/events.rb +60 -0
  39. data/lib/robin/expiry.rb +41 -0
  40. data/lib/robin/fetcher.rb +441 -0
  41. data/lib/robin/gvl.rb +62 -0
  42. data/lib/robin/health.rb +76 -0
  43. data/lib/robin/iterable_job.rb +294 -0
  44. data/lib/robin/job.rb +258 -0
  45. data/lib/robin/job_class.rb +157 -0
  46. data/lib/robin/job_logger.rb +121 -0
  47. data/lib/robin/launcher.rb +658 -0
  48. data/lib/robin/leader.rb +86 -0
  49. data/lib/robin/limiter.rb +639 -0
  50. data/lib/robin/manager.rb +125 -0
  51. data/lib/robin/metrics.rb +303 -0
  52. data/lib/robin/middleware.rb +165 -0
  53. data/lib/robin/opentelemetry.rb +88 -0
  54. data/lib/robin/periodic.rb +327 -0
  55. data/lib/robin/processor.rb +317 -0
  56. data/lib/robin/profiler.rb +140 -0
  57. data/lib/robin/progress.rb +46 -0
  58. data/lib/robin/rails/app_loader.rb +23 -0
  59. data/lib/robin/rails/current_attributes.rb +88 -0
  60. data/lib/robin/rails/error_reporter.rb +31 -0
  61. data/lib/robin/rails/notifications.rb +22 -0
  62. data/lib/robin/rails/railtie.rb +87 -0
  63. data/lib/robin/rails/transactional_push.rb +49 -0
  64. data/lib/robin/rails.rb +23 -0
  65. data/lib/robin/recovery.rb +135 -0
  66. data/lib/robin/redis/connection.rb +639 -0
  67. data/lib/robin/redis/pool.rb +190 -0
  68. data/lib/robin/redis/resp.rb +77 -0
  69. data/lib/robin/reliable_push.rb +153 -0
  70. data/lib/robin/retrier.rb +284 -0
  71. data/lib/robin/scheduler.rb +102 -0
  72. data/lib/robin/scripts.rb +331 -0
  73. data/lib/robin/statsd.rb +135 -0
  74. data/lib/robin/swarm.rb +319 -0
  75. data/lib/robin/systemd.rb +47 -0
  76. data/lib/robin/testing.rb +158 -0
  77. data/lib/robin/top.rb +178 -0
  78. data/lib/robin/unique.rb +198 -0
  79. data/lib/robin/version.rb +5 -0
  80. data/lib/robin/warmup.rb +94 -0
  81. data/lib/robin/web/api.rb +580 -0
  82. data/lib/robin/web/batch_status.rb +44 -0
  83. data/lib/robin/web/dist/assets/ar-y7v9b75f.js +1 -0
  84. data/lib/robin/web/dist/assets/ar-y7v9b75f.js.gz +0 -0
  85. data/lib/robin/web/dist/assets/bricolage-0qmzcpnj.woff2 +0 -0
  86. data/lib/robin/web/dist/assets/cs-df88mq5e.js +1 -0
  87. data/lib/robin/web/dist/assets/cs-df88mq5e.js.gz +0 -0
  88. data/lib/robin/web/dist/assets/da-kemms74g.js +1 -0
  89. data/lib/robin/web/dist/assets/da-kemms74g.js.gz +0 -0
  90. data/lib/robin/web/dist/assets/de-z8kkqg65.js +1 -0
  91. data/lib/robin/web/dist/assets/de-z8kkqg65.js.gz +0 -0
  92. data/lib/robin/web/dist/assets/es-9ahrrn1s.js +1 -0
  93. data/lib/robin/web/dist/assets/es-9ahrrn1s.js.gz +0 -0
  94. data/lib/robin/web/dist/assets/fa-7r0x28nc.js +1 -0
  95. data/lib/robin/web/dist/assets/fa-7r0x28nc.js.gz +0 -0
  96. data/lib/robin/web/dist/assets/favicon-1ebfcc0182.svg +31 -0
  97. data/lib/robin/web/dist/assets/favicon-1ebfcc0182.svg.gz +0 -0
  98. data/lib/robin/web/dist/assets/fr-r7mqf3d9.js +1 -0
  99. data/lib/robin/web/dist/assets/fr-r7mqf3d9.js.gz +0 -0
  100. data/lib/robin/web/dist/assets/he-7t46b6rt.js +1 -0
  101. data/lib/robin/web/dist/assets/he-7t46b6rt.js.gz +0 -0
  102. data/lib/robin/web/dist/assets/hi-zj434tx4.js +1 -0
  103. data/lib/robin/web/dist/assets/hi-zj434tx4.js.gz +0 -0
  104. data/lib/robin/web/dist/assets/it-pqc2m7gm.js +1 -0
  105. data/lib/robin/web/dist/assets/it-pqc2m7gm.js.gz +0 -0
  106. data/lib/robin/web/dist/assets/ja-k9rgm1pj.js +1 -0
  107. data/lib/robin/web/dist/assets/ja-k9rgm1pj.js.gz +0 -0
  108. data/lib/robin/web/dist/assets/ko-bxersv91.js +1 -0
  109. data/lib/robin/web/dist/assets/ko-bxersv91.js.gz +0 -0
  110. data/lib/robin/web/dist/assets/main-anw3f6ba.css +1 -0
  111. data/lib/robin/web/dist/assets/main-anw3f6ba.css.gz +0 -0
  112. data/lib/robin/web/dist/assets/main-pdtvjejb.js +7 -0
  113. data/lib/robin/web/dist/assets/main-pdtvjejb.js.gz +0 -0
  114. data/lib/robin/web/dist/assets/main-zz8zzhwn.js +2 -0
  115. data/lib/robin/web/dist/assets/main-zz8zzhwn.js.gz +0 -0
  116. data/lib/robin/web/dist/assets/nb-fjnc5064.js +1 -0
  117. data/lib/robin/web/dist/assets/nb-fjnc5064.js.gz +0 -0
  118. data/lib/robin/web/dist/assets/nl-9p8b95b6.js +1 -0
  119. data/lib/robin/web/dist/assets/nl-9p8b95b6.js.gz +0 -0
  120. data/lib/robin/web/dist/assets/pl-8xsrdn8n.js +1 -0
  121. data/lib/robin/web/dist/assets/pl-8xsrdn8n.js.gz +0 -0
  122. data/lib/robin/web/dist/assets/pt-BR-650j7cvg.js +1 -0
  123. data/lib/robin/web/dist/assets/pt-BR-650j7cvg.js.gz +0 -0
  124. data/lib/robin/web/dist/assets/robin-ae4a4aedd9.svg +34 -0
  125. data/lib/robin/web/dist/assets/robin-ae4a4aedd9.svg.gz +0 -0
  126. data/lib/robin/web/dist/assets/robin-wordmark-5dde5d8e4b.svg +4 -0
  127. data/lib/robin/web/dist/assets/robin-wordmark-5dde5d8e4b.svg.gz +0 -0
  128. data/lib/robin/web/dist/assets/ru-a9ftyw3d.js +1 -0
  129. data/lib/robin/web/dist/assets/ru-a9ftyw3d.js.gz +0 -0
  130. data/lib/robin/web/dist/assets/sv-j9gqamr1.js +1 -0
  131. data/lib/robin/web/dist/assets/sv-j9gqamr1.js.gz +0 -0
  132. data/lib/robin/web/dist/assets/tr-y9z0q51g.js +1 -0
  133. data/lib/robin/web/dist/assets/tr-y9z0q51g.js.gz +0 -0
  134. data/lib/robin/web/dist/assets/uk-2dr9ew3p.js +1 -0
  135. data/lib/robin/web/dist/assets/uk-2dr9ew3p.js.gz +0 -0
  136. data/lib/robin/web/dist/assets/ur-h25nzq1s.js +1 -0
  137. data/lib/robin/web/dist/assets/ur-h25nzq1s.js.gz +0 -0
  138. data/lib/robin/web/dist/assets/vi-9y2ff1bd.js +1 -0
  139. data/lib/robin/web/dist/assets/vi-9y2ff1bd.js.gz +0 -0
  140. data/lib/robin/web/dist/assets/zh-CN-tbj9mf98.js +1 -0
  141. data/lib/robin/web/dist/assets/zh-CN-tbj9mf98.js.gz +0 -0
  142. data/lib/robin/web/dist/assets/zh-TW-59q8j9vw.js +1 -0
  143. data/lib/robin/web/dist/assets/zh-TW-59q8j9vw.js.gz +0 -0
  144. data/lib/robin/web/dist/index.html +19 -0
  145. data/lib/robin/web/extension.rb +193 -0
  146. data/lib/robin/web/permissions.rb +40 -0
  147. data/lib/robin/web/prometheus.rb +79 -0
  148. data/lib/robin/web/router.rb +150 -0
  149. data/lib/robin/web/static.rb +110 -0
  150. data/lib/robin/web.rb +196 -0
  151. data/lib/robin.rb +261 -0
  152. data/lib/robin_resp/robin_resp.jar +0 -0
  153. data/sig/manifest.yaml +9 -0
  154. data/sig/robin/api.rbs +442 -0
  155. data/sig/robin/batch.rbs +292 -0
  156. data/sig/robin/cancellation.rbs +25 -0
  157. data/sig/robin/cli.rbs +102 -0
  158. data/sig/robin/client.rbs +118 -0
  159. data/sig/robin/config.rbs +341 -0
  160. data/sig/robin/cron.rbs +149 -0
  161. data/sig/robin/debounce.rbs +36 -0
  162. data/sig/robin/deploy.rbs +24 -0
  163. data/sig/robin/embedded.rbs +25 -0
  164. data/sig/robin/encryption.rbs +49 -0
  165. data/sig/robin/events.rbs +10 -0
  166. data/sig/robin/expiry.rbs +17 -0
  167. data/sig/robin/fetcher.rbs +134 -0
  168. data/sig/robin/gvl.rbs +39 -0
  169. data/sig/robin/health.rbs +30 -0
  170. data/sig/robin/iterable_job.rbs +99 -0
  171. data/sig/robin/job.rbs +173 -0
  172. data/sig/robin/job_class.rbs +55 -0
  173. data/sig/robin/job_logger.rbs +56 -0
  174. data/sig/robin/launcher.rbs +191 -0
  175. data/sig/robin/leader.rbs +43 -0
  176. data/sig/robin/limiter.rbs +317 -0
  177. data/sig/robin/manager.rbs +54 -0
  178. data/sig/robin/metrics.rbs +122 -0
  179. data/sig/robin/middleware.rbs +106 -0
  180. data/sig/robin/opentelemetry.rbs +51 -0
  181. data/sig/robin/periodic.rbs +81 -0
  182. data/sig/robin/processor.rbs +107 -0
  183. data/sig/robin/profiler.rbs +60 -0
  184. data/sig/robin/progress.rbs +22 -0
  185. data/sig/robin/rails/app_loader.rbs +10 -0
  186. data/sig/robin/rails/current_attributes.rbs +44 -0
  187. data/sig/robin/rails/error_reporter.rbs +21 -0
  188. data/sig/robin/rails/notifications.rbs +9 -0
  189. data/sig/robin/rails/transactional_push.rbs +16 -0
  190. data/sig/robin/rails.rbs +8 -0
  191. data/sig/robin/recovery.rbs +29 -0
  192. data/sig/robin/redis/connection.rbs +224 -0
  193. data/sig/robin/redis/pool.rbs +89 -0
  194. data/sig/robin/redis/resp.rbs +29 -0
  195. data/sig/robin/reliable_push.rbs +77 -0
  196. data/sig/robin/retrier.rbs +72 -0
  197. data/sig/robin/scheduler.rbs +40 -0
  198. data/sig/robin/scripts.rbs +36 -0
  199. data/sig/robin/statsd.rbs +55 -0
  200. data/sig/robin/swarm.rbs +133 -0
  201. data/sig/robin/systemd.rbs +13 -0
  202. data/sig/robin/testing.rbs +80 -0
  203. data/sig/robin/top.rbs +79 -0
  204. data/sig/robin/unique.rbs +72 -0
  205. data/sig/robin/version.rbs +3 -0
  206. data/sig/robin/warmup.rbs +44 -0
  207. data/sig/robin/web/api.rbs +196 -0
  208. data/sig/robin/web/batch_status.rbs +25 -0
  209. data/sig/robin/web/extension.rbs +106 -0
  210. data/sig/robin/web/permissions.rbs +14 -0
  211. data/sig/robin/web/prometheus.rbs +33 -0
  212. data/sig/robin/web/router.rbs +53 -0
  213. data/sig/robin/web/static.rbs +42 -0
  214. data/sig/robin/web.rbs +140 -0
  215. data/sig/robin.rbs +116 -0
  216. data/sig/robin_resp.rbs +55 -0
  217. metadata +294 -0
@@ -0,0 +1,341 @@
1
+ module Robin
2
+ # Seconds: a duration or interval, whole or fractional.
3
+ type seconds = Integer | Float
4
+
5
+ # The callables a config holds (retry_backoff, push_deferrer...) are a
6
+ # lambda (or proc) or any object with a #call like the interface's. The
7
+ # interfaces include _Object, so such a value can be tested like any
8
+ # object's.
9
+ interface _Object
10
+ def !: () -> bool
11
+
12
+ def nil?: () -> bool
13
+
14
+ def respond_to?: (Symbol name, ?bool include_all) -> bool
15
+ end
16
+
17
+ # Called with each error Robin reports: the error, a Hash about where it
18
+ # happened (:context, and :job, :queue... when there's one), and the config.
19
+ interface _ErrorHandler
20
+ def call: (Exception error, Hash[Symbol, untyped] context, Config config) -> void
21
+ end
22
+
23
+ # Called with each job that's out of retries (or killed): its payload and
24
+ # the error (nil when it was killed from the dashboard or the API).
25
+ interface _DeathHandler
26
+ def call: (job_hash payload, Exception? error) -> void
27
+ end
28
+
29
+ # Called with each job recovered from a crashed process, and whether it
30
+ # was a poison pill moved to the dead set.
31
+ interface _RecoveryHandler
32
+ def call: (job_hash payload, bool poison) -> void
33
+ end
34
+
35
+ # Called with each of Robin's events (see Robin::Events).
36
+ interface _EventHandler
37
+ def call: (String name, Hash[Symbol, untyped] payload) -> void
38
+ end
39
+
40
+ # Config#retry_backoff: the seconds before a failed job's retry.
41
+ interface _RetryBackoff
42
+ def call: (Integer failures, Exception error, job_hash payload, Numeric? custom) -> Numeric
43
+
44
+ include _Object
45
+ end
46
+
47
+ type retry_backoff = ^(Integer failures, Exception error, job_hash payload, Numeric? custom) -> Numeric | _RetryBackoff
48
+
49
+ # Config#rate_limit_backoff: the seconds before a rate-limited job runs
50
+ # again, or nil for the default.
51
+ interface _RateLimitBackoff
52
+ def call: (Integer count, Limiter::OverLimit error, job_hash payload) -> seconds?
53
+
54
+ include _Object
55
+ end
56
+
57
+ type rate_limit_backoff = ^(Integer count, Limiter::OverLimit error, job_hash payload) -> seconds? | _RateLimitBackoff
58
+
59
+ # Config#backtrace_cleaner: the backtrace lines to keep.
60
+ interface _BacktraceCleaner
61
+ def call: (Array[String] lines) -> Array[String]
62
+
63
+ include _Object
64
+ end
65
+
66
+ type backtrace_cleaner = ^(Array[String] lines) -> Array[String] | _BacktraceCleaner
67
+
68
+ # Config#push_deferrer: truthy when it took over delivering the payloads
69
+ # (calling the block later, or right away).
70
+ interface _PushDeferrer
71
+ def call: (Array[job_hash] payloads) { () -> void } -> boolish
72
+
73
+ include _Object
74
+ end
75
+
76
+ type push_deferrer = ^(Array[job_hash] payloads) { () -> void } -> boolish | _PushDeferrer
77
+
78
+ # Config#job_wrapper: runs the job (the block) inside something, such as
79
+ # the Rails executor.
80
+ interface _JobWrapper
81
+ def call: (job_hash payload) { () -> void } -> void
82
+
83
+ include _Object
84
+ end
85
+
86
+ type job_wrapper = ^(job_hash payload) { () -> void } -> void | _JobWrapper
87
+
88
+ # A group of worker threads with its own queues and concurrency.
89
+ class Capsule
90
+ @name: String
91
+ @config: Config
92
+ @workers: Hash[Symbol, Integer]
93
+ @weights: Hash[String, Integer]
94
+ @strict: bool
95
+ @expanded: Array[String]
96
+
97
+ attr_reader name: String
98
+ attr_reader config: Config
99
+
100
+ # Each queue's weight (0 for strict priority).
101
+ attr_reader weights: Hash[String, Integer]
102
+
103
+ # The capsule whose worker is running this thread's code, if any.
104
+ def self.current: () -> Capsule?
105
+
106
+ def initialize: (String name, Config config) -> void
107
+
108
+ # How many workers the capsule runs.
109
+ def concurrency: () -> Integer
110
+
111
+ def concurrency=: (Integer count) -> Integer
112
+
113
+ # A running capsule's new worker count (see Manager#resize).
114
+ def resized: (Integer count) -> Integer
115
+
116
+ # Plain names ("critical"), weighted names ("critical,3"), or
117
+ # [name, weight] pairs.
118
+ def queues=: (String | Symbol | Array[String | Symbol | [String | Symbol, Integer | String]] list) -> void
119
+
120
+ def queues: () -> Array[String]
121
+
122
+ def strict?: () -> bool
123
+
124
+ # Queue names in the order they should be checked for the next fetch.
125
+ def queue_order: () -> Array[String]
126
+
127
+ def freeze: () -> self
128
+ end
129
+
130
+ class Config
131
+ DEFAULT_ERROR_HANDLER: ^(Exception ex, Hash[Symbol, untyped] context, Config config) -> void
132
+
133
+ CONNECTION_DEFAULTS: Hash[Symbol, String]
134
+
135
+ JIT_WARMUP: bool
136
+
137
+ LIFECYCLE_EVENTS: Array[Symbol]
138
+
139
+ JID_INDEX_TTL: Integer
140
+
141
+ SHARED_KEYS: Array[String]
142
+
143
+ @redis_options: Hash[Symbol, untyped]
144
+ @capsules: Hash[String, Capsule]
145
+ @client_chain: Middleware::Chain
146
+ @server_chain: Middleware::Chain
147
+ @logger: Logger?
148
+ @redis_pool: Redis::Pool?
149
+ @housekeeping_pool: Redis::Pool?
150
+ @batch_status_class: singleton(Batch::Status)?
151
+ @internal_key_prefix: String?
152
+
153
+ # Seconds a stopping server waits for running jobs (default 25).
154
+ attr_accessor timeout: seconds
155
+
156
+ # Seconds between checks for scheduled jobs and retries due (default 5).
157
+ attr_accessor poll_interval: seconds
158
+
159
+ attr_accessor max_retries: Integer
160
+
161
+ attr_accessor dead_max_jobs: Integer
162
+
163
+ # Seconds a job stays in the dead set.
164
+ attr_accessor dead_timeout: Integer
165
+
166
+ # What a push with arguments that aren't JSON-native does: raise
167
+ # (:raise, the default), log a warning (:warn), or nothing (false/nil).
168
+ attr_accessor strict_args: :raise | :warn | false | nil
169
+
170
+ attr_accessor key_prefix: String
171
+
172
+ attr_accessor tag: String?
173
+
174
+ attr_accessor labels: Array[String]
175
+
176
+ attr_accessor environment: String
177
+
178
+ attr_accessor heartbeat_interval: seconds
179
+
180
+ attr_accessor process_ttl: Integer
181
+
182
+ attr_accessor max_recoveries: Integer
183
+
184
+ attr_accessor backtrace_lines: Integer
185
+
186
+ # {version => key}: the newest version encrypts.
187
+ attr_accessor encryption_keys: Hash[Integer, String]?
188
+
189
+ attr_accessor max_rate_limit_retries: Integer
190
+
191
+ attr_accessor statsd: Statsd?
192
+
193
+ attr_accessor memory_limit_mb: Integer?
194
+
195
+ attr_accessor metrics_retention_days: Integer
196
+
197
+ # true, or the buffer's size (see Robin::ReliablePush).
198
+ attr_accessor reliable_push: bool | Integer
199
+
200
+ attr_accessor shutdown_requeue: bool
201
+
202
+ attr_accessor job_wrapper: job_wrapper?
203
+
204
+ attr_accessor health_bind: String
205
+
206
+ attr_accessor rate_limit_backoff: rate_limit_backoff?
207
+
208
+ attr_writer batch_status_class: singleton(Batch::Status)?
209
+
210
+ # The class of the batch status batch callbacks get.
211
+ def batch_status_class: () -> singleton(Batch::Status)
212
+
213
+ attr_accessor leader_candidate: bool
214
+
215
+ attr_reader recovery_handlers: Array[_RecoveryHandler]
216
+
217
+ attr_reader event_handlers: Array[_EventHandler]
218
+
219
+ attr_accessor gvl_monitoring: bool
220
+
221
+ attr_accessor retry_backoff: retry_backoff?
222
+
223
+ # false, or the fewest jobs that must have finished since the last
224
+ # collection.
225
+ @idle_gc: Integer | bool
226
+
227
+ def idle_gc: () -> (Integer | false)
228
+
229
+ def idle_gc=: (bool | Integer | nil least) -> void
230
+
231
+ attr_accessor jit_warmup: bool
232
+
233
+ attr_accessor fetch_timeout: seconds
234
+
235
+ attr_reader fetch_batch: Integer
236
+
237
+ def fetch_batch=: (Integer | String count) -> void
238
+
239
+ attr_accessor max_iteration_runtime: seconds?
240
+
241
+ attr_accessor backtrace_cleaner: backtrace_cleaner?
242
+
243
+ # Seconds the jid index remembers a job's queue, or nil (off).
244
+ @jid_index: Integer | bool | nil
245
+
246
+ def jid_index: () -> (Integer | false | nil)
247
+
248
+ def jid_index=: (bool | Integer | String | nil value) -> void
249
+
250
+ attr_reader health_port: Integer?
251
+
252
+ def health_port=: (Integer | String | nil port) -> void
253
+
254
+ attr_accessor push_deferrer: push_deferrer?
255
+
256
+ def logger=: (Logger logger) -> Logger
257
+
258
+ attr_writer redis_pool: Redis::Pool?
259
+
260
+ attr_reader capsules: Hash[String, Capsule]
261
+
262
+ attr_reader error_handlers: Array[_ErrorHandler]
263
+
264
+ attr_reader death_handlers: Array[_DeathHandler]
265
+
266
+ attr_reader lifecycle: Hash[Symbol, Array[^() -> void]]
267
+
268
+ attr_reader periodic_blocks: Array[^(Periodic::Registry cron) -> void]
269
+
270
+ def initialize: () -> void
271
+
272
+ # Built-in middleware powering per-job options.
273
+ def install_default_middleware: () -> Middleware::Chain
274
+
275
+ def default_capsule: () -> Capsule
276
+
277
+ def concurrency: () -> Integer
278
+
279
+ def concurrency=: (Integer n) -> void
280
+
281
+ def queues: () -> Array[String]
282
+
283
+ def queues=: (String | Symbol | Array[String | Symbol | [String | Symbol, Integer | String]] list) -> void
284
+
285
+ def capsule: (String | Symbol name) ?{ (Capsule cap) -> void } -> Capsule
286
+
287
+ def total_concurrency: () -> Integer
288
+
289
+ # Called when a server boots: capsules can't change afterwards.
290
+ def freeze_capsules!: () -> Hash[String, Capsule]
291
+
292
+ # Redis options (see Robin::Redis::Connection), plus :pool_size,
293
+ # :pool_timeout and :idle_timeout for the pool.
294
+ def redis=: (Hash[Symbol | String, untyped] options) -> void
295
+
296
+ attr_reader redis_options: Hash[Symbol, untyped]
297
+
298
+ # The shared connection pool.
299
+ def redis_pool: () -> Redis::Pool
300
+
301
+ # Makes the shared pool big enough for +workers+ worker threads.
302
+ def fit_redis_pool: (Integer workers) -> bool
303
+
304
+ # A small pool reserved for a server's own housekeeping.
305
+ def housekeeping_pool: () -> Redis::Pool
306
+
307
+ def redis: [T] () { (Redis::Connection conn) -> T } -> T
308
+
309
+ attr_writer internal_key_prefix: String?
310
+
311
+ def internal_key_prefix: () -> String
312
+
313
+ def key: (*String | Symbol | Integer | nil parts) -> String
314
+
315
+ def process_key: (String identity) -> String
316
+
317
+ def logger: () -> Logger
318
+
319
+ def client_middleware: () ?{ (Middleware::Chain chain) -> void } -> Middleware::Chain
320
+
321
+ def server_middleware: () ?{ (Middleware::Chain chain) -> void } -> Middleware::Chain
322
+
323
+ # Registers a lifecycle callback: :startup, :quiet, :shutdown, :leader,
324
+ # :follower, :heartbeat, :exit or :fork.
325
+ def on: (Symbol event) { () -> void } -> Array[^() -> void]
326
+
327
+ # Runs the callbacks for +event+.
328
+ def fire_event: (Symbol event, ?reverse: bool, ?reraise: bool) -> void
329
+
330
+ # Registers periodic (cron) jobs.
331
+ def periodic: () { (Periodic::Registry cron) -> void } -> Array[^(Periodic::Registry cron) -> void]
332
+
333
+ def handle_exception: (Exception ex, ?Hash[Symbol, untyped] context) -> void
334
+
335
+ def inspect: () -> String
336
+
337
+ private
338
+
339
+ def default_pool_size: (Integer workers) -> Integer
340
+ end
341
+ end
@@ -0,0 +1,149 @@
1
+ module Robin
2
+ # A cron expression (five fields, or six with leading seconds; names, L,
3
+ # ? and @shortcuts), in a time zone.
4
+ class Cron
5
+ class ParseError < ArgumentError
6
+ end
7
+
8
+ SHORTCUTS: Hash[String, String]
9
+ MONTHS: Hash[String, Integer]
10
+ DAYS: Hash[String, Integer]
11
+ DAY_NAMES: Array[String]
12
+ MONTH_NAMES: Array[String]
13
+ ANY: Array[String]
14
+ MAX_STEPS: Integer
15
+
16
+ @last_dom: bool
17
+ @dom_any: bool
18
+ @dow_any: bool
19
+
20
+ attr_reader expression: String
21
+
22
+ # The time zone: nil (the system's), "UTC", an offset ("+05:30") or an
23
+ # IANA name ("Europe/Berlin", with the tzinfo gem).
24
+ attr_reader tz: String?
25
+
26
+ attr_reader zone: Zone::_Zone
27
+
28
+ attr_reader seconds: Array[Integer]
29
+ attr_reader minutes: Array[Integer]
30
+ attr_reader hours: Array[Integer]
31
+ attr_reader days: Array[Integer]
32
+ attr_reader months: Array[Integer]
33
+ attr_reader weekdays: Array[Integer]
34
+
35
+ def initialize: (_ToS expression, ?tz: String?) -> void
36
+
37
+ def to_s: () -> String
38
+
39
+ def inspect: () -> String
40
+
41
+ # Whether +time+ (to the second) matches.
42
+ def match?: (Time time) -> bool
43
+
44
+ # The first matching time strictly after +from+, in UTC (nil for an
45
+ # expression that never matches).
46
+ def next_time: (?Time from) -> Time?
47
+
48
+ # The last matching time strictly before +from+, in UTC.
49
+ def previous_time: (?Time from) -> Time?
50
+
51
+ # Best-effort English description.
52
+ def description: () -> String
53
+
54
+ private
55
+
56
+ def next_month: (Time w) -> Time
57
+
58
+ def next_day: (Time w) -> Time
59
+
60
+ def describe_time: () -> String?
61
+
62
+ def step_of: (Array[Integer] values, Integer max) -> Integer?
63
+
64
+ def contiguous?: (Array[Integer] values) -> bool
65
+
66
+ def every: (Integer step, String unit) -> String
67
+
68
+ def describe_days: () -> String?
69
+
70
+ def describe_dom: () -> String?
71
+
72
+ def describe_dow: () -> String?
73
+
74
+ def describe_months: () -> String?
75
+
76
+ def parse: (String expr) -> void
77
+
78
+ def field: (String text, Integer min, Integer max, ?Hash[String, Integer] names) -> Array[Integer]
79
+
80
+ def value: (String text, Hash[String, Integer] names) -> Integer
81
+
82
+ def day_match?: (Time w) -> bool
83
+
84
+ # Converts between UTC instants and "wall clock" times (UTC Times
85
+ # holding the local fields).
86
+ module Zone
87
+ interface _Zone
88
+ # The zone's name for descriptions (nil for the system zone).
89
+ def label: () -> String?
90
+
91
+ def to_wall: (Time time) -> Time
92
+
93
+ # nil for wall times skipped by a daylight-saving change.
94
+ def to_utc: (Time wall) -> Time?
95
+ end
96
+
97
+ OFFSET: Regexp
98
+
99
+ def self.for: (String? tz) -> (Fixed | Local | IANA)
100
+
101
+ # A fixed offset from UTC (a _Zone).
102
+ class Fixed
103
+ @offset: Integer
104
+
105
+ attr_reader label: String
106
+
107
+ def initialize: (Integer offset, String label) -> void
108
+
109
+ def to_wall: (Time time) -> Time
110
+
111
+ def to_utc: (Time wall) -> Time
112
+ end
113
+
114
+ # The system's zone (a _Zone).
115
+ class Local
116
+ attr_reader label: nil
117
+
118
+ def to_wall: (Time time) -> Time
119
+
120
+ def to_utc: (Time wall) -> Time?
121
+ end
122
+
123
+ # An IANA zone, with the tzinfo gem (a _Zone).
124
+ class IANA
125
+ # What Robin uses of a TZInfo::Timezone (Robin doesn't depend on
126
+ # tzinfo, so its signatures can't name it).
127
+ interface _Timezone
128
+ def utc_to_local: (Time utc_time) -> Time
129
+
130
+ def local_to_utc: (Time local_time, ?bool? dst) -> Time
131
+ end
132
+
133
+ @tz: _Timezone
134
+
135
+ attr_reader label: String
136
+
137
+ def to_wall: (Time time) -> Time
138
+
139
+ def to_utc: (Time wall) -> Time?
140
+
141
+ def self.lookup: (String name) -> _Timezone
142
+
143
+ def self.load_tzinfo: (String name) -> bool
144
+
145
+ def initialize: (String name) -> void
146
+ end
147
+ end
148
+ end
149
+ end
@@ -0,0 +1,36 @@
1
+ module Robin
2
+ # Debounced jobs: a burst of pushes with the same arguments collapses
3
+ # into a single run, +debounce+ seconds after the last push.
4
+ module Debounce
5
+ CLAIM: Redis::Script
6
+
7
+ # The instance variable a push's claim waits on.
8
+ CLAIM_IVAR: Symbol
9
+
10
+ # Queues the claims of +payloads+ on +pipe+, ahead of the jobs.
11
+ def self.queue_claims: (Redis::Pipeline pipe, Array[job_hash] payloads) -> void
12
+
13
+ # Moves the claim of +from+ to +to+, the payload the middleware chain
14
+ # returned instead.
15
+ def self.carry: (job_hash from, job_hash? to) -> void
16
+
17
+ class ClientMiddleware
18
+ include Middleware::ConfigAware
19
+ include Middleware::Stateless
20
+
21
+ def self.applies?: (String job_class, job_hash payload, String queue, Redis::Pool redis) -> bool
22
+
23
+ def call: (String job_class, job_hash payload, String queue, Redis::Pool redis) { () -> job_hash? } -> job_hash?
24
+ end
25
+
26
+ # Skips debounced jobs superseded by a later push.
27
+ class ServerMiddleware
28
+ include Middleware::ConfigAware
29
+ include Middleware::Stateless
30
+
31
+ def self.applies?: (untyped job, job_hash payload, String queue) -> bool
32
+
33
+ def call: (untyped job, job_hash payload, String queue) { () -> untyped } -> untyped
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,24 @@
1
+ module Robin
2
+ # Deploy markers, drawn on the dashboard's metrics charts.
3
+ module Deploy
4
+ DEDUP_SECONDS: Integer
5
+
6
+ MAX_LABEL: Integer
7
+
8
+ MARK: Redis::Script
9
+
10
+ # Records a deploy at +at+. Returns false when +label+ was already
11
+ # marked in the last hour, true otherwise.
12
+ def self.mark!: (?_ToS? label, ?at: Time, ?config: Config) -> bool
13
+
14
+ # Deploys from +from+ to +to+, oldest first: {"at" => epoch ms,
15
+ # "label" => String or nil}.
16
+ def self.list: (from: Time, ?to: Time, ?config: Config) -> Array[Hash[String, untyped]]
17
+
18
+ def self.key: (Config config) -> String
19
+
20
+ private def self.ms: (Time time) -> Integer
21
+
22
+ private def self.dedup_key: (Config config, String label) -> String
23
+ end
24
+ end
@@ -0,0 +1,25 @@
1
+ module Robin
2
+ # Runs a Robin server inside another process (see the Puma plugin).
3
+ class Embedded
4
+ @stop_lock: Thread::Mutex
5
+
6
+ # nil until #run.
7
+ @launcher: Launcher
8
+
9
+ attr_reader config: Config
10
+
11
+ # The server's launcher, once it runs.
12
+ def launcher: () -> Launcher?
13
+
14
+ def initialize: (Config config) -> void
15
+
16
+ def configure: () ?{ (Config config) -> void } -> self
17
+
18
+ def run: () -> self
19
+
20
+ def quiet: () -> void
21
+
22
+ # Stops the server gracefully and returns once it has stopped.
23
+ def stop: () -> void
24
+ end
25
+ end
@@ -0,0 +1,49 @@
1
+ module Robin
2
+ # Encrypts job arguments at rest with AES-256-GCM (robin_options
3
+ # encrypt: true, or "last" for just the last argument).
4
+ module Encryption
5
+ class Error < Robin::Error
6
+ end
7
+
8
+ CIPHER: String
9
+ IV_BYTES: Integer
10
+ TAG_BYTES: Integer
11
+
12
+ # The configured keys, by version, as 32 raw bytes.
13
+ def self.keys: (Config config) -> Hash[Integer, String]
14
+
15
+ # A key as 32 raw bytes, from raw bytes, 64 hex characters or base64.
16
+ def self.normalize_key: (_ToS key) -> String
17
+
18
+ # Returns [version, ciphertext (base64)].
19
+ def self.encrypt: (Config config, json args, String aad) -> [Integer, String]
20
+
21
+ def self.decrypt: (Config config, Integer version, String blob, String aad) -> json
22
+
23
+ # Whether only the job's last argument is encrypted.
24
+ def self.last_only?: (job_hash payload) -> bool
25
+
26
+ # An encrypted job's arguments as they may be shown.
27
+ def self.visible_args: (job_hash payload) -> Array[untyped]
28
+
29
+ def self.cipher: (:encrypt | :decrypt mode, String key) -> OpenSSL::Cipher
30
+
31
+ class ClientMiddleware
32
+ include Middleware::ConfigAware
33
+ include Middleware::Stateless
34
+
35
+ def self.applies?: (String job_class, job_hash payload, String queue, Redis::Pool redis) -> bool
36
+
37
+ def call: (String job_class, job_hash payload, String queue, Redis::Pool redis) { () -> job_hash? } -> job_hash?
38
+ end
39
+
40
+ class ServerMiddleware
41
+ include Middleware::ConfigAware
42
+ include Middleware::Stateless
43
+
44
+ def self.applies?: (untyped job, job_hash payload, String queue) -> bool
45
+
46
+ def call: (untyped job, job_hash payload, String queue) { () -> untyped } -> untyped
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,10 @@
1
+ module Robin
2
+ # Things worth knowing about that aren't errors, as events (see
3
+ # Config#event_handlers for the handlers, and lib/robin/events.rb for
4
+ # the list).
5
+ module Events
6
+ # Calls every handler; one that raises is reported and the others still
7
+ # run.
8
+ def self.emit: (Config config, String name, **untyped payload) -> nil
9
+ end
10
+ end
@@ -0,0 +1,17 @@
1
+ module Robin
2
+ # Expiring jobs: work that's worthless after a deadline (expires_in).
3
+ module Expiry
4
+ # Whether the job's "expires_at" (epoch ms) has passed.
5
+ def self.expired?: (job_hash payload, ?Integer now) -> bool
6
+
7
+ # Skips expired jobs (they count as done).
8
+ class ServerMiddleware
9
+ include Middleware::ConfigAware
10
+ include Middleware::Stateless
11
+
12
+ def self.applies?: (untyped job, job_hash payload, String queue) -> bool
13
+
14
+ def call: (untyped job, job_hash payload, String queue) { () -> untyped } -> untyped
15
+ end
16
+ end
17
+ end