karafka-web 0.9.1 → 0.10.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (418) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/.github/workflows/ci.yml +30 -0
  4. data/.gitignore +2 -0
  5. data/.ruby-version +1 -1
  6. data/CHANGELOG.md +86 -1
  7. data/Gemfile +1 -0
  8. data/Gemfile.lock +29 -25
  9. data/LICENSE +1 -1
  10. data/bin/build_assets +51 -0
  11. data/bin/release +6 -0
  12. data/config/locales/pro_errors.yml +18 -0
  13. data/docker-compose.yml +1 -1
  14. data/gulpfile.js +73 -0
  15. data/karafka-web.gemspec +2 -2
  16. data/lib/karafka/web/config.rb +9 -10
  17. data/lib/karafka/web/contracts/base.rb +2 -0
  18. data/lib/karafka/web/contracts/config.rb +2 -1
  19. data/lib/karafka/web/errors.rb +12 -0
  20. data/lib/karafka/web/inflector.rb +1 -1
  21. data/lib/karafka/web/management/actions/enable.rb +11 -0
  22. data/lib/karafka/web/management/migrations/consumers_metrics/0_set_initial.rb +39 -0
  23. data/lib/karafka/web/management/migrations/consumers_metrics/1699543515_fill_missing_received_and_sent_bytes.rb +28 -0
  24. data/lib/karafka/web/management/migrations/consumers_metrics/1700234522_introduce_waiting.rb +26 -0
  25. data/lib/karafka/web/management/migrations/consumers_metrics/1700234522_remove_processing.rb +26 -0
  26. data/lib/karafka/web/management/migrations/consumers_metrics/1704722380_split_listeners_into_active_and_paused.rb +38 -0
  27. data/lib/karafka/web/management/migrations/consumers_metrics/1706607960_introduce_lag_total.rb +40 -0
  28. data/lib/karafka/web/management/migrations/consumers_metrics/1706611396_rename_lag_total_to_lag_hybrid.rb +38 -0
  29. data/lib/karafka/web/management/migrations/consumers_metrics/1716218393_populate_jobs_metrics.rb +26 -0
  30. data/lib/karafka/web/management/migrations/consumers_states/0_set_initial.rb +46 -0
  31. data/lib/karafka/web/management/migrations/consumers_states/1699543515_fill_missing_received_and_sent_bytes.rb +25 -0
  32. data/lib/karafka/web/management/migrations/consumers_states/1700234522_introduce_waiting.rb +22 -0
  33. data/lib/karafka/web/management/migrations/consumers_states/1700234522_remove_processing.rb +22 -0
  34. data/lib/karafka/web/management/migrations/consumers_states/1704722380_split_listeners_into_active_and_paused.rb +34 -0
  35. data/lib/karafka/web/management/migrations/consumers_states/1706607960_introduce_lag_total.rb +24 -0
  36. data/lib/karafka/web/management/migrations/consumers_states/1706611396_rename_lag_total_to_lag_hybrid.rb +23 -0
  37. data/lib/karafka/web/management/migrations/consumers_states/1716218393_add_jobs_counter.rb +24 -0
  38. data/lib/karafka/web/management/migrator.rb +5 -5
  39. data/lib/karafka/web/pro/commanding/commands/base.rb +8 -0
  40. data/lib/karafka/web/pro/commanding/commands/quiet.rb +4 -1
  41. data/lib/karafka/web/pro/commanding/commands/stop.rb +4 -1
  42. data/lib/karafka/web/pro/loader.rb +8 -0
  43. data/lib/karafka/web/pro/ui/app.rb +44 -7
  44. data/lib/karafka/web/pro/ui/controllers/dlq_controller.rb +1 -1
  45. data/lib/karafka/web/pro/ui/controllers/errors_controller.rb +1 -0
  46. data/lib/karafka/web/pro/ui/controllers/explorer_controller.rb +6 -14
  47. data/lib/karafka/web/pro/ui/controllers/messages_controller.rb +5 -4
  48. data/lib/karafka/web/pro/ui/controllers/search_controller.rb +73 -0
  49. data/lib/karafka/web/pro/ui/controllers/support_controller.rb +26 -0
  50. data/lib/karafka/web/pro/ui/controllers/topics_controller.rb +31 -0
  51. data/lib/karafka/web/pro/ui/controllers/ux_controller.rb +26 -0
  52. data/lib/karafka/web/pro/ui/lib/policies/config.rb +39 -0
  53. data/lib/karafka/web/pro/ui/lib/policies/contracts/config.rb +46 -0
  54. data/lib/karafka/web/pro/ui/lib/policies/messages.rb +76 -0
  55. data/lib/karafka/web/pro/ui/lib/policies/requests.rb +36 -0
  56. data/lib/karafka/web/pro/ui/lib/policies.rb +34 -0
  57. data/lib/karafka/web/pro/ui/lib/safe_runner.rb +98 -0
  58. data/lib/karafka/web/pro/ui/lib/search/config.rb +53 -0
  59. data/lib/karafka/web/pro/ui/lib/search/contracts/config.rb +101 -0
  60. data/lib/karafka/web/pro/ui/lib/search/contracts/form.rb +111 -0
  61. data/lib/karafka/web/pro/ui/lib/search/matchers/base.rb +59 -0
  62. data/lib/karafka/web/pro/ui/lib/search/matchers/raw_header_includes.rb +57 -0
  63. data/lib/karafka/web/pro/ui/lib/search/matchers/raw_key_includes.rb +41 -0
  64. data/lib/karafka/web/pro/ui/lib/search/matchers/raw_payload_includes.rb +45 -0
  65. data/lib/karafka/web/pro/ui/lib/search/normalizer.rb +47 -0
  66. data/lib/karafka/web/pro/ui/lib/search/runner.rb +230 -0
  67. data/lib/karafka/web/pro/ui/lib/search.rb +36 -0
  68. data/lib/karafka/web/pro/ui/views/cluster/_breadcrumbs.erb +4 -4
  69. data/lib/karafka/web/pro/ui/views/cluster/_tabs.erb +14 -24
  70. data/lib/karafka/web/pro/ui/views/cluster/index.erb +20 -22
  71. data/lib/karafka/web/pro/ui/views/cluster/show.erb +21 -25
  72. data/lib/karafka/web/pro/ui/views/commands/_backtrace.erb +4 -19
  73. data/lib/karafka/web/pro/ui/views/commands/_breadcrumbs.erb +3 -3
  74. data/lib/karafka/web/pro/ui/views/commands/_command.erb +6 -6
  75. data/lib/karafka/web/pro/ui/views/commands/_command_details.erb +1 -11
  76. data/lib/karafka/web/pro/ui/views/commands/_incompatible_schema.erb +3 -14
  77. data/lib/karafka/web/pro/ui/views/commands/_metadata.erb +33 -42
  78. data/lib/karafka/web/pro/ui/views/commands/_table.erb +9 -3
  79. data/lib/karafka/web/pro/ui/views/commands/index.erb +18 -12
  80. data/lib/karafka/web/pro/ui/views/commands/show.erb +24 -29
  81. data/lib/karafka/web/pro/ui/views/consumers/_breadcrumbs.erb +8 -8
  82. data/lib/karafka/web/pro/ui/views/consumers/_consumer.erb +13 -23
  83. data/lib/karafka/web/pro/ui/views/consumers/_consumer_controls.erb +51 -35
  84. data/lib/karafka/web/pro/ui/views/consumers/_consumer_performance.erb +1 -1
  85. data/lib/karafka/web/pro/ui/views/consumers/_tabs.erb +28 -30
  86. data/lib/karafka/web/pro/ui/views/consumers/consumer/_commands.erb +68 -28
  87. data/lib/karafka/web/pro/ui/views/consumers/consumer/_job.erb +1 -1
  88. data/lib/karafka/web/pro/ui/views/consumers/consumer/_metrics.erb +114 -133
  89. data/lib/karafka/web/pro/ui/views/consumers/consumer/_partition.erb +4 -4
  90. data/lib/karafka/web/pro/ui/views/consumers/consumer/_stopped.erb +6 -9
  91. data/lib/karafka/web/pro/ui/views/consumers/consumer/_subscription_group.erb +116 -126
  92. data/lib/karafka/web/pro/ui/views/consumers/consumer/_tabs.erb +26 -31
  93. data/lib/karafka/web/pro/ui/views/consumers/controls.erb +53 -57
  94. data/lib/karafka/web/pro/ui/views/consumers/details.erb +4 -17
  95. data/lib/karafka/web/pro/ui/views/consumers/index.erb +31 -34
  96. data/lib/karafka/web/pro/ui/views/consumers/pending_jobs.erb +41 -46
  97. data/lib/karafka/web/pro/ui/views/consumers/performance.erb +43 -47
  98. data/lib/karafka/web/pro/ui/views/consumers/running_jobs.erb +41 -46
  99. data/lib/karafka/web/pro/ui/views/consumers/subscriptions.erb +14 -17
  100. data/lib/karafka/web/pro/ui/views/dashboard/index.erb +67 -76
  101. data/lib/karafka/web/pro/ui/views/dlq/_breadcrumbs.erb +1 -1
  102. data/lib/karafka/web/pro/ui/views/dlq/_no_topics.erb +1 -7
  103. data/lib/karafka/web/pro/ui/views/dlq/_topic.erb +7 -10
  104. data/lib/karafka/web/pro/ui/views/dlq/index.erb +8 -10
  105. data/lib/karafka/web/pro/ui/views/errors/_breadcrumbs.erb +3 -3
  106. data/lib/karafka/web/pro/ui/views/errors/_error.erb +8 -5
  107. data/lib/karafka/web/pro/ui/views/errors/_selector.erb +12 -0
  108. data/lib/karafka/web/pro/ui/views/errors/_table.erb +5 -4
  109. data/lib/karafka/web/pro/ui/views/errors/index.erb +50 -15
  110. data/lib/karafka/web/pro/ui/views/errors/partition.erb +61 -14
  111. data/lib/karafka/web/pro/ui/views/errors/show.erb +28 -46
  112. data/lib/karafka/web/pro/ui/views/explorer/_breadcrumbs.erb +11 -3
  113. data/lib/karafka/web/pro/ui/views/explorer/_failed_deserialization.erb +8 -3
  114. data/lib/karafka/web/pro/ui/views/explorer/_message.erb +12 -6
  115. data/lib/karafka/web/pro/ui/views/explorer/_no_topics.erb +1 -5
  116. data/lib/karafka/web/pro/ui/views/explorer/_selector.erb +12 -0
  117. data/lib/karafka/web/pro/ui/views/explorer/_topic.erb +6 -8
  118. data/lib/karafka/web/pro/ui/views/explorer/index.erb +13 -15
  119. data/lib/karafka/web/pro/ui/views/explorer/message/_metadata.erb +68 -32
  120. data/lib/karafka/web/pro/ui/views/explorer/message/_payload.erb +17 -16
  121. data/lib/karafka/web/pro/ui/views/explorer/message/_resources_utilization.erb +127 -0
  122. data/lib/karafka/web/pro/ui/views/explorer/message/_too_big_to_be_displayed.erb +20 -0
  123. data/lib/karafka/web/pro/ui/views/explorer/messages/_detail.erb +1 -1
  124. data/lib/karafka/web/pro/ui/views/explorer/partition/_cleaned.erb +3 -5
  125. data/lib/karafka/web/pro/ui/views/explorer/partition/_empty.erb +3 -5
  126. data/lib/karafka/web/pro/ui/views/explorer/partition/_messages.erb +6 -3
  127. data/lib/karafka/web/pro/ui/views/explorer/partition.erb +67 -46
  128. data/lib/karafka/web/pro/ui/views/explorer/show.erb +85 -21
  129. data/lib/karafka/web/pro/ui/views/explorer/topic/_actions.erb +27 -0
  130. data/lib/karafka/web/pro/ui/views/explorer/topic/_empty.erb +3 -5
  131. data/lib/karafka/web/pro/ui/views/explorer/topic/_limited.erb +8 -10
  132. data/lib/karafka/web/pro/ui/views/explorer/topic.erb +24 -44
  133. data/lib/karafka/web/pro/ui/views/health/_breadcrumbs.erb +7 -7
  134. data/lib/karafka/web/pro/ui/views/health/_no_data.erb +1 -7
  135. data/lib/karafka/web/pro/ui/views/health/_partition.erb +3 -3
  136. data/lib/karafka/web/pro/ui/views/health/_partition_lags.erb +3 -3
  137. data/lib/karafka/web/pro/ui/views/health/_partition_offset.erb +2 -2
  138. data/lib/karafka/web/pro/ui/views/health/_partition_times.erb +3 -7
  139. data/lib/karafka/web/pro/ui/views/health/_table_metadata.erb +8 -0
  140. data/lib/karafka/web/pro/ui/views/health/_tabs.erb +32 -49
  141. data/lib/karafka/web/pro/ui/views/health/changes.erb +51 -51
  142. data/lib/karafka/web/pro/ui/views/health/cluster_lags.erb +28 -41
  143. data/lib/karafka/web/pro/ui/views/health/lags.erb +52 -52
  144. data/lib/karafka/web/pro/ui/views/health/offsets.erb +55 -55
  145. data/lib/karafka/web/pro/ui/views/health/overview.erb +60 -60
  146. data/lib/karafka/web/pro/ui/views/jobs/_job.erb +1 -1
  147. data/lib/karafka/web/pro/ui/views/jobs/_no_jobs.erb +1 -7
  148. data/lib/karafka/web/pro/ui/views/jobs/pending.erb +36 -38
  149. data/lib/karafka/web/pro/ui/views/jobs/running.erb +36 -38
  150. data/lib/karafka/web/pro/ui/views/routing/_consumer_group.erb +7 -12
  151. data/lib/karafka/web/pro/ui/views/routing/_topic.erb +13 -11
  152. data/lib/karafka/web/pro/ui/views/routing/index.erb +7 -9
  153. data/lib/karafka/web/pro/ui/views/routing/show.erb +41 -33
  154. data/lib/karafka/web/pro/ui/views/search/_fix_errors.erb +3 -0
  155. data/lib/karafka/web/pro/ui/views/search/_metadata.erb +71 -0
  156. data/lib/karafka/web/pro/ui/views/search/_no_results.erb +3 -0
  157. data/lib/karafka/web/pro/ui/views/search/_no_search_criteria.erb +5 -0
  158. data/lib/karafka/web/pro/ui/views/search/_search_criteria.erb +37 -0
  159. data/lib/karafka/web/pro/ui/views/search/_search_modal.erb +139 -0
  160. data/lib/karafka/web/pro/ui/views/search/_timeout.erb +3 -0
  161. data/lib/karafka/web/pro/ui/views/search/index.erb +29 -0
  162. data/lib/karafka/web/pro/ui/views/shared/_navigation.erb +80 -28
  163. data/lib/karafka/web/pro/ui/views/topics/_breadcrumbs.erb +14 -6
  164. data/lib/karafka/web/pro/ui/views/topics/_partition_offsets.erb +10 -0
  165. data/lib/karafka/web/pro/ui/views/topics/_tabs.erb +26 -32
  166. data/lib/karafka/web/pro/ui/views/topics/_topic.erb +7 -10
  167. data/lib/karafka/web/pro/ui/views/topics/config.erb +21 -25
  168. data/lib/karafka/web/pro/ui/views/topics/distribution/_badges.erb +10 -5
  169. data/lib/karafka/web/pro/ui/views/topics/distribution/_chart.erb +3 -1
  170. data/lib/karafka/web/pro/ui/views/topics/distribution/_limited.erb +1 -1
  171. data/lib/karafka/web/pro/ui/views/topics/distribution.erb +34 -39
  172. data/lib/karafka/web/pro/ui/views/topics/index.erb +13 -15
  173. data/lib/karafka/web/pro/ui/views/topics/offsets.erb +24 -0
  174. data/lib/karafka/web/pro/ui/views/topics/replication.erb +20 -24
  175. data/lib/karafka/web/processing/consumers/aggregators/metrics.rb +1 -1
  176. data/lib/karafka/web/processing/consumers/aggregators/state.rb +1 -1
  177. data/lib/karafka/web/processing/consumers/contracts/aggregated_stats.rb +1 -0
  178. data/lib/karafka/web/tracking/consumers/contracts/job.rb +1 -1
  179. data/lib/karafka/web/tracking/consumers/contracts/report.rb +6 -0
  180. data/lib/karafka/web/tracking/consumers/listeners/connections.rb +8 -6
  181. data/lib/karafka/web/tracking/consumers/listeners/processing.rb +7 -1
  182. data/lib/karafka/web/tracking/consumers/listeners/tags.rb +1 -1
  183. data/lib/karafka/web/tracking/consumers/reporter.rb +6 -8
  184. data/lib/karafka/web/tracking/consumers/sampler.rb +16 -5
  185. data/lib/karafka/web/ui/app.rb +20 -1
  186. data/lib/karafka/web/ui/base.rb +26 -20
  187. data/lib/karafka/web/ui/controllers/base_controller.rb +7 -5
  188. data/lib/karafka/web/ui/controllers/dashboard_controller.rb +8 -0
  189. data/lib/karafka/web/ui/controllers/requests/params.rb +16 -2
  190. data/lib/karafka/web/ui/controllers/support_controller.rb +17 -0
  191. data/lib/karafka/web/ui/controllers/ux_controller.rb +17 -0
  192. data/lib/karafka/web/ui/helpers/application_helper.rb +75 -42
  193. data/lib/karafka/web/ui/helpers/paths_helper.rb +24 -0
  194. data/lib/karafka/web/ui/helpers/tailwind_helper.rb +90 -0
  195. data/lib/karafka/web/ui/lib/sorter.rb +1 -1
  196. data/lib/karafka/web/ui/models/metrics/aggregated.rb +1 -0
  197. data/lib/karafka/web/ui/models/metrics/charts/topics.rb +36 -20
  198. data/lib/karafka/web/ui/models/status.rb +28 -1
  199. data/lib/karafka/web/ui/public/images/calendar.svg +3 -0
  200. data/lib/karafka/web/ui/public/javascripts/application.js +39 -15
  201. data/lib/karafka/web/ui/public/javascripts/application.min.js +64 -0
  202. data/lib/karafka/web/ui/public/javascripts/application.min.js.br +0 -0
  203. data/lib/karafka/web/ui/public/javascripts/application.min.js.gz +0 -0
  204. data/lib/karafka/web/ui/public/javascripts/charts/types/line.js +41 -9
  205. data/lib/karafka/web/ui/public/javascripts/components/btn_toggle_manager.js +37 -0
  206. data/lib/karafka/web/ui/public/javascripts/{live_poll.js → components/live_poll.js} +44 -8
  207. data/lib/karafka/web/ui/public/javascripts/{offset_datetime.js → components/offset_datetime.js} +1 -1
  208. data/lib/karafka/web/ui/public/javascripts/components/search.js +102 -0
  209. data/lib/karafka/web/ui/public/javascripts/components/tabs_manager.js +84 -0
  210. data/lib/karafka/web/ui/public/javascripts/components/theme_manager.js +66 -0
  211. data/lib/karafka/web/ui/public/javascripts/components/turbo_tracker.js +30 -0
  212. data/lib/karafka/web/ui/public/javascripts/libs/datepicker.js +2 -2
  213. data/lib/karafka/web/ui/public/javascripts/libs/turbo.js +6618 -0
  214. data/lib/karafka/web/ui/public/stylesheets/application.css +16 -113
  215. data/lib/karafka/web/ui/public/stylesheets/application.min.css +13 -0
  216. data/lib/karafka/web/ui/public/stylesheets/application.min.css.br +0 -0
  217. data/lib/karafka/web/ui/public/stylesheets/application.min.css.gz +0 -0
  218. data/lib/karafka/web/ui/public/stylesheets/libs/highlight_dark.min.css +8 -0
  219. data/lib/karafka/web/ui/public/stylesheets/libs/highlight_dark.min.css.br +0 -0
  220. data/lib/karafka/web/ui/public/stylesheets/libs/highlight_dark.min.css.gz +0 -0
  221. data/lib/karafka/web/ui/public/stylesheets/libs/highlight_light.min.css.br +0 -0
  222. data/lib/karafka/web/ui/public/stylesheets/libs/highlight_light.min.css.gz +0 -0
  223. data/lib/karafka/web/ui/public/stylesheets/libs/tailwind.css +391 -0
  224. data/lib/karafka/web/ui/views/cluster/_breadcrumbs.erb +3 -3
  225. data/lib/karafka/web/ui/views/cluster/_tabs.erb +14 -24
  226. data/lib/karafka/web/ui/views/cluster/brokers.erb +20 -22
  227. data/lib/karafka/web/ui/views/cluster/replication.erb +28 -32
  228. data/lib/karafka/web/ui/views/consumers/_assignments_badges.erb +1 -1
  229. data/lib/karafka/web/ui/views/consumers/_breadcrumbs.erb +5 -0
  230. data/lib/karafka/web/ui/views/consumers/_consumer.erb +9 -13
  231. data/lib/karafka/web/ui/views/consumers/_no_consumers.erb +2 -8
  232. data/lib/karafka/web/ui/views/consumers/_summary.erb +34 -45
  233. data/lib/karafka/web/ui/views/consumers/_tabs.erb +35 -0
  234. data/lib/karafka/web/ui/views/consumers/index.erb +31 -33
  235. data/lib/karafka/web/ui/views/dashboard/_counters.erb +76 -0
  236. data/lib/karafka/web/ui/views/dashboard/_feature_pro.erb +6 -2
  237. data/lib/karafka/web/ui/views/dashboard/_not_enough_data.erb +3 -15
  238. data/lib/karafka/web/ui/views/dashboard/_ranges_selector.erb +12 -12
  239. data/lib/karafka/web/ui/views/dashboard/index.erb +78 -52
  240. data/lib/karafka/web/ui/views/errors/_breadcrumbs.erb +2 -2
  241. data/lib/karafka/web/ui/views/errors/_detail.erb +1 -3
  242. data/lib/karafka/web/ui/views/errors/_error.erb +3 -5
  243. data/lib/karafka/web/ui/views/errors/index.erb +34 -44
  244. data/lib/karafka/web/ui/views/errors/show.erb +29 -47
  245. data/lib/karafka/web/ui/views/jobs/_breadcrumbs.erb +3 -3
  246. data/lib/karafka/web/ui/views/jobs/_job.erb +1 -1
  247. data/lib/karafka/web/ui/views/jobs/_no_jobs.erb +1 -7
  248. data/lib/karafka/web/ui/views/jobs/_tabs.erb +14 -24
  249. data/lib/karafka/web/ui/views/jobs/pending.erb +30 -32
  250. data/lib/karafka/web/ui/views/jobs/running.erb +30 -32
  251. data/lib/karafka/web/ui/views/layout.erb +37 -21
  252. data/lib/karafka/web/ui/views/routing/_breadcrumbs.erb +2 -2
  253. data/lib/karafka/web/ui/views/routing/_consumer_group.erb +7 -12
  254. data/lib/karafka/web/ui/views/routing/_topic.erb +3 -5
  255. data/lib/karafka/web/ui/views/routing/index.erb +7 -9
  256. data/lib/karafka/web/ui/views/routing/show.erb +30 -22
  257. data/lib/karafka/web/ui/views/shared/_become_pro.erb +8 -8
  258. data/lib/karafka/web/ui/views/shared/_brand.erb +2 -2
  259. data/lib/karafka/web/ui/views/shared/_breadcrumbs.erb +23 -0
  260. data/lib/karafka/web/ui/views/shared/_content.erb +2 -28
  261. data/lib/karafka/web/ui/views/shared/_controls.erb +15 -0
  262. data/lib/karafka/web/ui/views/shared/_flashes.erb +5 -7
  263. data/lib/karafka/web/ui/views/shared/_header.erb +16 -19
  264. data/lib/karafka/web/ui/views/shared/_navigation.erb +84 -28
  265. data/lib/karafka/web/ui/views/shared/_no_paginated_data.erb +5 -9
  266. data/lib/karafka/web/ui/views/shared/_pagination.erb +11 -11
  267. data/lib/karafka/web/ui/views/shared/_tab_nav.erb +4 -5
  268. data/lib/karafka/web/ui/views/shared/_title.erb +5 -0
  269. data/lib/karafka/web/ui/views/shared/alerts/_box_error.erb +15 -0
  270. data/lib/karafka/web/ui/views/shared/alerts/_box_info.erb +15 -0
  271. data/lib/karafka/web/ui/views/shared/alerts/_box_primary.erb +15 -0
  272. data/lib/karafka/web/ui/views/shared/alerts/_box_secondary.erb +15 -0
  273. data/lib/karafka/web/ui/views/shared/alerts/_box_success.erb +15 -0
  274. data/lib/karafka/web/ui/views/shared/alerts/_box_warning.erb +15 -0
  275. data/lib/karafka/web/ui/views/shared/alerts/_error.erb +4 -0
  276. data/lib/karafka/web/ui/views/shared/alerts/_info.erb +5 -2
  277. data/lib/karafka/web/ui/views/shared/alerts/_primary.erb +4 -0
  278. data/lib/karafka/web/ui/views/shared/alerts/_secondary.erb +4 -0
  279. data/lib/karafka/web/ui/views/shared/alerts/_success.erb +4 -0
  280. data/lib/karafka/web/ui/views/shared/alerts/_warning.erb +4 -0
  281. data/lib/karafka/web/ui/views/shared/charts/_line.erb +1 -1
  282. data/lib/karafka/web/ui/views/shared/exceptions/not_allowed.erb +14 -19
  283. data/lib/karafka/web/ui/views/shared/exceptions/not_found.erb +16 -21
  284. data/lib/karafka/web/ui/views/shared/exceptions/pro_only.erb +16 -28
  285. data/lib/karafka/web/ui/views/shared/icons/_arrow_down_on_square.erb +3 -0
  286. data/lib/karafka/web/ui/views/shared/icons/_arrow_down_tray.erb +3 -0
  287. data/lib/karafka/web/ui/views/shared/icons/_arrow_on_squares.erb +3 -0
  288. data/lib/karafka/web/ui/views/shared/icons/_arrow_path_rounded.erb +3 -0
  289. data/lib/karafka/web/ui/views/shared/icons/_arrow_uturn_right.erb +3 -0
  290. data/lib/karafka/web/ui/views/shared/icons/_arrows_right_left.erb +3 -0
  291. data/lib/karafka/web/ui/views/shared/icons/_blocks.erb +3 -0
  292. data/lib/karafka/web/ui/views/shared/icons/_book_open.erb +3 -0
  293. data/lib/karafka/web/ui/views/shared/icons/_bug.erb +3 -0
  294. data/lib/karafka/web/ui/views/shared/icons/_burger.erb +14 -0
  295. data/lib/karafka/web/ui/views/shared/icons/_calendar_days.erb +3 -0
  296. data/lib/karafka/web/ui/views/shared/icons/_chart_bar.erb +3 -0
  297. data/lib/karafka/web/ui/views/shared/icons/_check_badge.erb +3 -0
  298. data/lib/karafka/web/ui/views/shared/icons/_check_circle.erb +3 -0
  299. data/lib/karafka/web/ui/views/shared/icons/_circle_stack.erb +3 -0
  300. data/lib/karafka/web/ui/views/shared/icons/_cpu.erb +3 -0
  301. data/lib/karafka/web/ui/views/shared/icons/_document_glass.erb +3 -0
  302. data/lib/karafka/web/ui/views/shared/icons/_exclamation_triangle.erb +3 -0
  303. data/lib/karafka/web/ui/views/shared/icons/_eye.erb +4 -0
  304. data/lib/karafka/web/ui/views/shared/icons/_gear.erb +4 -0
  305. data/lib/karafka/web/ui/views/shared/icons/_github.erb +13 -0
  306. data/lib/karafka/web/ui/views/shared/icons/_globe.erb +3 -0
  307. data/lib/karafka/web/ui/views/shared/icons/_heart.erb +3 -0
  308. data/lib/karafka/web/ui/views/shared/icons/_home.erb +3 -0
  309. data/lib/karafka/web/ui/views/shared/icons/_info_circle.erb +3 -0
  310. data/lib/karafka/web/ui/views/shared/icons/_lifebuoy.erb +3 -0
  311. data/lib/karafka/web/ui/views/shared/icons/_light_bulb.erb +3 -0
  312. data/lib/karafka/web/ui/views/shared/icons/_list_bullets.erb +3 -0
  313. data/lib/karafka/web/ui/views/shared/icons/_magnifying_glass.erb +3 -0
  314. data/lib/karafka/web/ui/views/shared/icons/_moon.erb +3 -0
  315. data/lib/karafka/web/ui/views/shared/icons/_offices.erb +3 -0
  316. data/lib/karafka/web/ui/views/shared/icons/_pause.erb +3 -0
  317. data/lib/karafka/web/ui/views/shared/icons/_pause_circle.erb +3 -0
  318. data/lib/karafka/web/ui/views/shared/icons/_play_circle.erb +4 -0
  319. data/lib/karafka/web/ui/views/shared/icons/_question_circle.erb +3 -0
  320. data/lib/karafka/web/ui/views/shared/icons/_queue_list.erb +3 -0
  321. data/lib/karafka/web/ui/views/shared/icons/_refresh.erb +3 -0
  322. data/lib/karafka/web/ui/views/shared/icons/_slack.erb +16 -0
  323. data/lib/karafka/web/ui/views/shared/icons/_stop.erb +3 -0
  324. data/lib/karafka/web/ui/views/shared/icons/_sun.erb +3 -0
  325. data/lib/karafka/web/ui/views/shared/icons/_x_circle.erb +3 -0
  326. data/lib/karafka/web/ui/views/shared/icons/_x_mark.erb +3 -0
  327. data/lib/karafka/web/ui/views/status/_breadcrumbs.erb +1 -1
  328. data/lib/karafka/web/ui/views/status/_failure.erb +2 -13
  329. data/lib/karafka/web/ui/views/status/_halted.erb +2 -10
  330. data/lib/karafka/web/ui/views/status/_info.erb +2 -13
  331. data/lib/karafka/web/ui/views/status/_success.erb +2 -10
  332. data/lib/karafka/web/ui/views/status/_warning.erb +2 -13
  333. data/lib/karafka/web/ui/views/status/failures/_connection.erb +2 -2
  334. data/lib/karafka/web/ui/views/status/failures/_consumers_reports.erb +3 -3
  335. data/lib/karafka/web/ui/views/status/failures/_consumers_reports_schema_state.erb +4 -4
  336. data/lib/karafka/web/ui/views/status/failures/_enabled.erb +2 -2
  337. data/lib/karafka/web/ui/views/status/failures/_initial_consumers_metrics.erb +6 -6
  338. data/lib/karafka/web/ui/views/status/failures/_initial_consumers_state.erb +6 -6
  339. data/lib/karafka/web/ui/views/status/failures/_live_reporting.erb +2 -2
  340. data/lib/karafka/web/ui/views/status/failures/_materializing_lag.erb +11 -0
  341. data/lib/karafka/web/ui/views/status/failures/_partitions.erb +3 -3
  342. data/lib/karafka/web/ui/views/status/failures/_state_calculation.erb +2 -2
  343. data/lib/karafka/web/ui/views/status/failures/_topics.erb +3 -3
  344. data/lib/karafka/web/ui/views/status/info/_components.erb +14 -41
  345. data/lib/karafka/web/ui/views/status/show.erb +165 -154
  346. data/lib/karafka/web/ui/views/status/warnings/_connection.erb +3 -3
  347. data/lib/karafka/web/ui/views/status/warnings/_pro_subscription.erb +2 -2
  348. data/lib/karafka/web/ui/views/status/warnings/_replication.erb +2 -2
  349. data/lib/karafka/web/ui/views/status/warnings/_routing_topics_presence.erb +1 -1
  350. data/lib/karafka/web/ui/views/support/_breadcrumbs.erb +5 -0
  351. data/lib/karafka/web/ui/views/support/show.erb +71 -0
  352. data/lib/karafka/web/ui/views/ux/_alerts.erb +25 -0
  353. data/lib/karafka/web/ui/views/ux/_badges.erb +21 -0
  354. data/lib/karafka/web/ui/views/ux/_breadcrumbs.erb +5 -0
  355. data/lib/karafka/web/ui/views/ux/_buttons.erb +47 -0
  356. data/lib/karafka/web/ui/views/ux/_card_detail.erb +15 -0
  357. data/lib/karafka/web/ui/views/ux/_card_metric.erb +123 -0
  358. data/lib/karafka/web/ui/views/ux/_card_summary.erb +72 -0
  359. data/lib/karafka/web/ui/views/ux/_card_support.erb +39 -0
  360. data/lib/karafka/web/ui/views/ux/_code.erb +9 -0
  361. data/lib/karafka/web/ui/views/ux/_data_table.erb +52 -0
  362. data/lib/karafka/web/ui/views/ux/_headers.erb +2 -0
  363. data/lib/karafka/web/ui/views/ux/_icons.erb +9 -0
  364. data/lib/karafka/web/ui/views/ux/_pagination.erb +32 -0
  365. data/lib/karafka/web/ui/views/ux/_row_table.erb +52 -0
  366. data/lib/karafka/web/ui/views/ux/_status_rows.erb +53 -0
  367. data/lib/karafka/web/ui/views/ux/_tabs.erb +14 -0
  368. data/lib/karafka/web/ui/views/ux/_text.erb +2 -0
  369. data/lib/karafka/web/ui/views/ux/_topic_tiles.erb +42 -0
  370. data/lib/karafka/web/ui/views/ux/show.erb +19 -0
  371. data/lib/karafka/web/version.rb +1 -1
  372. data/lib/karafka/web.rb +2 -0
  373. data/package-lock.json +4163 -0
  374. data/package.json +15 -0
  375. data/postcss.config.js +6 -0
  376. data/tailwind.config.js +16 -0
  377. data.tar.gz.sig +0 -0
  378. metadata +172 -47
  379. metadata.gz.sig +0 -0
  380. data/lib/karafka/web/management/migrations/0_set_initial_consumers_metrics.rb +0 -36
  381. data/lib/karafka/web/management/migrations/0_set_initial_consumers_state.rb +0 -43
  382. data/lib/karafka/web/management/migrations/1699543515_fill_missing_received_and_sent_bytes_in_consumers_metrics.rb +0 -26
  383. data/lib/karafka/web/management/migrations/1699543515_fill_missing_received_and_sent_bytes_in_consumers_state.rb +0 -23
  384. data/lib/karafka/web/management/migrations/1700234522_introduce_waiting_in_consumers_metrics.rb +0 -24
  385. data/lib/karafka/web/management/migrations/1700234522_introduce_waiting_in_consumers_state.rb +0 -20
  386. data/lib/karafka/web/management/migrations/1700234522_remove_processing_from_consumers_metrics.rb +0 -24
  387. data/lib/karafka/web/management/migrations/1700234522_remove_processing_from_consumers_state.rb +0 -20
  388. data/lib/karafka/web/management/migrations/1704722380_split_listeners_into_active_and_paused_in_metrics.rb +0 -36
  389. data/lib/karafka/web/management/migrations/1704722380_split_listeners_into_active_and_paused_in_states.rb +0 -32
  390. data/lib/karafka/web/management/migrations/1706607960_introduce_lag_total_in_metrics.rb +0 -38
  391. data/lib/karafka/web/management/migrations/1706607960_introduce_lag_total_in_states.rb +0 -22
  392. data/lib/karafka/web/management/migrations/1706611396_rename_lag_total_to_lag_hybrid_in_metrics.rb +0 -36
  393. data/lib/karafka/web/management/migrations/1706611396_rename_lag_total_to_lag_hybrid_in_states.rb +0 -21
  394. data/lib/karafka/web/pro/ui/views/cluster/brokers.erb +0 -27
  395. data/lib/karafka/web/pro/ui/views/commands/_details.erb +0 -26
  396. data/lib/karafka/web/pro/ui/views/consumers/_counters.erb +0 -72
  397. data/lib/karafka/web/pro/ui/views/consumers/consumer/_title.erb +0 -5
  398. data/lib/karafka/web/pro/ui/views/errors/_title_with_select.erb +0 -31
  399. data/lib/karafka/web/pro/ui/views/explorer/message/_message_actions.erb +0 -18
  400. data/lib/karafka/web/pro/ui/views/explorer/message/_payload_actions.erb +0 -19
  401. data/lib/karafka/web/pro/ui/views/explorer/partition/_details.erb +0 -35
  402. data/lib/karafka/web/pro/ui/views/explorer/topic/_details.erb +0 -23
  403. data/lib/karafka/web/pro/ui/views/health/_consumer_group_header.erb +0 -14
  404. data/lib/karafka/web/ui/controllers/responses/deny.rb +0 -15
  405. data/lib/karafka/web/ui/helpers/alerts_helper.rb +0 -23
  406. data/lib/karafka/web/ui/lib/safe_runner.rb +0 -59
  407. data/lib/karafka/web/ui/models/visibility_filter.rb +0 -49
  408. data/lib/karafka/web/ui/public/javascripts/libs/bootstrap.min.js +0 -6
  409. data/lib/karafka/web/ui/public/javascripts/tabs_manager.js +0 -57
  410. data/lib/karafka/web/ui/public/stylesheets/libs/bootstrap.min.css +0 -6
  411. data/lib/karafka/web/ui/views/consumers/_counters.erb +0 -62
  412. data/lib/karafka/web/ui/views/errors/_watermark_offsets.erb +0 -10
  413. data/lib/karafka/web/ui/views/shared/_feature_pro.erb +0 -4
  414. data/lib/karafka/web/ui/views/shared/_footer.erb +0 -22
  415. data/lib/karafka/web/ui/views/shared/_live_poll.erb +0 -7
  416. /data/lib/karafka/web/management/migrations/{0_base.rb → base.rb} +0 -0
  417. /data/lib/karafka/web/ui/public/javascripts/{charts.js → components/charts.js} +0 -0
  418. /data/lib/karafka/web/ui/public/stylesheets/libs/{highlight.min.css → highlight_light.min.css} +0 -0
