karafka 2.5.9 → 2.6.0.beta1

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 (471) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +34 -0
  3. data/certs/expired.txt +83 -0
  4. data/config/locales/errors.yml +17 -7
  5. data/karafka.gemspec +3 -3
  6. data/lib/active_job/queue_adapters/karafka_adapter.rb +1 -2
  7. data/lib/karafka/active_job/job_extensions.rb +1 -2
  8. data/lib/karafka/admin/configs/resource.rb +1 -2
  9. data/lib/karafka/admin/consumer_groups.rb +109 -98
  10. data/lib/karafka/admin/isolation_levels.rb +22 -0
  11. data/lib/karafka/admin/topics.rb +103 -8
  12. data/lib/karafka/admin.rb +59 -31
  13. data/lib/karafka/app.rb +16 -5
  14. data/lib/karafka/base_consumer.rb +2 -2
  15. data/lib/karafka/cli/contracts/server.rb +4 -4
  16. data/lib/karafka/cli/info.rb +1 -1
  17. data/lib/karafka/cli/topics/base.rb +10 -18
  18. data/lib/karafka/cli/topics/repartition.rb +1 -1
  19. data/lib/karafka/connection/client.rb +40 -9
  20. data/lib/karafka/connection/consumer_groups/rebalance_manager.rb +120 -0
  21. data/lib/karafka/connection/listener.rb +8 -7
  22. data/lib/karafka/connection/listeners_batch.rb +1 -1
  23. data/lib/karafka/connection/mode.rb +1 -2
  24. data/lib/karafka/connection/raw_messages_buffer.rb +0 -5
  25. data/lib/karafka/declaratives/builder.rb +65 -0
  26. data/lib/karafka/declaratives/contracts/topic.rb +28 -0
  27. data/lib/karafka/declaratives/repository.rb +52 -0
  28. data/lib/karafka/declaratives/topic.rb +100 -0
  29. data/lib/karafka/declaratives.rb +9 -0
  30. data/lib/karafka/helpers/interval_runner.rb +2 -2
  31. data/lib/karafka/instrumentation/assignments_tracker.rb +65 -2
  32. data/lib/karafka/instrumentation/callbacks/consumer_groups/error.rb +56 -0
  33. data/lib/karafka/instrumentation/callbacks/consumer_groups/rebalance.rb +93 -0
  34. data/lib/karafka/instrumentation/callbacks/consumer_groups/statistics.rb +59 -0
  35. data/lib/karafka/instrumentation/logger_listener.rb +27 -9
  36. data/lib/karafka/instrumentation/notifications.rb +2 -0
  37. data/lib/karafka/instrumentation/vendors/appsignal/metrics_listener.rb +14 -17
  38. data/lib/karafka/instrumentation/vendors/datadog/metrics_listener.rb +8 -9
  39. data/lib/karafka/instrumentation/vendors/kubernetes/base_listener.rb +7 -3
  40. data/lib/karafka/instrumentation/vendors/kubernetes/liveness_listener.rb +13 -10
  41. data/lib/karafka/licenser.rb +16 -3
  42. data/lib/karafka/pro/active_job/consumer.rb +1 -2
  43. data/lib/karafka/pro/active_job/dispatcher.rb +1 -2
  44. data/lib/karafka/pro/admin/recovery.rb +19 -19
  45. data/lib/karafka/pro/base_consumer.rb +3 -3
  46. data/lib/karafka/pro/cli/contracts/server.rb +5 -5
  47. data/lib/karafka/pro/cli/parallel_segments/base.rb +7 -7
  48. data/lib/karafka/pro/cli/parallel_segments/collapse.rb +4 -4
  49. data/lib/karafka/pro/cli/parallel_segments/distribute.rb +6 -6
  50. data/lib/karafka/pro/iterator/tpl_builder.rb +38 -18
  51. data/lib/karafka/pro/loader.rb +15 -12
  52. data/lib/karafka/pro/processing/consumer_groups/adaptive_iterator/consumer.rb +84 -0
  53. data/lib/karafka/pro/processing/consumer_groups/adaptive_iterator/tracker.rb +97 -0
  54. data/lib/karafka/pro/processing/consumer_groups/collapser.rb +84 -0
  55. data/lib/karafka/pro/processing/consumer_groups/coordinator.rb +202 -0
  56. data/lib/karafka/pro/processing/consumer_groups/coordinators/errors_tracker.rb +124 -0
  57. data/lib/karafka/pro/processing/consumer_groups/coordinators/filters_applier.rb +157 -0
  58. data/lib/karafka/pro/processing/consumer_groups/coordinators/virtual_offset_manager.rb +212 -0
  59. data/lib/karafka/pro/processing/{filters/expirer.rb → consumer_groups/executor.rb} +17 -31
  60. data/lib/karafka/pro/processing/{jobs/periodic.rb → consumer_groups/expansions_selector.rb} +18 -21
  61. data/lib/karafka/pro/processing/consumer_groups/filters/base.rb +103 -0
  62. data/lib/karafka/pro/processing/consumer_groups/filters/delayer.rb +92 -0
  63. data/lib/karafka/pro/processing/consumer_groups/filters/expirer.rb +78 -0
  64. data/lib/karafka/pro/processing/consumer_groups/filters/inline_insights_delayer.rb +99 -0
  65. data/lib/karafka/pro/processing/consumer_groups/filters/throttler.rb +106 -0
  66. data/lib/karafka/pro/processing/consumer_groups/filters/virtual_limiter.rb +79 -0
  67. data/lib/karafka/pro/processing/{jobs → consumer_groups/jobs}/consume_non_blocking.rb +21 -17
  68. data/lib/karafka/pro/processing/{virtual_partitions/distributors/consistent.rb → consumer_groups/jobs/eofed_non_blocking.rb} +16 -14
  69. data/lib/karafka/pro/processing/consumer_groups/jobs/periodic.rb +64 -0
  70. data/lib/karafka/pro/processing/{jobs → consumer_groups/jobs}/periodic_non_blocking.rb +16 -11
  71. data/lib/karafka/pro/processing/{jobs → consumer_groups/jobs}/revoked_non_blocking.rb +19 -15
  72. data/lib/karafka/pro/processing/consumer_groups/jobs_builder.rb +95 -0
  73. data/lib/karafka/pro/processing/consumer_groups/offset_metadata/consumer.rb +66 -0
  74. data/lib/karafka/pro/processing/consumer_groups/offset_metadata/fetcher.rb +154 -0
  75. data/lib/karafka/pro/processing/consumer_groups/offset_metadata/listener.rb +68 -0
  76. data/lib/karafka/pro/processing/consumer_groups/parallel_segments/filters/base.rb +102 -0
  77. data/lib/karafka/pro/processing/consumer_groups/parallel_segments/filters/default.rb +115 -0
  78. data/lib/karafka/pro/processing/consumer_groups/parallel_segments/filters/mom.rb +96 -0
  79. data/lib/karafka/pro/processing/consumer_groups/partitioner.rb +98 -0
  80. data/lib/karafka/pro/processing/consumer_groups/periodic_job/consumer.rb +90 -0
  81. data/lib/karafka/pro/processing/consumer_groups/piping/consumer.rb +154 -0
  82. data/lib/karafka/pro/processing/consumer_groups/strategies/aj/dlq_ftr_lrj_mom.rb +93 -0
  83. data/lib/karafka/pro/processing/consumer_groups/strategies/aj/dlq_ftr_lrj_mom_vp.rb +99 -0
  84. data/lib/karafka/pro/processing/consumer_groups/strategies/aj/dlq_ftr_mom.rb +92 -0
  85. data/lib/karafka/pro/processing/consumer_groups/strategies/aj/dlq_ftr_mom_vp.rb +90 -0
  86. data/lib/karafka/pro/processing/{strategies/aj/dlq_ftr_lrj_mom.rb → consumer_groups/strategies/aj/dlq_lrj_mom.rb} +37 -39
  87. data/lib/karafka/pro/processing/consumer_groups/strategies/aj/dlq_lrj_mom_vp.rb +90 -0
  88. data/lib/karafka/pro/processing/consumer_groups/strategies/aj/dlq_mom.rb +84 -0
  89. data/lib/karafka/pro/processing/consumer_groups/strategies/aj/dlq_mom_vp.rb +89 -0
  90. data/lib/karafka/pro/processing/{strategies → consumer_groups/strategies}/aj/ftr_lrj_mom.rb +20 -15
  91. data/lib/karafka/pro/processing/consumer_groups/strategies/aj/ftr_lrj_mom_vp.rb +91 -0
  92. data/lib/karafka/pro/processing/{strategies → consumer_groups/strategies}/aj/ftr_mom.rb +20 -15
  93. data/lib/karafka/pro/processing/consumer_groups/strategies/aj/ftr_mom_vp.rb +80 -0
  94. data/lib/karafka/pro/processing/{strategies/mom/default.rb → consumer_groups/strategies/aj/lrj_mom.rb} +18 -22
  95. data/lib/karafka/pro/processing/consumer_groups/strategies/aj/lrj_mom_vp.rb +106 -0
  96. data/lib/karafka/pro/processing/consumer_groups/strategies/aj/mom.rb +58 -0
  97. data/lib/karafka/pro/processing/consumer_groups/strategies/aj/mom_vp.rb +74 -0
  98. data/lib/karafka/pro/processing/{strategies/lrj/vp.rb → consumer_groups/strategies/base.rb} +9 -14
  99. data/lib/karafka/pro/processing/consumer_groups/strategies/default.rb +421 -0
  100. data/lib/karafka/pro/processing/consumer_groups/strategies/dlq/default.rb +285 -0
  101. data/lib/karafka/pro/processing/{strategies/dlq/lrj.rb → consumer_groups/strategies/dlq/ftr.rb} +30 -29
  102. data/lib/karafka/pro/processing/consumer_groups/strategies/dlq/ftr_lrj.rb +95 -0
  103. data/lib/karafka/pro/processing/consumer_groups/strategies/dlq/ftr_lrj_mom.rb +97 -0
  104. data/lib/karafka/pro/processing/{executor.rb → consumer_groups/strategies/dlq/ftr_lrj_mom_vp.rb} +26 -15
  105. data/lib/karafka/pro/processing/consumer_groups/strategies/dlq/ftr_lrj_vp.rb +63 -0
  106. data/lib/karafka/pro/processing/consumer_groups/strategies/dlq/ftr_mom.rb +97 -0
  107. data/lib/karafka/pro/processing/consumer_groups/strategies/dlq/ftr_mom_vp.rb +63 -0
  108. data/lib/karafka/pro/{routing/features/patterns/patterns.rb → processing/consumer_groups/strategies/dlq/ftr_vp.rb} +22 -12
  109. data/lib/karafka/pro/processing/consumer_groups/strategies/dlq/lrj.rb +83 -0
  110. data/lib/karafka/pro/processing/consumer_groups/strategies/dlq/lrj_mom.rb +100 -0
  111. data/lib/karafka/pro/processing/{strategies → consumer_groups/strategies}/dlq/lrj_mom_vp.rb +18 -13
  112. data/lib/karafka/pro/processing/consumer_groups/strategies/dlq/lrj_vp.rb +61 -0
  113. data/lib/karafka/pro/processing/consumer_groups/strategies/dlq/mom.rb +96 -0
  114. data/lib/karafka/pro/processing/{strategies/lrj → consumer_groups/strategies/dlq}/mom_vp.rb +19 -15
  115. data/lib/karafka/pro/processing/consumer_groups/strategies/dlq/vp.rb +62 -0
  116. data/lib/karafka/pro/processing/consumer_groups/strategies/ftr/default.rb +146 -0
  117. data/lib/karafka/pro/processing/{strategies/mom/ftr.rb → consumer_groups/strategies/ftr/vp.rb} +20 -28
  118. data/lib/karafka/pro/processing/consumer_groups/strategies/lrj/default.rb +119 -0
  119. data/lib/karafka/pro/processing/consumer_groups/strategies/lrj/ftr.rb +94 -0
  120. data/lib/karafka/pro/processing/consumer_groups/strategies/lrj/ftr_mom.rb +92 -0
  121. data/lib/karafka/pro/processing/consumer_groups/strategies/lrj/ftr_mom_vp.rb +62 -0
  122. data/lib/karafka/pro/processing/consumer_groups/strategies/lrj/ftr_vp.rb +61 -0
  123. data/lib/karafka/pro/processing/consumer_groups/strategies/lrj/mom.rb +101 -0
  124. data/lib/karafka/pro/processing/consumer_groups/strategies/lrj/mom_vp.rb +60 -0
  125. data/lib/karafka/pro/processing/{strategies/mom → consumer_groups/strategies/lrj}/vp.rb +18 -12
  126. data/lib/karafka/pro/processing/{strategies/aj/mom_vp.rb → consumer_groups/strategies/mom/default.rb} +22 -23
  127. data/lib/karafka/pro/processing/{strategies/aj/ftr_mom_vp.rb → consumer_groups/strategies/mom/ftr.rb} +28 -28
  128. data/lib/karafka/pro/processing/{virtual_partitions/distributors/base.rb → consumer_groups/strategies/mom/ftr_vp.rb} +19 -14
  129. data/lib/karafka/pro/processing/{strategies/aj/mom.rb → consumer_groups/strategies/mom/vp.rb} +16 -12
  130. data/lib/karafka/pro/processing/consumer_groups/strategies/vp/default.rb +197 -0
  131. data/lib/karafka/pro/processing/consumer_groups/strategy_selector.rb +106 -0
  132. data/lib/karafka/pro/processing/consumer_groups/subscription_groups_coordinator.rb +73 -0
  133. data/lib/karafka/pro/processing/consumer_groups/virtual_partitions/distributors/balanced.rb +82 -0
  134. data/lib/karafka/pro/processing/consumer_groups/virtual_partitions/distributors/base.rb +59 -0
  135. data/lib/karafka/pro/processing/{strategies/dlq/ftr.rb → consumer_groups/virtual_partitions/distributors/consistent.rb} +18 -33
  136. data/lib/karafka/pro/processing/filters/base.rb +3 -61
  137. data/lib/karafka/pro/processing/partitioner.rb +2 -57
  138. data/lib/karafka/pro/processing/schedulers/base.rb +10 -6
  139. data/lib/karafka/pro/processing/schedulers/default.rb +6 -5
  140. data/lib/karafka/pro/recurring_tasks/executor.rb +1 -2
  141. data/lib/karafka/pro/routing/features/{active_job → consumer_groups/active_job}/builder.rb +20 -18
  142. data/lib/karafka/pro/routing/features/{inline_insights/config.rb → consumer_groups/active_job.rb} +5 -9
  143. data/lib/karafka/pro/routing/features/consumer_groups/adaptive_iterator/config.rb +53 -0
  144. data/lib/karafka/pro/routing/features/consumer_groups/adaptive_iterator/contracts/topic.rb +91 -0
  145. data/lib/karafka/pro/routing/features/consumer_groups/adaptive_iterator/topic.rb +90 -0
  146. data/lib/karafka/pro/routing/features/consumer_groups/adaptive_iterator.rb +50 -0
  147. data/lib/karafka/pro/routing/features/{patterns/contracts/consumer_group.rb → consumer_groups/dead_letter_queue/contracts/topic.rb} +25 -30
  148. data/lib/karafka/pro/routing/features/consumer_groups/dead_letter_queue/topic.rb +70 -0
  149. data/lib/karafka/pro/routing/features/consumer_groups/dead_letter_queue.rb +46 -0
  150. data/lib/karafka/pro/routing/features/{direct_assignments → consumer_groups/delaying}/config.rb +6 -4
  151. data/lib/karafka/pro/routing/features/{patterns/contracts/pattern.rb → consumer_groups/delaying/contracts/topic.rb} +13 -16
  152. data/lib/karafka/pro/routing/features/consumer_groups/delaying/topic.rb +85 -0
  153. data/lib/karafka/pro/routing/features/{adaptive_iterator/config.rb → consumer_groups/delaying.rb} +8 -11
  154. data/lib/karafka/pro/routing/features/consumer_groups/direct_assignments/config.rb +46 -0
  155. data/lib/karafka/pro/routing/features/consumer_groups/direct_assignments/contracts/consumer_group.rb +68 -0
  156. data/lib/karafka/pro/routing/features/consumer_groups/direct_assignments/contracts/topic.rb +125 -0
  157. data/lib/karafka/pro/routing/features/consumer_groups/direct_assignments/subscription_group.rb +97 -0
  158. data/lib/karafka/pro/routing/features/consumer_groups/direct_assignments/topic.rb +97 -0
  159. data/lib/karafka/pro/routing/features/consumer_groups/direct_assignments.rb +44 -0
  160. data/lib/karafka/pro/routing/features/consumer_groups/inline_insights/config.rb +51 -0
  161. data/lib/karafka/pro/routing/features/consumer_groups/inline_insights/contracts/topic.rb +58 -0
  162. data/lib/karafka/pro/routing/features/consumer_groups/inline_insights/topic.rb +80 -0
  163. data/lib/karafka/pro/routing/features/consumer_groups/inline_insights.rb +45 -0
  164. data/lib/karafka/pro/routing/features/consumer_groups/long_running_job/config.rb +47 -0
  165. data/lib/karafka/pro/routing/features/{multiplexing/patches/contracts/consumer_group.rb → consumer_groups/long_running_job/contracts/topic.rb} +13 -15
  166. data/lib/karafka/pro/routing/features/consumer_groups/long_running_job/topic.rb +72 -0
  167. data/lib/karafka/pro/routing/features/{long_running_job.rb → consumer_groups/long_running_job.rb} +6 -4
  168. data/lib/karafka/pro/routing/features/consumer_groups/multiplexing/config.rb +58 -0
  169. data/lib/karafka/pro/routing/features/consumer_groups/multiplexing/contracts/routing.rb +83 -0
  170. data/lib/karafka/pro/routing/features/consumer_groups/multiplexing/contracts/topic.rb +148 -0
  171. data/lib/karafka/pro/routing/features/{delaying/contracts/topic.rb → consumer_groups/multiplexing/patches/contracts/consumer_group.rb} +19 -14
  172. data/lib/karafka/pro/routing/features/{multiplexing/subscription_group.rb → consumer_groups/multiplexing/proxy.rb} +17 -23
  173. data/lib/karafka/pro/routing/features/consumer_groups/multiplexing/subscription_group.rb +68 -0
  174. data/lib/karafka/pro/routing/features/{multiplexing → consumer_groups/multiplexing}/subscription_groups_builder.rb +16 -14
  175. data/lib/karafka/pro/routing/features/consumer_groups/multiplexing.rb +85 -0
  176. data/lib/karafka/pro/routing/features/consumer_groups/non_blocking_job/topic.rb +51 -0
  177. data/lib/karafka/pro/routing/features/{non_blocking_job.rb → consumer_groups/non_blocking_job.rb} +15 -13
  178. data/lib/karafka/pro/routing/features/consumer_groups/offset_metadata/config.rb +52 -0
  179. data/lib/karafka/pro/routing/features/consumer_groups/offset_metadata/contracts/topic.rb +59 -0
  180. data/lib/karafka/pro/routing/features/consumer_groups/offset_metadata/topic.rb +93 -0
  181. data/lib/karafka/pro/routing/features/{offset_metadata.rb → consumer_groups/offset_metadata.rb} +16 -14
  182. data/lib/karafka/pro/routing/features/consumer_groups/parallel_segments/builder.rb +74 -0
  183. data/lib/karafka/pro/routing/features/{multiplexing → consumer_groups/parallel_segments}/config.rb +13 -15
  184. data/lib/karafka/pro/routing/features/consumer_groups/parallel_segments/consumer_group.rb +110 -0
  185. data/lib/karafka/pro/routing/features/consumer_groups/parallel_segments/contracts/consumer_group.rb +74 -0
  186. data/lib/karafka/pro/routing/features/{parallel_segments → consumer_groups/parallel_segments}/topic.rb +24 -22
  187. data/lib/karafka/pro/routing/features/consumer_groups/parallel_segments.rb +51 -0
  188. data/lib/karafka/pro/routing/features/{patterns → consumer_groups/patterns}/builder.rb +15 -13
  189. data/lib/karafka/pro/routing/features/{offset_metadata/contracts/topic.rb → consumer_groups/patterns/config.rb} +28 -13
  190. data/lib/karafka/pro/routing/features/consumer_groups/patterns/consumer_group.rb +91 -0
  191. data/lib/karafka/pro/routing/features/consumer_groups/patterns/contracts/consumer_group.rb +83 -0
  192. data/lib/karafka/pro/routing/features/{parallel_segments.rb → consumer_groups/patterns/contracts/pattern.rb} +24 -10
  193. data/lib/karafka/pro/routing/features/consumer_groups/patterns/contracts/topic.rb +58 -0
  194. data/lib/karafka/pro/routing/features/consumer_groups/patterns/detector.rb +98 -0
  195. data/lib/karafka/pro/routing/features/consumer_groups/patterns/pattern.rb +114 -0
  196. data/lib/karafka/pro/routing/features/{recurring_tasks/contracts/topic.rb → consumer_groups/patterns/patterns.rb} +12 -13
  197. data/lib/karafka/pro/routing/features/consumer_groups/patterns/topic.rb +78 -0
  198. data/lib/karafka/pro/routing/features/consumer_groups/patterns/topics.rb +72 -0
  199. data/lib/karafka/pro/routing/features/consumer_groups/patterns.rb +52 -0
  200. data/lib/karafka/pro/routing/features/consumer_groups/periodic_job/config.rb +56 -0
  201. data/lib/karafka/pro/routing/features/{direct_assignments/contracts/consumer_group.rb → consumer_groups/periodic_job/contracts/topic.rb} +17 -22
  202. data/lib/karafka/pro/routing/features/consumer_groups/periodic_job/topic.rb +122 -0
  203. data/lib/karafka/pro/routing/features/consumer_groups/periodic_job.rb +46 -0
  204. data/lib/karafka/pro/routing/features/consumer_groups/recurring_tasks/builder.rb +150 -0
  205. data/lib/karafka/pro/routing/features/{swarm → consumer_groups/recurring_tasks}/config.rb +7 -8
  206. data/lib/karafka/pro/routing/features/{inline_insights → consumer_groups/recurring_tasks}/contracts/topic.rb +14 -13
  207. data/lib/karafka/pro/routing/features/{scheduled_messages → consumer_groups/recurring_tasks}/proxy.rb +6 -4
  208. data/lib/karafka/pro/routing/features/consumer_groups/recurring_tasks/topic.rb +72 -0
  209. data/lib/karafka/pro/routing/features/consumer_groups/recurring_tasks.rb +44 -0
  210. data/lib/karafka/pro/routing/features/consumer_groups/scheduled_messages/builder.rb +154 -0
  211. data/lib/karafka/pro/routing/features/consumer_groups/scheduled_messages/config.rb +47 -0
  212. data/lib/karafka/pro/routing/features/{long_running_job → consumer_groups/scheduled_messages}/contracts/topic.rb +14 -12
  213. data/lib/karafka/pro/routing/features/{delaying/config.rb → consumer_groups/scheduled_messages/proxy.rb} +6 -4
  214. data/lib/karafka/pro/routing/features/consumer_groups/scheduled_messages/topic.rb +72 -0
  215. data/lib/karafka/pro/routing/features/{recurring_tasks/proxy.rb → consumer_groups/scheduled_messages.rb} +3 -4
  216. data/lib/karafka/pro/routing/features/{non_blocking_job/topic.rb → consumer_groups/swarm/config.rb} +9 -8
  217. data/lib/karafka/pro/routing/features/consumer_groups/swarm/contracts/routing.rb +94 -0
  218. data/lib/karafka/pro/routing/features/consumer_groups/swarm/contracts/topic.rb +95 -0
  219. data/lib/karafka/pro/routing/features/consumer_groups/swarm/topic.rb +105 -0
  220. data/lib/karafka/pro/routing/features/consumer_groups/swarm.rb +58 -0
  221. data/lib/karafka/pro/routing/features/consumer_groups/virtual_partitions/config.rb +69 -0
  222. data/lib/karafka/pro/routing/features/{parallel_segments/contracts/consumer_group.rb → consumer_groups/virtual_partitions/contracts/topic.rb} +21 -18
  223. data/lib/karafka/pro/routing/features/consumer_groups/virtual_partitions/topic.rb +101 -0
  224. data/lib/karafka/pro/routing/features/consumer_groups/virtual_partitions.rb +46 -0
  225. data/lib/karafka/pro/routing/features/{scheduled_messages.rb → consumer_groups.rb} +3 -2
  226. data/lib/karafka/pro/routing/features/expiring/topic.rb +4 -4
  227. data/lib/karafka/pro/routing/features/filtering/topic.rb +3 -3
  228. data/lib/karafka/pro/routing/features/pausing/topic.rb +3 -3
  229. data/lib/karafka/pro/routing/features/throttling/topic.rb +4 -4
  230. data/lib/karafka/pro/setup/defaults_injector.rb +70 -0
  231. data/lib/karafka/pro/swarm/liveness_listener.rb +22 -10
  232. data/lib/karafka/processing/consumer_groups/coordinator.rb +221 -0
  233. data/lib/karafka/processing/consumer_groups/coordinators_buffer.rb +69 -0
  234. data/lib/karafka/processing/consumer_groups/executor.rb +220 -0
  235. data/lib/karafka/processing/consumer_groups/executors_buffer.rb +94 -0
  236. data/lib/karafka/processing/consumer_groups/expansions_selector.rb +26 -0
  237. data/lib/karafka/processing/consumer_groups/inline_insights/consumer.rb +47 -0
  238. data/lib/karafka/processing/consumer_groups/inline_insights/listener.rb +23 -0
  239. data/lib/karafka/processing/consumer_groups/inline_insights/tracker.rb +132 -0
  240. data/lib/karafka/processing/consumer_groups/jobs/consume.rb +52 -0
  241. data/lib/karafka/processing/consumer_groups/jobs/eofed.rb +34 -0
  242. data/lib/karafka/processing/consumer_groups/jobs/idle.rb +33 -0
  243. data/lib/karafka/processing/consumer_groups/jobs/revoked.rb +34 -0
  244. data/lib/karafka/processing/consumer_groups/jobs/shutdown.rb +32 -0
  245. data/lib/karafka/processing/consumer_groups/jobs_builder.rb +36 -0
  246. data/lib/karafka/processing/consumer_groups/partitioner.rb +28 -0
  247. data/lib/karafka/processing/consumer_groups/strategies/aj_dlq_mom.rb +48 -0
  248. data/lib/karafka/processing/consumer_groups/strategies/aj_mom.rb +25 -0
  249. data/lib/karafka/processing/consumer_groups/strategies/base.rb +65 -0
  250. data/lib/karafka/processing/consumer_groups/strategies/default.rb +218 -0
  251. data/lib/karafka/processing/consumer_groups/strategies/dlq.rb +157 -0
  252. data/lib/karafka/processing/consumer_groups/strategies/dlq_mom.rb +72 -0
  253. data/lib/karafka/processing/consumer_groups/strategies/mom.rb +33 -0
  254. data/lib/karafka/processing/consumer_groups/strategy_selector.rb +53 -0
  255. data/lib/karafka/processing/coordinator.rb +4 -211
  256. data/lib/karafka/processing/coordinators_buffer.rb +4 -59
  257. data/lib/karafka/processing/jobs_queue.rb +12 -4
  258. data/lib/karafka/processing/partitioner.rb +4 -18
  259. data/lib/karafka/processing/schedulers/default.rb +2 -1
  260. data/lib/karafka/processing/strategy_selector.rb +4 -42
  261. data/lib/karafka/processing/worker.rb +8 -4
  262. data/lib/karafka/processing/workers_pool.rb +158 -0
  263. data/lib/karafka/routing/builder.rb +12 -12
  264. data/lib/karafka/routing/contracts/routing.rb +3 -4
  265. data/lib/karafka/routing/features/base/expander.rb +5 -5
  266. data/lib/karafka/routing/features/consumer_groups/active_job/builder.rb +35 -0
  267. data/lib/karafka/routing/features/consumer_groups/active_job/config.rb +17 -0
  268. data/lib/karafka/routing/features/consumer_groups/active_job/contracts/topic.rb +44 -0
  269. data/lib/karafka/routing/features/consumer_groups/active_job/proxy.rb +16 -0
  270. data/lib/karafka/routing/features/consumer_groups/active_job/topic.rb +50 -0
  271. data/lib/karafka/routing/features/consumer_groups/active_job.rb +15 -0
  272. data/lib/karafka/routing/features/consumer_groups/dead_letter_queue/config.rb +39 -0
  273. data/lib/karafka/routing/features/consumer_groups/dead_letter_queue/contracts/topic.rb +58 -0
  274. data/lib/karafka/routing/features/consumer_groups/dead_letter_queue/topic.rb +76 -0
  275. data/lib/karafka/routing/features/consumer_groups/dead_letter_queue.rb +18 -0
  276. data/lib/karafka/routing/features/consumer_groups/eofed/config.rb +17 -0
  277. data/lib/karafka/routing/features/consumer_groups/eofed/contracts/topic.rb +39 -0
  278. data/lib/karafka/routing/features/consumer_groups/eofed/topic.rb +42 -0
  279. data/lib/karafka/routing/features/consumer_groups/eofed.rb +16 -0
  280. data/lib/karafka/routing/features/consumer_groups/inline_insights/config.rb +17 -0
  281. data/lib/karafka/routing/features/consumer_groups/inline_insights/contracts/topic.rb +27 -0
  282. data/lib/karafka/routing/features/consumer_groups/inline_insights/topic.rb +42 -0
  283. data/lib/karafka/routing/features/consumer_groups/inline_insights.rb +42 -0
  284. data/lib/karafka/routing/features/consumer_groups/manual_offset_management/config.rb +17 -0
  285. data/lib/karafka/routing/features/consumer_groups/manual_offset_management/contracts/topic.rb +27 -0
  286. data/lib/karafka/routing/features/consumer_groups/manual_offset_management/topic.rb +46 -0
  287. data/lib/karafka/routing/features/consumer_groups/manual_offset_management.rb +20 -0
  288. data/lib/karafka/routing/features/consumer_groups.rb +12 -0
  289. data/lib/karafka/routing/features/declaratives/contracts/topic.rb +4 -19
  290. data/lib/karafka/routing/features/declaratives/topic.rb +30 -14
  291. data/lib/karafka/routing/features/deserializers/topic.rb +3 -3
  292. data/lib/karafka/routing/router.rb +2 -2
  293. data/lib/karafka/routing/subscription_group.rb +18 -9
  294. data/lib/karafka/routing/topic.rb +25 -11
  295. data/lib/karafka/runner.rb +17 -17
  296. data/lib/karafka/server.rb +28 -6
  297. data/lib/karafka/setup/attributes_map.rb +2 -0
  298. data/lib/karafka/setup/config.rb +64 -15
  299. data/lib/karafka/setup/config_proxy.rb +1 -2
  300. data/lib/karafka/setup/contracts/config.rb +28 -8
  301. data/lib/karafka/setup/defaults_injector.rb +10 -0
  302. data/lib/karafka/status.rb +1 -2
  303. data/lib/karafka/swarm/liveness_listener.rb +7 -0
  304. data/lib/karafka/swarm/manager.rb +7 -7
  305. data/lib/karafka/swarm/node.rb +8 -0
  306. data/lib/karafka/swarm/supervisor.rb +9 -1
  307. data/lib/karafka/templates/karafka.rb.erb +11 -5
  308. data/lib/karafka/version.rb +1 -1
  309. metadata +237 -224
  310. data/lib/karafka/connection/rebalance_manager.rb +0 -116
  311. data/lib/karafka/instrumentation/callbacks/error.rb +0 -52
  312. data/lib/karafka/instrumentation/callbacks/rebalance.rb +0 -84
  313. data/lib/karafka/instrumentation/callbacks/statistics.rb +0 -55
  314. data/lib/karafka/pro/processing/adaptive_iterator/consumer.rb +0 -79
  315. data/lib/karafka/pro/processing/adaptive_iterator/tracker.rb +0 -92
  316. data/lib/karafka/pro/processing/collapser.rb +0 -79
  317. data/lib/karafka/pro/processing/coordinator.rb +0 -197
  318. data/lib/karafka/pro/processing/coordinators/errors_tracker.rb +0 -119
  319. data/lib/karafka/pro/processing/coordinators/filters_applier.rb +0 -152
  320. data/lib/karafka/pro/processing/coordinators/virtual_offset_manager.rb +0 -207
  321. data/lib/karafka/pro/processing/expansions_selector.rb +0 -52
  322. data/lib/karafka/pro/processing/filters/delayer.rb +0 -87
  323. data/lib/karafka/pro/processing/filters/inline_insights_delayer.rb +0 -95
  324. data/lib/karafka/pro/processing/filters/throttler.rb +0 -101
  325. data/lib/karafka/pro/processing/filters/virtual_limiter.rb +0 -74
  326. data/lib/karafka/pro/processing/jobs/eofed_non_blocking.rb +0 -51
  327. data/lib/karafka/pro/processing/jobs_builder.rb +0 -90
  328. data/lib/karafka/pro/processing/offset_metadata/consumer.rb +0 -61
  329. data/lib/karafka/pro/processing/offset_metadata/fetcher.rb +0 -149
  330. data/lib/karafka/pro/processing/offset_metadata/listener.rb +0 -63
  331. data/lib/karafka/pro/processing/parallel_segments/filters/base.rb +0 -98
  332. data/lib/karafka/pro/processing/parallel_segments/filters/default.rb +0 -110
  333. data/lib/karafka/pro/processing/parallel_segments/filters/mom.rb +0 -91
  334. data/lib/karafka/pro/processing/periodic_job/consumer.rb +0 -85
  335. data/lib/karafka/pro/processing/piping/consumer.rb +0 -149
  336. data/lib/karafka/pro/processing/strategies/aj/dlq_ftr_lrj_mom_vp.rb +0 -94
  337. data/lib/karafka/pro/processing/strategies/aj/dlq_ftr_mom.rb +0 -87
  338. data/lib/karafka/pro/processing/strategies/aj/dlq_ftr_mom_vp.rb +0 -85
  339. data/lib/karafka/pro/processing/strategies/aj/dlq_lrj_mom.rb +0 -81
  340. data/lib/karafka/pro/processing/strategies/aj/dlq_lrj_mom_vp.rb +0 -85
  341. data/lib/karafka/pro/processing/strategies/aj/dlq_mom.rb +0 -79
  342. data/lib/karafka/pro/processing/strategies/aj/dlq_mom_vp.rb +0 -84
  343. data/lib/karafka/pro/processing/strategies/aj/ftr_lrj_mom_vp.rb +0 -86
  344. data/lib/karafka/pro/processing/strategies/aj/lrj_mom.rb +0 -54
  345. data/lib/karafka/pro/processing/strategies/aj/lrj_mom_vp.rb +0 -101
  346. data/lib/karafka/pro/processing/strategies/base.rb +0 -43
  347. data/lib/karafka/pro/processing/strategies/default.rb +0 -416
  348. data/lib/karafka/pro/processing/strategies/dlq/default.rb +0 -280
  349. data/lib/karafka/pro/processing/strategies/dlq/ftr_lrj.rb +0 -90
  350. data/lib/karafka/pro/processing/strategies/dlq/ftr_lrj_mom.rb +0 -92
  351. data/lib/karafka/pro/processing/strategies/dlq/ftr_lrj_mom_vp.rb +0 -60
  352. data/lib/karafka/pro/processing/strategies/dlq/ftr_lrj_vp.rb +0 -58
  353. data/lib/karafka/pro/processing/strategies/dlq/ftr_mom.rb +0 -92
  354. data/lib/karafka/pro/processing/strategies/dlq/ftr_mom_vp.rb +0 -58
  355. data/lib/karafka/pro/processing/strategies/dlq/ftr_vp.rb +0 -57
  356. data/lib/karafka/pro/processing/strategies/dlq/lrj_mom.rb +0 -95
  357. data/lib/karafka/pro/processing/strategies/dlq/lrj_vp.rb +0 -56
  358. data/lib/karafka/pro/processing/strategies/dlq/mom.rb +0 -91
  359. data/lib/karafka/pro/processing/strategies/dlq/mom_vp.rb +0 -54
  360. data/lib/karafka/pro/processing/strategies/dlq/vp.rb +0 -57
  361. data/lib/karafka/pro/processing/strategies/ftr/default.rb +0 -141
  362. data/lib/karafka/pro/processing/strategies/ftr/vp.rb +0 -57
  363. data/lib/karafka/pro/processing/strategies/lrj/default.rb +0 -114
  364. data/lib/karafka/pro/processing/strategies/lrj/ftr.rb +0 -89
  365. data/lib/karafka/pro/processing/strategies/lrj/ftr_mom.rb +0 -87
  366. data/lib/karafka/pro/processing/strategies/lrj/ftr_mom_vp.rb +0 -57
  367. data/lib/karafka/pro/processing/strategies/lrj/ftr_vp.rb +0 -56
  368. data/lib/karafka/pro/processing/strategies/lrj/mom.rb +0 -96
  369. data/lib/karafka/pro/processing/strategies/mom/ftr_vp.rb +0 -54
  370. data/lib/karafka/pro/processing/strategies/vp/default.rb +0 -192
  371. data/lib/karafka/pro/processing/strategies.rb +0 -39
  372. data/lib/karafka/pro/processing/strategy_selector.rb +0 -102
  373. data/lib/karafka/pro/processing/subscription_groups_coordinator.rb +0 -68
  374. data/lib/karafka/pro/processing/virtual_partitions/distributors/balanced.rb +0 -77
  375. data/lib/karafka/pro/routing/features/active_job.rb +0 -43
  376. data/lib/karafka/pro/routing/features/adaptive_iterator/contracts/topic.rb +0 -89
  377. data/lib/karafka/pro/routing/features/adaptive_iterator/topic.rb +0 -88
  378. data/lib/karafka/pro/routing/features/adaptive_iterator.rb +0 -48
  379. data/lib/karafka/pro/routing/features/dead_letter_queue/contracts/topic.rb +0 -74
  380. data/lib/karafka/pro/routing/features/dead_letter_queue/topic.rb +0 -68
  381. data/lib/karafka/pro/routing/features/dead_letter_queue.rb +0 -44
  382. data/lib/karafka/pro/routing/features/delaying/topic.rb +0 -83
  383. data/lib/karafka/pro/routing/features/delaying.rb +0 -46
  384. data/lib/karafka/pro/routing/features/direct_assignments/contracts/topic.rb +0 -123
  385. data/lib/karafka/pro/routing/features/direct_assignments/subscription_group.rb +0 -95
  386. data/lib/karafka/pro/routing/features/direct_assignments/topic.rb +0 -95
  387. data/lib/karafka/pro/routing/features/direct_assignments.rb +0 -42
  388. data/lib/karafka/pro/routing/features/inline_insights/topic.rb +0 -78
  389. data/lib/karafka/pro/routing/features/inline_insights.rb +0 -43
  390. data/lib/karafka/pro/routing/features/long_running_job/config.rb +0 -45
  391. data/lib/karafka/pro/routing/features/long_running_job/topic.rb +0 -70
  392. data/lib/karafka/pro/routing/features/multiplexing/contracts/routing.rb +0 -81
  393. data/lib/karafka/pro/routing/features/multiplexing/contracts/topic.rb +0 -146
  394. data/lib/karafka/pro/routing/features/multiplexing/proxy.rb +0 -58
  395. data/lib/karafka/pro/routing/features/multiplexing.rb +0 -83
  396. data/lib/karafka/pro/routing/features/offset_metadata/config.rb +0 -50
  397. data/lib/karafka/pro/routing/features/offset_metadata/topic.rb +0 -91
  398. data/lib/karafka/pro/routing/features/parallel_segments/builder.rb +0 -72
  399. data/lib/karafka/pro/routing/features/parallel_segments/config.rb +0 -52
  400. data/lib/karafka/pro/routing/features/parallel_segments/consumer_group.rb +0 -108
  401. data/lib/karafka/pro/routing/features/patterns/config.rb +0 -71
  402. data/lib/karafka/pro/routing/features/patterns/consumer_group.rb +0 -89
  403. data/lib/karafka/pro/routing/features/patterns/contracts/topic.rb +0 -56
  404. data/lib/karafka/pro/routing/features/patterns/detector.rb +0 -96
  405. data/lib/karafka/pro/routing/features/patterns/pattern.rb +0 -112
  406. data/lib/karafka/pro/routing/features/patterns/topic.rb +0 -76
  407. data/lib/karafka/pro/routing/features/patterns/topics.rb +0 -70
  408. data/lib/karafka/pro/routing/features/patterns.rb +0 -50
  409. data/lib/karafka/pro/routing/features/periodic_job/config.rb +0 -54
  410. data/lib/karafka/pro/routing/features/periodic_job/contracts/topic.rb +0 -59
  411. data/lib/karafka/pro/routing/features/periodic_job/topic.rb +0 -120
  412. data/lib/karafka/pro/routing/features/periodic_job.rb +0 -44
  413. data/lib/karafka/pro/routing/features/recurring_tasks/builder.rb +0 -148
  414. data/lib/karafka/pro/routing/features/recurring_tasks/config.rb +0 -45
  415. data/lib/karafka/pro/routing/features/recurring_tasks/topic.rb +0 -70
  416. data/lib/karafka/pro/routing/features/recurring_tasks.rb +0 -42
  417. data/lib/karafka/pro/routing/features/scheduled_messages/builder.rb +0 -152
  418. data/lib/karafka/pro/routing/features/scheduled_messages/config.rb +0 -45
  419. data/lib/karafka/pro/routing/features/scheduled_messages/contracts/topic.rb +0 -55
  420. data/lib/karafka/pro/routing/features/scheduled_messages/topic.rb +0 -70
  421. data/lib/karafka/pro/routing/features/swarm/contracts/routing.rb +0 -92
  422. data/lib/karafka/pro/routing/features/swarm/contracts/topic.rb +0 -93
  423. data/lib/karafka/pro/routing/features/swarm/topic.rb +0 -103
  424. data/lib/karafka/pro/routing/features/swarm.rb +0 -56
  425. data/lib/karafka/pro/routing/features/virtual_partitions/config.rb +0 -67
  426. data/lib/karafka/pro/routing/features/virtual_partitions/contracts/topic.rb +0 -73
  427. data/lib/karafka/pro/routing/features/virtual_partitions/topic.rb +0 -99
  428. data/lib/karafka/pro/routing/features/virtual_partitions.rb +0 -44
  429. data/lib/karafka/processing/executor.rb +0 -216
  430. data/lib/karafka/processing/executors_buffer.rb +0 -90
  431. data/lib/karafka/processing/expansions_selector.rb +0 -22
  432. data/lib/karafka/processing/inline_insights/consumer.rb +0 -43
  433. data/lib/karafka/processing/inline_insights/listener.rb +0 -19
  434. data/lib/karafka/processing/inline_insights/tracker.rb +0 -129
  435. data/lib/karafka/processing/jobs/consume.rb +0 -47
  436. data/lib/karafka/processing/jobs/eofed.rb +0 -29
  437. data/lib/karafka/processing/jobs/idle.rb +0 -31
  438. data/lib/karafka/processing/jobs/revoked.rb +0 -29
  439. data/lib/karafka/processing/jobs/shutdown.rb +0 -30
  440. data/lib/karafka/processing/jobs_builder.rb +0 -34
  441. data/lib/karafka/processing/strategies/aj_dlq_mom.rb +0 -44
  442. data/lib/karafka/processing/strategies/aj_mom.rb +0 -21
  443. data/lib/karafka/processing/strategies/base.rb +0 -61
  444. data/lib/karafka/processing/strategies/default.rb +0 -214
  445. data/lib/karafka/processing/strategies/dlq.rb +0 -153
  446. data/lib/karafka/processing/strategies/dlq_mom.rb +0 -68
  447. data/lib/karafka/processing/strategies/mom.rb +0 -29
  448. data/lib/karafka/processing/workers_batch.rb +0 -29
  449. data/lib/karafka/routing/features/active_job/builder.rb +0 -33
  450. data/lib/karafka/routing/features/active_job/config.rb +0 -15
  451. data/lib/karafka/routing/features/active_job/contracts/topic.rb +0 -42
  452. data/lib/karafka/routing/features/active_job/proxy.rb +0 -14
  453. data/lib/karafka/routing/features/active_job/topic.rb +0 -48
  454. data/lib/karafka/routing/features/active_job.rb +0 -13
  455. data/lib/karafka/routing/features/dead_letter_queue/config.rb +0 -37
  456. data/lib/karafka/routing/features/dead_letter_queue/contracts/topic.rb +0 -56
  457. data/lib/karafka/routing/features/dead_letter_queue/topic.rb +0 -74
  458. data/lib/karafka/routing/features/dead_letter_queue.rb +0 -16
  459. data/lib/karafka/routing/features/declaratives/config.rb +0 -18
  460. data/lib/karafka/routing/features/eofed/config.rb +0 -15
  461. data/lib/karafka/routing/features/eofed/contracts/topic.rb +0 -37
  462. data/lib/karafka/routing/features/eofed/topic.rb +0 -40
  463. data/lib/karafka/routing/features/eofed.rb +0 -14
  464. data/lib/karafka/routing/features/inline_insights/config.rb +0 -15
  465. data/lib/karafka/routing/features/inline_insights/contracts/topic.rb +0 -25
  466. data/lib/karafka/routing/features/inline_insights/topic.rb +0 -40
  467. data/lib/karafka/routing/features/inline_insights.rb +0 -40
  468. data/lib/karafka/routing/features/manual_offset_management/config.rb +0 -15
  469. data/lib/karafka/routing/features/manual_offset_management/contracts/topic.rb +0 -25
  470. data/lib/karafka/routing/features/manual_offset_management/topic.rb +0 -44
  471. data/lib/karafka/routing/features/manual_offset_management.rb +0 -18