@@ -43,7 +43,7 @@ module Karafka
43
43
  # @note We cannot use offset references here because each of the partitions may have
44
44
  # completely different values
45
45
  def topic(topic_id)
46
- @visibility_filter = ::Karafka::Web.config.ui.visibility.filter
46
+ @visibility_filter = ::Karafka::Web.config.ui.policies.messages
47
47
 
48
48
  @topic_id = topic_id
49
49
  @partitions_count = Models::ClusterInfo.partitions_count(topic_id)
@@ -66,7 +66,7 @@ module Karafka
66
66
  # @param topic_id [String]
67
67
  # @param partition_id [Integer]
68
68
  def partition(topic_id, partition_id)
69
- @visibility_filter = ::Karafka::Web.config.ui.visibility.filter
69
+ @visibility_filter = ::Karafka::Web.config.ui.policies.messages
70
70
  @topic_id = topic_id
71
71
  @partition_id = partition_id
72
72
  @watermark_offsets = Models::WatermarkOffsets.find(topic_id, partition_id)
@@ -94,23 +94,15 @@ module Karafka
94
94
  def show(topic_id, partition_id, offset, paginate: true)
95
95
  Lib::PatternsDetector.new.call
96
96
 
97
- @visibility_filter = ::Karafka::Web.config.ui.visibility.filter
97
+ @visibility_filter = ::Karafka::Web.config.ui.policies.messages
98
98
  @topic_id = topic_id
99
99
  @partition_id = partition_id
100
100
  @offset = offset
101
101
  @message = Models::Message.find(@topic_id, @partition_id, @offset)
102
102
 
103
- @safe_payload = Web::Ui::Lib::SafeRunner.new do
104
- JSON.pretty_generate(@message.payload)
105
- end
106
-
107
- @safe_key = Web::Ui::Lib::SafeRunner.new do
108
- @message.key
109
- end
110
-
111
- @safe_headers = Web::Ui::Lib::SafeRunner.new do
112
- @message.headers
113
- end
103
+ @safe_key = Web::Pro::Ui::Lib::SafeRunner.new { @message.key }.tap(&:call)
104
+ @safe_headers = Web::Pro::Ui::Lib::SafeRunner.new { @message.headers }.tap(&:call)
105
+ @safe_payload = Web::Pro::Ui::Lib::SafeRunner.new { @message.payload }.tap(&:call)
114
106
 
115
107
  # This may be off for certain views like recent view where we are interested only
116
108
  # in the most recent all the time. It does not make any sense to display pagination
@@ -28,6 +28,8 @@ module Karafka
28
28
  def republish(topic_id, partition_id, offset)
29
29
  message = Models::Message.find(topic_id, partition_id, offset)
30
30
 
31
+ deny! unless visibility_filter.republish?(message)
32
+
31
33
  delivery = ::Karafka::Web.producer.produce_sync(
32
34
  topic: topic_id,
33
35
  partition: partition_id,
@@ -50,8 +52,7 @@ module Karafka
50
52
  def download(topic_id, partition_id, offset)
51
53
  message = Models::Message.find(topic_id, partition_id, offset)
52
54
 
53
- # Check if downloads are allowed
54
- return deny unless visibility_filter.download?(message)
55
+ deny! unless visibility_filter.download?(message)
55
56
 
56
57
  file(
57
58
  message.raw_payload,
@@ -73,7 +74,7 @@ module Karafka
73
74
  message = Models::Message.find(topic_id, partition_id, offset)
74
75
 
75
76
  # Check if exports are allowed
76
- return deny unless visibility_filter.export?(message)
77
+ deny! unless visibility_filter.export?(message)
77
78
 
78
79
  file(
79
80
  message.payload.to_json,
@@ -96,7 +97,7 @@ module Karafka
96
97
 
97
98
  # @return [Object] visibility filter. Either default or user-based
98
99
  def visibility_filter
99
- ::Karafka::Web.config.ui.visibility.filter
100
+ ::Karafka::Web.config.ui.policies.messages
100
101
  end
101
102
  end
102
103
  end
@@ -0,0 +1,73 @@
1
+ # frozen_string_literal: true
2
+
3
+ # This Karafka component is a Pro component under a commercial license.
4
+ # This Karafka component is NOT licensed under LGPL.
5
+ #
6
+ # All of the commercial components are present in the lib/karafka/pro directory of this
7
+ # repository and their usage requires commercial license agreement.
8
+ #
9
+ # Karafka has also commercial-friendly license, commercial support and commercial components.
10
+ #
11
+ # By sending a pull request to the pro components, you are agreeing to transfer the copyright of
12
+ # your code to Maciej Mensfeld.
13
+
14
+ module Karafka
15
+ module Web
16
+ module Pro
17
+ module Ui
18
+ module Controllers
19
+ # Handles the search requests
20
+ # We present this as a part of explorer scope but we use a separate controller not to
21
+ # mix data exploring with searching.
22
+ class SearchController < Web::Ui::Controllers::ClusterController
23
+ # Runs the search if search parameters are provided
24
+ # If no parameters provided, displays the search modal and info to provide search data
25
+ # If invalid search parameters provided, modal contains errors
26
+ #
27
+ # @param topic_id [String] topic we're interested in
28
+ # @note In theory search can be used to detect pieces of information within messages.
29
+ # Since we allow for custom search strategies, this is not an issue because users
30
+ # that need to provide only granular search can do so.
31
+ def index(topic_id)
32
+ @topic_id = topic_id
33
+ @partitions_count = Models::ClusterInfo.partitions_count(topic_id)
34
+ # Select only matchers that should be available in the context of the current topic
35
+ @matchers = Web.config.ui.search.matchers.select { |match| match.active?(@topic_id) }
36
+ @search_criteria = !@params.current_search.empty?
37
+ @current_search = Lib::Search::Normalizer.call(@params.current_search)
38
+ # Needed when rendering found messages rows. We should always filter the messages
39
+ # details with the visibility filter
40
+ @visibility_filter = ::Karafka::Web.config.ui.policies.messages
41
+ @limits = ::Karafka::Web.config.ui.search.limits.sort
42
+
43
+ # If there is search form filled, we validate it to make sure there are no errors
44
+ @errors = if @search_criteria
45
+ Lib::Search::Contracts::Form.new.call(@current_search).errors
46
+ else
47
+ {}
48
+ end
49
+
50
+ # If all good we run the search
51
+ if @search_criteria && @errors.empty?
52
+ found, @search_details = Lib::Search::Runner.new(
53
+ @topic_id,
54
+ @partitions_count,
55
+ @current_search
56
+ ).call
57
+
58
+ @messages, last_page = Paginators::Arrays.call(
59
+ found,
60
+ @params.current_page
61
+ )
62
+
63
+ paginate(@params.current_page, !last_page)
64
+ end
65
+
66
+ render
67
+ end
68
+ end
69
+ end
70
+ end
71
+ end
72
+ end
73
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ # This Karafka component is a Pro component under a commercial license.
4
+ # This Karafka component is NOT licensed under LGPL.
5
+ #
6
+ # All of the commercial components are present in the lib/karafka/pro directory of this
7
+ # repository and their usage requires commercial license agreement.
8
+ #
9
+ # Karafka has also commercial-friendly license, commercial support and commercial components.
10
+ #
11
+ # By sending a pull request to the pro components, you are agreeing to transfer the copyright of
12
+ # your code to Maciej Mensfeld.
13
+
14
+ module Karafka
15
+ module Web
16
+ module Pro
17
+ module Ui
18
+ module Controllers
19
+ # Support details - same as in OSS
20
+ class SupportController < Web::Ui::Controllers::SupportController
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -33,6 +33,8 @@ module Karafka
33
33
  count
34
34
  share
35
35
  diff
36
+ low
37
+ high
36
38
  ].freeze
37
39
 
38
40
  # Lists available topics in the cluster
@@ -91,6 +93,35 @@ module Karafka
91
93
 
92
94
  render
93
95
  end
96
+
97
+ # Displays high and low offsets for given topic
98
+ #
99
+ # @param topic_name [String] topic we're interested in
100
+ def offsets(topic_name)
101
+ @topic = Models::Topic.find(topic_name)
102
+
103
+ @active_partitions, _materialized_page, @limited = Paginators::Partitions.call(
104
+ @topic.partition_count, @params.current_page
105
+ )
106
+
107
+ offsets = @active_partitions.map do |partition_id|
108
+ part_offsets = Admin.read_watermark_offsets(topic_name, partition_id)
109
+
110
+ {
111
+ partition_id: partition_id,
112
+ low: part_offsets.first,
113
+ high: part_offsets.last,
114
+ diff: part_offsets.last - part_offsets.first
115
+ }
116
+ end
117
+
118
+ @offsets = refine(offsets)
119
+
120
+ next_page = @active_partitions.last < @topic.partition_count - 1
121
+ paginate(@params.current_page, next_page)
122
+
123
+ render
124
+ end
94
125
  end
95
126
  end
96
127
  end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ # This Karafka component is a Pro component under a commercial license.
4
+ # This Karafka component is NOT licensed under LGPL.
5
+ #
6
+ # All of the commercial components are present in the lib/karafka/pro directory of this
7
+ # repository and their usage requires commercial license agreement.
8
+ #
9
+ # Karafka has also commercial-friendly license, commercial support and commercial components.
10
+ #
11
+ # By sending a pull request to the pro components, you are agreeing to transfer the copyright of
12
+ # your code to Maciej Mensfeld.
13
+
14
+ module Karafka
15
+ module Web
16
+ module Pro
17
+ module Ui
18
+ module Controllers
19
+ # Ux details - same as in OSS
20
+ class UxController < Web::Ui::Controllers::UxController
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ # This Karafka component is a Pro component under a commercial license.
4
+ # This Karafka component is NOT licensed under LGPL.
5
+ #
6
+ # All of the commercial components are present in the lib/karafka/pro directory of this
7
+ # repository and their usage requires commercial license agreement.
8
+ #
9
+ # Karafka has also commercial-friendly license, commercial support and commercial components.
10
+ #
11
+ # By sending a pull request to the pro components, you are agreeing to transfer the copyright of
12
+ # your code to Maciej Mensfeld.
13
+
14
+ module Karafka
15
+ module Web
16
+ module Pro
17
+ module Ui
18
+ module Lib
19
+ module Policies
20
+ # Extra configuration for pro UI
21
+ class Config
22
+ extend ::Karafka::Core::Configurable
23
+
24
+ # Policies controller related to messages operations and visibility
25
+ setting :messages, default: Policies::Messages.new
26
+
27
+ # Policies controller related to all requests. It is a general one that is not
28
+ # granular but can be used to block completely certain pieces of the UI from
29
+ # accessing like explorer or any other as operates on the raw env level
30
+ setting :requests, default: Policies::Requests.new
31
+
32
+ configure
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ # This Karafka component is a Pro component under a commercial license.
4
+ # This Karafka component is NOT licensed under LGPL.
5
+ #
6
+ # All of the commercial components are present in the lib/karafka/pro directory of this
7
+ # repository and their usage requires commercial license agreement.
8
+ #
9
+ # Karafka has also commercial-friendly license, commercial support and commercial components.
10
+ #
11
+ # By sending a pull request to the pro components, you are agreeing to transfer the copyright of
12
+ # your code to Maciej Mensfeld.
13
+
14
+ module Karafka
15
+ module Web
16
+ module Pro
17
+ module Ui
18
+ module Lib
19
+ # Policies related contracts
20
+ module Policies
21
+ # Namespace with policies related contracts
22
+ module Contracts
23
+ # Makes sure, all the expected UI policies config is defined as it should be
24
+ class Config < ::Karafka::Contracts::Base
25
+ configure do |config|
26
+ config.error_messages = YAML.safe_load(
27
+ File.read(
28
+ File.join(Karafka::Web.gem_root, 'config', 'locales', 'pro_errors.yml')
29
+ )
30
+ ).fetch('en').fetch('validations').fetch('config')
31
+ end
32
+
33
+ nested(:ui) do
34
+ nested(:policies) do
35
+ required(:messages) { |val| !val.nil? }
36
+ required(:requests) { |val| !val.nil? }
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,76 @@
1
+ # frozen_string_literal: true
2
+
3
+ # This Karafka component is a Pro component under a commercial license.
4
+ # This Karafka component is NOT licensed under LGPL.
5
+ #
6
+ # All of the commercial components are present in the lib/karafka/pro directory of this
7
+ # repository and their usage requires commercial license agreement.
8
+ #
9
+ # Karafka has also commercial-friendly license, commercial support and commercial components.
10
+ #
11
+ # By sending a pull request to the pro components, you are agreeing to transfer the copyright of
12
+ # your code to Maciej Mensfeld.
13
+
14
+ module Karafka
15
+ module Web
16
+ module Pro
17
+ module Ui
18
+ module Lib
19
+ module Policies
20
+ # Allows for a granular control over what parts of messages are being displayed and
21
+ # operated on.
22
+ # There are scenarios where payload or other parts of messages should not be presented
23
+ # because they may contain sensitive data. This API allows to manage that on a per
24
+ # message basis.
25
+ class Messages
26
+ # @param _message [::Karafka::Messages::Message]
27
+ # @return [Boolean] should message key be visible
28
+ def key?(_message)
29
+ true
30
+ end
31
+
32
+ # @param _message [::Karafka::Messages::Message]
33
+ # @return [Boolean] should message headers be visible
34
+ def headers?(_message)
35
+ true
36
+ end
37
+
38
+ # @param message [::Karafka::Messages::Message]
39
+ # @return [Boolean] should message payload be visible
40
+ def payload?(message)
41
+ !message.headers.key?('encryption')
42
+ end
43
+
44
+ # Should it be allowed to download this message raw payload
45
+ #
46
+ # @param message [::Karafka::Messages::Message]
47
+ # @return [Boolean] true if downloads allowed
48
+ def download?(message)
49
+ payload?(message)
50
+ end
51
+
52
+ # Should it be allowed to download the deserialized and sanitized payload as JSON
53
+ #
54
+ # @param message [::Karafka::Messages::Message]
55
+ # @return [Boolean] true if exports allowed
56
+ def export?(message)
57
+ payload?(message)
58
+ end
59
+
60
+ # Should we allow to republish given message
61
+ #
62
+ # @param _message [::Karafka::Messages::Message]
63
+ # @return [Boolean] true if we should allow republishing
64
+ # @note This is a simple API that does not provide granular republishing support.
65
+ # You can decide whether to allow for republishing but you cannot say "allow only
66
+ # to X", etc.
67
+ def republish?(_message)
68
+ true
69
+ end
70
+ end
71
+ end
72
+ end
73
+ end
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ # This Karafka component is a Pro component under a commercial license.
4
+ # This Karafka component is NOT licensed under LGPL.
5
+ #
6
+ # All of the commercial components are present in the lib/karafka/pro directory of this
7
+ # repository and their usage requires commercial license agreement.
8
+ #
9
+ # Karafka has also commercial-friendly license, commercial support and commercial components.
10
+ #
11
+ # By sending a pull request to the pro components, you are agreeing to transfer the copyright of
12
+ # your code to Maciej Mensfeld.
13
+
14
+ module Karafka
15
+ module Web
16
+ module Pro
17
+ module Ui
18
+ module Lib
19
+ module Policies
20
+ # Per request policies setup class. Allows for writing low level policies that can
21
+ # be used to block certain Web UI functionalities on the request level.
22
+ class Requests
23
+ # @param _env [Hash] rack env object that we can use to get request details
24
+ # @return [Boolean] should this request be allowed or not
25
+ # @note By default we do not limit anything in the Web UI, however particular
26
+ # granular policies may limit things on their own.
27
+ def allow?(_env)
28
+ true
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ # This Karafka component is a Pro component under a commercial license.
4
+ # This Karafka component is NOT licensed under LGPL.
5
+ #
6
+ # All of the commercial components are present in the lib/karafka/pro directory of this
7
+ # repository and their usage requires commercial license agreement.
8
+ #
9
+ # Karafka has also commercial-friendly license, commercial support and commercial components.
10
+ #
11
+ # By sending a pull request to the pro components, you are agreeing to transfer the copyright of
12
+ # your code to Maciej Mensfeld.
13
+
14
+ module Karafka
15
+ module Web
16
+ module Pro
17
+ module Ui
18
+ module Lib
19
+ # All code needed to support the search functionality
20
+ module Policies
21
+ class << self
22
+ # Validates that the UI policies config is correct
23
+ #
24
+ # @param config [Karafka::Core::Configurable::Node] web config
25
+ def post_setup(config)
26
+ Policies::Contracts::Config.new.validate!(config.to_h)
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,98 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Karafka
4
+ module Web
5
+ module Pro
6
+ module Ui
7
+ module Lib
8
+ # Class used to execute code that can fail but we do not want to fail the whole
9
+ # operation. The primary use-case is for displaying deserialized data. We always need to
10
+ # assume, that part of the data can be corrupted and it should not crash the whole UI.
11
+ #
12
+ # It caches the result and does not run the code twice (only once). Additionally, it
13
+ # measures the CPU usage and total time during the execution of the code block.
14
+ class SafeRunner
15
+ include Karafka::Core::Helpers::Time
16
+
17
+ attr_reader :error, :result, :cpu_time, :total_time, :allocations
18
+
19
+ # @param block [Proc] code we want to safe-guard
20
+ def initialize(&block)
21
+ @code = block
22
+ @executed = false
23
+ @success = false
24
+ @error = nil
25
+ @result = nil
26
+ @cpu_time = 0
27
+ @total_time = 0
28
+ @allocations = false
29
+ end
30
+
31
+ # @return [Boolean] was the code execution successful or not
32
+ def success?
33
+ return @success if executed?
34
+
35
+ call
36
+
37
+ @success
38
+ end
39
+
40
+ # @return [Boolean] was the code execution failed or not
41
+ def failure?
42
+ !success?
43
+ end
44
+
45
+ # Runs the execution and returns block result
46
+ def call
47
+ return @result if executed?
48
+
49
+ @executed = true
50
+
51
+ if objspace?
52
+ ObjectSpace.trace_object_allocations_start
53
+ before = ObjectSpace.each_object.count
54
+ end
55
+
56
+ # We measure time as close to the process as possible so it is not impacted by the
57
+ # objects allocations count (if applicable)
58
+ start_time = monotonic_now
59
+ start_cpu = ::Process.times
60
+ @result = @code.call
61
+ @success = true
62
+
63
+ @result
64
+ rescue StandardError => e
65
+ @error = e
66
+ @success = false
67
+ ensure
68
+ end_time = monotonic_now
69
+ end_cpu = ::Process.times
70
+
71
+ @cpu_time = (
72
+ (end_cpu.utime - start_cpu.utime) + (end_cpu.stime - start_cpu.stime)
73
+ ) * 1_000
74
+ @total_time = (end_time - start_time)
75
+
76
+ if objspace?
77
+ @allocations = ObjectSpace.each_object.count - before
78
+ ObjectSpace.trace_object_allocations_stop
79
+ end
80
+ end
81
+
82
+ # @return [Boolean] was the code executed already or not yet
83
+ def executed?
84
+ @executed
85
+ end
86
+
87
+ private
88
+
89
+ # @return [Boolean] true if tracing is available
90
+ def objspace?
91
+ ObjectSpace.respond_to?(:trace_object_allocations_start)
92
+ end
93
+ end
94
+ end
95
+ end
96
+ end
97
+ end
98
+ end
@@ -0,0 +1,53 @@
1
+ # frozen_string_literal: true
2
+
3
+ # This Karafka component is a Pro component under a commercial license.
4
+ # This Karafka component is NOT licensed under LGPL.
5
+ #
6
+ # All of the commercial components are present in the lib/karafka/pro directory of this
7
+ # repository and their usage requires commercial license agreement.
8
+ #
9
+ # Karafka has also commercial-friendly license, commercial support and commercial components.
10
+ #
11
+ # By sending a pull request to the pro components, you are agreeing to transfer the copyright of
12
+ # your code to Maciej Mensfeld.
13
+
14
+ module Karafka
15
+ module Web
16
+ module Pro
17
+ module Ui
18
+ module Lib
19
+ module Search
20
+ # Extra configuration for pro UI
21
+ class Config
22
+ extend ::Karafka::Core::Configurable
23
+
24
+ # Matches for messages
25
+ setting :matchers, default: [
26
+ Matchers::RawPayloadIncludes,
27
+ Matchers::RawKeyIncludes,
28
+ Matchers::RawHeaderIncludes
29
+ ]
30
+
31
+ # How long should we at most search before stopping (in ms)
32
+ # This prevents us from having a search that would basically hang the browser and
33
+ # never finish
34
+ setting :timeout, default: 30_000
35
+
36
+ # Search limits as the search runs in Puma
37
+ # Too big value will make the scan really slow
38
+ # We do not put a max limit here because those values are used in a select in
39
+ # the Web UI.
40
+ setting :limits, default: [
41
+ 1_000,
42
+ 10_000,
43
+ 100_000
44
+ ]
45
+
46
+ configure
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end