@@ -1,59 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Karafka Pro - Source Available Commercial Software
4
- # Copyright (c) 2017-present Maciej Mensfeld. All rights reserved.
5
- #
6
- # This software is NOT open source. It is source-available commercial software
7
- # requiring a paid license for use. It is NOT covered by LGPL.
8
- #
9
- # The author retains all right, title, and interest in this software,
10
- # including all copyrights, patents, and other intellectual property rights.
11
- # No patent rights are granted under this license.
12
- #
13
- # PROHIBITED:
14
- # - Use without a valid commercial license
15
- # - Redistribution, modification, or derivative works without authorization
16
- # - Reverse engineering, decompilation, or disassembly of this software
17
- # - Use as training data for AI/ML models or inclusion in datasets
18
- # - Scraping, crawling, or automated collection for any purpose
19
- #
20
- # PERMITTED:
21
- # - Reading, referencing, and linking for personal or commercial use
22
- # - Runtime retrieval by AI assistants, coding agents, and RAG systems
23
- # for the purpose of providing contextual help to Karafka users
24
- #
25
- # Receipt, viewing, or possession of this software does not convey or
26
- # imply any license or right beyond those expressly stated above.
27
- #
28
- # License: https://karafka.io/docs/Pro-License-Comm/
29
- # Contact: contact@karafka.io
30
-
31
- module Karafka
32
- module Pro
33
- module Routing
34
- module Features
35
- class PeriodicJob < Base
36
- # Namespace for periodics messages contracts
37
- module Contracts
38
- # Contract to validate configuration of the periodics feature
39
- class Topic < Karafka::Contracts::Base
40
- configure do |config|
41
- config.error_messages = YAML.safe_load_file(
42
- File.join(Karafka.gem_root, "config", "locales", "pro_errors.yml")
43
- ).fetch("en").fetch("validations").fetch("routing").fetch("topic")
44
- end
45
-
46
- nested(:periodic_job) do
47
- required(:active) { |val| [true, false].include?(val) }
48
- required(:interval) { |val| val.is_a?(Integer) && val >= 100 }
49
- required(:during_pause) { |val| [true, false].include?(val) }
50
- required(:during_retry) { |val| [true, false].include?(val) }
51
- required(:materialized) { |val| [true, false].include?(val) }
52
- end
53
- end
54
- end
55
- end
56
- end
57
- end
58
- end
59
- end
@@ -1,120 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Karafka Pro - Source Available Commercial Software
4
- # Copyright (c) 2017-present Maciej Mensfeld. All rights reserved.
5
- #
6
- # This software is NOT open source. It is source-available commercial software
7
- # requiring a paid license for use. It is NOT covered by LGPL.
8
- #
9
- # The author retains all right, title, and interest in this software,
10
- # including all copyrights, patents, and other intellectual property rights.
11
- # No patent rights are granted under this license.
12
- #
13
- # PROHIBITED:
14
- # - Use without a valid commercial license
15
- # - Redistribution, modification, or derivative works without authorization
16
- # - Reverse engineering, decompilation, or disassembly of this software
17
- # - Use as training data for AI/ML models or inclusion in datasets
18
- # - Scraping, crawling, or automated collection for any purpose
19
- #
20
- # PERMITTED:
21
- # - Reading, referencing, and linking for personal or commercial use
22
- # - Runtime retrieval by AI assistants, coding agents, and RAG systems
23
- # for the purpose of providing contextual help to Karafka users
24
- #
25
- # Receipt, viewing, or possession of this software does not convey or
26
- # imply any license or right beyond those expressly stated above.
27
- #
28
- # License: https://karafka.io/docs/Pro-License-Comm/
29
- # Contact: contact@karafka.io
30
-
31
- module Karafka
32
- module Pro
33
- module Routing
34
- module Features
35
- class PeriodicJob < Base
36
- # Periodic topic action flows extensions
37
- module Topic
38
- # This method calls the parent class initializer and then sets up the
39
- # extra instance variable to nil. The explicit initialization
40
- # to nil is included as an optimization for Ruby's object shapes system,
41
- # which improves memory layout and access performance.
42
- def initialize(...)
43
- super
44
- @periodic_job = nil
45
- end
46
-
47
- # Defines topic as periodic. Periodic topics consumers will invoke `#tick` with each
48
- # poll where messages were not received.
49
- # @param active [Boolean] should ticking happen for this topic assignments.
50
- # @param interval [Integer] minimum interval to run periodic jobs on given topic.
51
- # @param during_pause [Boolean, nil] Should periodic jobs run when partition is paused.
52
- # It is set to `nil` by default allowing for detection when this value is not
53
- # configured but should be built dynamically based on LRJ status.
54
- # @param during_retry [Boolean, nil] Should we run when there was an error and we are
55
- # in a retry flow. Please note that for this to work, `during_pause` also needs to be
56
- # set to true as errors retry happens after pause.
57
- def periodic_job(
58
- active = false,
59
- interval: nil,
60
- during_pause: nil,
61
- during_retry: nil
62
- )
63
- @periodic_job ||= begin
64
- # Set to active if any of the values was configured
65
- active = true unless interval.nil?
66
- active = true unless during_pause.nil?
67
- active = true unless during_retry.nil?
68
- # Default is not to retry during retry flow
69
- during_retry = false if during_retry.nil?
70
-
71
- # If no interval, use default
72
- interval ||= Karafka::App.config.internal.tick_interval
73
-
74
- Config.new(
75
- active: active,
76
- interval: interval,
77
- during_pause: during_pause,
78
- during_retry: during_retry,
79
- # This is internal setting for state management, not part of the configuration
80
- # Do not overwrite.
81
- # If `during_pause` is explicit, we do not select it based on LRJ setup and we
82
- # consider if fully ready out of the box
83
- materialized: !during_pause.nil?
84
- )
85
- end
86
-
87
- return @periodic_job if @periodic_job.materialized?
88
- return @periodic_job unless @long_running_job
89
-
90
- # If not configured in any way, we want not to process during pause for LRJ.
91
- # LRJ pauses by default when processing and during this time we do not want to
92
- # tick at all. This prevents us from running periodic jobs while LRJ jobs are
93
- # running. This of course has a side effect of not running when paused for any
94
- # other reason but it is a compromise in the default settings
95
- @periodic_job.during_pause = !long_running_job?
96
- @periodic_job.materialized = true
97
-
98
- @periodic_job
99
- end
100
-
101
- alias_method :periodic, :periodic_job
102
-
103
- # @return [Boolean] is periodics active
104
- def periodic_job?
105
- periodic_job.active?
106
- end
107
-
108
- # @return [Hash] topic with all its native configuration options plus periodics flows
109
- # settings
110
- def to_h
111
- super.merge(
112
- periodic_job: periodic_job.to_h
113
- ).freeze
114
- end
115
- end
116
- end
117
- end
118
- end
119
- end
120
- end
@@ -1,44 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Karafka Pro - Source Available Commercial Software
4
- # Copyright (c) 2017-present Maciej Mensfeld. All rights reserved.
5
- #
6
- # This software is NOT open source. It is source-available commercial software
7
- # requiring a paid license for use. It is NOT covered by LGPL.
8
- #
9
- # The author retains all right, title, and interest in this software,
10
- # including all copyrights, patents, and other intellectual property rights.
11
- # No patent rights are granted under this license.
12
- #
13
- # PROHIBITED:
14
- # - Use without a valid commercial license
15
- # - Redistribution, modification, or derivative works without authorization
16
- # - Reverse engineering, decompilation, or disassembly of this software
17
- # - Use as training data for AI/ML models or inclusion in datasets
18
- # - Scraping, crawling, or automated collection for any purpose
19
- #
20
- # PERMITTED:
21
- # - Reading, referencing, and linking for personal or commercial use
22
- # - Runtime retrieval by AI assistants, coding agents, and RAG systems
23
- # for the purpose of providing contextual help to Karafka users
24
- #
25
- # Receipt, viewing, or possession of this software does not convey or
26
- # imply any license or right beyond those expressly stated above.
27
- #
28
- # License: https://karafka.io/docs/Pro-License-Comm/
29
- # Contact: contact@karafka.io
30
-
31
- module Karafka
32
- module Pro
33
- module Routing
34
- module Features
35
- # Feature allowing to run consumer operations even when no data is present on periodic
36
- # interval.
37
- # This allows for advanced window-based operations regardless of income of new data and
38
- # other advanced cases where the consumer is needed even when no data is coming
39
- class PeriodicJob < Base
40
- end
41
- end
42
- end
43
- end
44
- end
@@ -1,148 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Karafka Pro - Source Available Commercial Software
4
- # Copyright (c) 2017-present Maciej Mensfeld. All rights reserved.
5
- #
6
- # This software is NOT open source. It is source-available commercial software
7
- # requiring a paid license for use. It is NOT covered by LGPL.
8
- #
9
- # The author retains all right, title, and interest in this software,
10
- # including all copyrights, patents, and other intellectual property rights.
11
- # No patent rights are granted under this license.
12
- #
13
- # PROHIBITED:
14
- # - Use without a valid commercial license
15
- # - Redistribution, modification, or derivative works without authorization
16
- # - Reverse engineering, decompilation, or disassembly of this software
17
- # - Use as training data for AI/ML models or inclusion in datasets
18
- # - Scraping, crawling, or automated collection for any purpose
19
- #
20
- # PERMITTED:
21
- # - Reading, referencing, and linking for personal or commercial use
22
- # - Runtime retrieval by AI assistants, coding agents, and RAG systems
23
- # for the purpose of providing contextual help to Karafka users
24
- #
25
- # Receipt, viewing, or possession of this software does not convey or
26
- # imply any license or right beyond those expressly stated above.
27
- #
28
- # License: https://karafka.io/docs/Pro-License-Comm/
29
- # Contact: contact@karafka.io
30
-
31
- module Karafka
32
- module Pro
33
- module Routing
34
- module Features
35
- class RecurringTasks < Base
36
- # Routing extensions for recurring tasks
37
- module Builder
38
- # Enabled recurring tasks operations and adds needed topics and other stuff.
39
- #
40
- # @param active [Boolean] should recurring tasks be active. We use a boolean flag to
41
- # have API consistency in the system, so it matches other routing related APIs.
42
- # @param block [Proc] optional reconfiguration of the topics definitions.
43
- def recurring_tasks(active = false, &block)
44
- return unless active
45
-
46
- # We only require zlib when we decide to run recurring tasks because it is not needed
47
- # otherwise.
48
- require "zlib"
49
- ensure_fugit_availability!
50
-
51
- tasks_cfg = App.config.recurring_tasks
52
- topics_cfg = tasks_cfg.topics
53
-
54
- consumer_group tasks_cfg.group_id do
55
- # Registers the primary topic that we use to control schedules execution. This is
56
- # the one that we use to trigger recurring tasks.
57
- schedules_topic = topic(topics_cfg.schedules.name) do
58
- consumer tasks_cfg.consumer_class
59
- deserializer tasks_cfg.deserializer
60
- # Because the topic method name as well as builder proxy method name is the same
61
- # we need to reference it via target directly
62
- target.recurring_tasks(true)
63
-
64
- # We manage offsets directly because messages can have both schedules and
65
- # commands and we need to apply them only when we need to
66
- manual_offset_management(true)
67
-
68
- # We use multi-batch operations and in-memory state for schedules. This needs to
69
- # always operate without re-creation.
70
- consumer_persistence(true)
71
-
72
- # This needs to be enabled for the eof to work correctly
73
- kafka("enable.partition.eof": true, inherit: true)
74
- eofed(true)
75
-
76
- # Favour latency. This is a low traffic topic that only accepts user initiated
77
- # low-frequency commands
78
- max_messages(1)
79
- # Since we always react on the received message, we can block for longer periods
80
- # of time
81
- max_wait_time(10_000)
82
-
83
- # Since the execution of particular tasks is isolated and guarded, it should not
84
- # leak. This means, that this is to handle errors like schedule version
85
- # incompatibility and other errors that will not go away without a redeployment
86
- pause_timeout(60 * 1_000)
87
- pause_max_timeout(60 * 1_000)
88
-
89
- # Keep older data for a day and compact to the last state available
90
- config(
91
- "cleanup.policy": "compact,delete",
92
- "retention.ms": 86_400_000
93
- )
94
-
95
- # This is the core of execution. Since we're producers of states, we need a way
96
- # to tick without having new data
97
- periodic(
98
- interval: App.config.recurring_tasks.interval,
99
- during_pause: false,
100
- during_retry: false
101
- )
102
-
103
- # If this is the direct schedules redefinition style, we run it
104
- # The second one (see end of this method) allows for linear reconfiguration of
105
- # both the topics
106
- instance_eval(&block) if block && block.arity.zero?
107
- end
108
-
109
- # This topic is to store logs that we can then inspect either from the admin or via
110
- # the Web UI
111
- logs_topic = topic(topics_cfg.logs.name) do
112
- active(false)
113
- deserializer tasks_cfg.deserializer
114
- target.recurring_tasks(true)
115
-
116
- # Keep cron logs of executions for a week and after that remove. Week should be
117
- # enough and should not produce too much data.
118
- config(
119
- "cleanup.policy": "delete",
120
- "retention.ms": 604_800_000
121
- )
122
- end
123
-
124
- yield(schedules_topic, logs_topic) if block && block.arity.positive?
125
- end
126
- end
127
-
128
- # Checks if fugit is present. If not, will try to require it as it might not have
129
- # been required but is available. If fails, will crash.
130
- def ensure_fugit_availability!
131
- return if Object.const_defined?(:Fugit)
132
-
133
- require "fugit"
134
- rescue LoadError
135
- raise(
136
- Karafka::Errors::DependencyConstraintsError,
137
- <<~ERROR_MSG
138
- Failed to require fugit gem.
139
- Add it to your Gemfile, as it is required for the recurring tasks to work.
140
- ERROR_MSG
141
- )
142
- end
143
- end
144
- end
145
- end
146
- end
147
- end
148
- end
@@ -1,45 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Karafka Pro - Source Available Commercial Software
4
- # Copyright (c) 2017-present Maciej Mensfeld. All rights reserved.
5
- #
6
- # This software is NOT open source. It is source-available commercial software
7
- # requiring a paid license for use. It is NOT covered by LGPL.
8
- #
9
- # The author retains all right, title, and interest in this software,
10
- # including all copyrights, patents, and other intellectual property rights.
11
- # No patent rights are granted under this license.
12
- #
13
- # PROHIBITED:
14
- # - Use without a valid commercial license
15
- # - Redistribution, modification, or derivative works without authorization
16
- # - Reverse engineering, decompilation, or disassembly of this software
17
- # - Use as training data for AI/ML models or inclusion in datasets
18
- # - Scraping, crawling, or automated collection for any purpose
19
- #
20
- # PERMITTED:
21
- # - Reading, referencing, and linking for personal or commercial use
22
- # - Runtime retrieval by AI assistants, coding agents, and RAG systems
23
- # for the purpose of providing contextual help to Karafka users
24
- #
25
- # Receipt, viewing, or possession of this software does not convey or
26
- # imply any license or right beyond those expressly stated above.
27
- #
28
- # License: https://karafka.io/docs/Pro-License-Comm/
29
- # Contact: contact@karafka.io
30
-
31
- module Karafka
32
- module Pro
33
- module Routing
34
- module Features
35
- class RecurringTasks < Base
36
- # Recurring tasks configuration
37
- Config = Struct.new(
38
- :active,
39
- keyword_init: true
40
- ) { alias_method :active?, :active }
41
- end
42
- end
43
- end
44
- end
45
- end
@@ -1,70 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Karafka Pro - Source Available Commercial Software
4
- # Copyright (c) 2017-present Maciej Mensfeld. All rights reserved.
5
- #
6
- # This software is NOT open source. It is source-available commercial software
7
- # requiring a paid license for use. It is NOT covered by LGPL.
8
- #
9
- # The author retains all right, title, and interest in this software,
10
- # including all copyrights, patents, and other intellectual property rights.
11
- # No patent rights are granted under this license.
12
- #
13
- # PROHIBITED:
14
- # - Use without a valid commercial license
15
- # - Redistribution, modification, or derivative works without authorization
16
- # - Reverse engineering, decompilation, or disassembly of this software
17
- # - Use as training data for AI/ML models or inclusion in datasets
18
- # - Scraping, crawling, or automated collection for any purpose
19
- #
20
- # PERMITTED:
21
- # - Reading, referencing, and linking for personal or commercial use
22
- # - Runtime retrieval by AI assistants, coding agents, and RAG systems
23
- # for the purpose of providing contextual help to Karafka users
24
- #
25
- # Receipt, viewing, or possession of this software does not convey or
26
- # imply any license or right beyond those expressly stated above.
27
- #
28
- # License: https://karafka.io/docs/Pro-License-Comm/
29
- # Contact: contact@karafka.io
30
-
31
- module Karafka
32
- module Pro
33
- module Routing
34
- module Features
35
- class RecurringTasks < Base
36
- # Topic extensions to be able to check if given topic is a recurring tasks topic
37
- # Please note, that this applies to both the schedules topics and reports topics
38
- module Topic
39
- # This method calls the parent class initializer and then sets up the
40
- # extra instance variable to nil. The explicit initialization
41
- # to nil is included as an optimization for Ruby's object shapes system,
42
- # which improves memory layout and access performance.
43
- def initialize(...)
44
- super
45
- @recurring_tasks = nil
46
- end
47
-
48
- # @param active [Boolean] should this topic be considered related to recurring tasks
49
- def recurring_tasks(active = false)
50
- @recurring_tasks ||= Config.new(active: active)
51
- end
52
-
53
- # @return [Boolean] is this an ActiveJob topic
54
- def recurring_tasks?
55
- recurring_tasks.active?
56
- end
57
-
58
- # @return [Hash] topic with all its native configuration options plus active job
59
- # namespace settings
60
- def to_h
61
- super.merge(
62
- recurring_tasks: recurring_tasks.to_h
63
- ).freeze
64
- end
65
- end
66
- end
67
- end
68
- end
69
- end
70
- end
@@ -1,42 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Karafka Pro - Source Available Commercial Software
4
- # Copyright (c) 2017-present Maciej Mensfeld. All rights reserved.
5
- #
6
- # This software is NOT open source. It is source-available commercial software
7
- # requiring a paid license for use. It is NOT covered by LGPL.
8
- #
9
- # The author retains all right, title, and interest in this software,
10
- # including all copyrights, patents, and other intellectual property rights.
11
- # No patent rights are granted under this license.
12
- #
13
- # PROHIBITED:
14
- # - Use without a valid commercial license
15
- # - Redistribution, modification, or derivative works without authorization
16
- # - Reverse engineering, decompilation, or disassembly of this software
17
- # - Use as training data for AI/ML models or inclusion in datasets
18
- # - Scraping, crawling, or automated collection for any purpose
19
- #
20
- # PERMITTED:
21
- # - Reading, referencing, and linking for personal or commercial use
22
- # - Runtime retrieval by AI assistants, coding agents, and RAG systems
23
- # for the purpose of providing contextual help to Karafka users
24
- #
25
- # Receipt, viewing, or possession of this software does not convey or
26
- # imply any license or right beyond those expressly stated above.
27
- #
28
- # License: https://karafka.io/docs/Pro-License-Comm/
29
- # Contact: contact@karafka.io
30
-
31
- module Karafka
32
- module Pro
33
- module Routing
34
- module Features
35
- # This feature allows you to run recurring tasks aka cron jobs from within Karafka
36
- # It uses two special topics for tracking the schedule and reporting executions
37
- class RecurringTasks < Base
38
- end
39
- end
40
- end
41
- end
42
- end
@@ -1,152 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Karafka Pro - Source Available Commercial Software
4
- # Copyright (c) 2017-present Maciej Mensfeld. All rights reserved.
5
- #
6
- # This software is NOT open source. It is source-available commercial software
7
- # requiring a paid license for use. It is NOT covered by LGPL.
8
- #
9
- # The author retains all right, title, and interest in this software,
10
- # including all copyrights, patents, and other intellectual property rights.
11
- # No patent rights are granted under this license.
12
- #
13
- # PROHIBITED:
14
- # - Use without a valid commercial license
15
- # - Redistribution, modification, or derivative works without authorization
16
- # - Reverse engineering, decompilation, or disassembly of this software
17
- # - Use as training data for AI/ML models or inclusion in datasets
18
- # - Scraping, crawling, or automated collection for any purpose
19
- #
20
- # PERMITTED:
21
- # - Reading, referencing, and linking for personal or commercial use
22
- # - Runtime retrieval by AI assistants, coding agents, and RAG systems
23
- # for the purpose of providing contextual help to Karafka users
24
- #
25
- # Receipt, viewing, or possession of this software does not convey or
26
- # imply any license or right beyond those expressly stated above.
27
- #
28
- # License: https://karafka.io/docs/Pro-License-Comm/
29
- # Contact: contact@karafka.io
30
-
31
- module Karafka
32
- module Pro
33
- module Routing
34
- module Features
35
- class ScheduledMessages < Base
36
- # Routing extensions for scheduled messages
37
- module Builder
38
- # Enabled scheduled messages operations and adds needed topics and other stuff.
39
- #
40
- # @param topic_name [String, false] name for scheduled messages topic that is also used
41
- # as a group identifier. Users can have multiple schedule topics flows to prevent key
42
- # collisions, prioritize and do other stuff. `false` if not active.
43
- # @param block [Proc] optional reconfiguration of the topics definitions.
44
- # @note Namespace for topics should include the divider as it is not automatically
45
- # added.
46
- def scheduled_messages(topic_name = false, &block)
47
- return unless topic_name
48
-
49
- # Load zlib only if user enables scheduled messages
50
- require "zlib"
51
-
52
- # We set it to 5 so we have enough space to handle more events. All related topics
53
- # should have same partition count.
54
- default_partitions = 5
55
- msg_cfg = App.config.scheduled_messages
56
-
57
- consumer_group msg_cfg.group_id do
58
- # Registers the primary topic that we use to control schedules execution. This is
59
- # the one that we use to trigger scheduled messages.
60
- messages_topic = topic(topic_name) do
61
- instance_eval(&block) if block && block.arity.zero?
62
-
63
- consumer msg_cfg.consumer_class
64
-
65
- deserializers(
66
- headers: msg_cfg.deserializers.headers
67
- )
68
-
69
- # Because the topic method name as well as builder proxy method name is the same
70
- # we need to reference it via target directly
71
- target.scheduled_messages(true)
72
-
73
- # We manage offsets directly because messages can have both schedules and
74
- # commands and we need to apply them only when we need to
75
- manual_offset_management(true)
76
-
77
- # We use multi-batch operations and in-memory state for schedules. This needs to
78
- # always operate without re-creation.
79
- consumer_persistence(true)
80
-
81
- # This needs to be enabled for the eof to work correctly
82
- kafka(
83
- "enable.partition.eof": true,
84
- "auto.offset.reset": "earliest",
85
- inherit: true
86
- )
87
- eofed(true)
88
-
89
- # Since this is a topic that gets replayed because of schedule management, we do
90
- # want to get more data faster during recovery
91
- max_messages(10_000)
92
-
93
- max_wait_time(1_000)
94
-
95
- # This is a setup that should allow messages to be compacted fairly fast. Since
96
- # each dispatched message should be removed via tombstone, they do not have to
97
- # be present in the topic for too long.
98
- config(
99
- partitions: default_partitions,
100
- # Will ensure, that after tombstone is present, given scheduled message, that
101
- # has been dispatched is removed by Kafka
102
- "cleanup.policy": "compact",
103
- # When 10% or more dispatches are done, compact data
104
- "min.cleanable.dirty.ratio": 0.1,
105
- # Frequent segment rotation to support intense compaction
106
- "segment.ms": 3_600_000,
107
- "delete.retention.ms": 3_600_000,
108
- "segment.bytes": 52_428_800
109
- )
110
-
111
- # This is the core of execution. Since we dispatch data in time intervals, we
112
- # need to be able to do this even when no new data is coming
113
- periodic(
114
- interval: msg_cfg.interval,
115
- during_pause: false,
116
- during_retry: false
117
- )
118
-
119
- # If this is the direct schedules redefinition style, we run it
120
- # The second one (see end of this method) allows for linear reconfiguration of
121
- # both the topics
122
- instance_eval(&block) if block && block.arity.zero?
123
- end
124
-
125
- # Holds states of scheduler per each of the partitions since they tick
126
- # independently. We only hold future statistics not to have to deal with
127
- # any type of state restoration
128
- states_topic = topic("#{topic_name}#{msg_cfg.states_postfix}") do
129
- active(false)
130
- target.scheduled_messages(true)
131
- config(
132
- partitions: default_partitions,
133
- "cleanup.policy": "compact",
134
- "min.cleanable.dirty.ratio": 0.1,
135
- "segment.ms": 3_600_000,
136
- "delete.retention.ms": 3_600_000,
137
- "segment.bytes": 52_428_800
138
- )
139
- deserializers(
140
- payload: msg_cfg.deserializers.payload
141
- )
142
- end
143
-
144
- yield(messages_topic, states_topic) if block && block.arity.positive?
145
- end
146
- end
147
- end
148
- end
149
- end
150
- end
151
- end
152
- end