wurk 1.14.0 → 1.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/app/controllers/concerns/wurk/same_origin_guard.rb +30 -8
- data/app/controllers/wurk/api/pagination.rb +70 -53
- data/app/controllers/wurk/api_controller.rb +96 -27
- data/app/controllers/wurk/dashboard_controller.rb +26 -2
- data/app/controllers/wurk/profiles_controller.rb +28 -23
- data/config/routes.rb +8 -6
- data/lib/wurk/api/admin.rb +84 -0
- data/lib/wurk/api/app.rb +7 -2
- data/lib/wurk/api/jobs.rb +11 -3
- data/lib/wurk/api/queues.rb +10 -0
- data/lib/wurk/api/router.rb +6 -0
- data/lib/wurk/api/validation.rb +17 -0
- data/lib/wurk/batch/callbacks.rb +9 -2
- data/lib/wurk/batch.rb +15 -4
- data/lib/wurk/batch_set.rb +22 -0
- data/lib/wurk/cli.rb +4 -2
- data/lib/wurk/client/buffered.rb +104 -48
- data/lib/wurk/configuration.rb +28 -0
- data/lib/wurk/fetcher/many_queues.rb +18 -8
- data/lib/wurk/fetcher/poison_pill.rb +2 -0
- data/lib/wurk/fetcher/reaper.rb +3 -0
- data/lib/wurk/fetcher/reliable.rb +26 -12
- data/lib/wurk/health.rb +6 -1
- data/lib/wurk/health_probe.rb +45 -7
- data/lib/wurk/heartbeat.rb +29 -6
- data/lib/wurk/job_set.rb +25 -3
- data/lib/wurk/leader.rb +2 -0
- data/lib/wurk/metrics/accumulator.rb +27 -2
- data/lib/wurk/metrics/exposition.rb +45 -0
- data/lib/wurk/metrics/history.rb +10 -5
- data/lib/wurk/metrics/pool_registry.rb +27 -0
- data/lib/wurk/metrics/process_counters.rb +16 -0
- data/lib/wurk/metrics/process_families.rb +115 -0
- data/lib/wurk/metrics/prometheus.rb +84 -51
- data/lib/wurk/redis_pool.rb +6 -1
- data/lib/wurk/scheduled.rb +7 -0
- data/lib/wurk/swarm/child_boot.rb +6 -1
- data/lib/wurk/swarm/crash_watch.rb +5 -0
- data/lib/wurk/swarm/memory_watch.rb +1 -7
- data/lib/wurk/swarm/restart.rb +14 -5
- data/lib/wurk/swarm/restart_counters.rb +79 -0
- data/lib/wurk/swarm.rb +14 -6
- data/lib/wurk/version.rb +1 -1
- data/lib/wurk.rb +2 -1
- data/vendor/assets/dashboard/assets/{ArgsValue-BSTICTw4.js → ArgsValue-D10BT0xi.js} +1 -1
- data/vendor/assets/dashboard/assets/ArgsValue-D10BT0xi.js.br +0 -0
- data/vendor/assets/dashboard/assets/ArgsValue-D10BT0xi.js.gz +0 -0
- data/vendor/assets/dashboard/assets/{BatchDetail-BBMiNTok.js → BatchDetail-ByPRHv86.js} +1 -1
- data/vendor/assets/dashboard/assets/BatchDetail-ByPRHv86.js.br +0 -0
- data/vendor/assets/dashboard/assets/BatchDetail-ByPRHv86.js.gz +0 -0
- data/vendor/assets/dashboard/assets/Batches-CVVOJFhz.js +1 -0
- data/vendor/assets/dashboard/assets/Batches-CVVOJFhz.js.br +0 -0
- data/vendor/assets/dashboard/assets/Batches-CVVOJFhz.js.gz +0 -0
- data/vendor/assets/dashboard/assets/{Busy-CcSvIQFY.js → Busy-Dp26yz1A.js} +1 -1
- data/vendor/assets/dashboard/assets/Busy-Dp26yz1A.js.br +0 -0
- data/vendor/assets/dashboard/assets/Busy-Dp26yz1A.js.gz +0 -0
- data/vendor/assets/dashboard/assets/{Cron-ByRxtItH.js → Cron-BiRV6eoU.js} +1 -1
- data/vendor/assets/dashboard/assets/Cron-BiRV6eoU.js.br +0 -0
- data/vendor/assets/dashboard/assets/Cron-BiRV6eoU.js.gz +0 -0
- data/vendor/assets/dashboard/assets/Dashboard-CnpCQ8Of.js +1 -0
- data/vendor/assets/dashboard/assets/Dashboard-CnpCQ8Of.js.br +0 -0
- data/vendor/assets/dashboard/assets/Dashboard-CnpCQ8Of.js.gz +0 -0
- data/vendor/assets/dashboard/assets/Dead-ykYbsK8n.js +1 -0
- data/vendor/assets/dashboard/assets/Dead-ykYbsK8n.js.br +0 -0
- data/vendor/assets/dashboard/assets/Dead-ykYbsK8n.js.gz +0 -0
- data/vendor/assets/dashboard/assets/{Extension--fRIfdcW.js → Extension-BUsciXhN.js} +1 -1
- data/vendor/assets/dashboard/assets/Extension-BUsciXhN.js.br +0 -0
- data/vendor/assets/dashboard/assets/Extension-BUsciXhN.js.gz +0 -0
- data/vendor/assets/dashboard/assets/FilterBox-DBIZXNtY.js +1 -0
- data/vendor/assets/dashboard/assets/FilterBox-DBIZXNtY.js.br +0 -0
- data/vendor/assets/dashboard/assets/FilterBox-DBIZXNtY.js.gz +0 -0
- data/vendor/assets/dashboard/assets/{FlowDetail-CxmWxNpF.js → FlowDetail-CIGu7pRb.js} +1 -1
- data/vendor/assets/dashboard/assets/FlowDetail-CIGu7pRb.js.br +0 -0
- data/vendor/assets/dashboard/assets/FlowDetail-CIGu7pRb.js.gz +0 -0
- data/vendor/assets/dashboard/assets/{FlowState-ClzInw0-.js → FlowState-B04ZLDe-.js} +1 -1
- data/vendor/assets/dashboard/assets/FlowState-B04ZLDe-.js.br +0 -0
- data/vendor/assets/dashboard/assets/FlowState-B04ZLDe-.js.gz +0 -0
- data/vendor/assets/dashboard/assets/{Flows-CCnTVfkN.js → Flows-Ce9Qoq0c.js} +1 -1
- data/vendor/assets/dashboard/assets/Flows-Ce9Qoq0c.js.br +0 -0
- data/vendor/assets/dashboard/assets/Flows-Ce9Qoq0c.js.gz +0 -0
- data/vendor/assets/dashboard/assets/{JobDetailModal-Btzt9HOQ.js → JobDetailModal-DWp0OMoV.js} +1 -1
- data/vendor/assets/dashboard/assets/JobDetailModal-DWp0OMoV.js.br +0 -0
- data/vendor/assets/dashboard/assets/JobDetailModal-DWp0OMoV.js.gz +0 -0
- data/vendor/assets/dashboard/assets/{Limiters-DYxSN0sy.js → Limiters-DiWCiVay.js} +1 -1
- data/vendor/assets/dashboard/assets/Limiters-DiWCiVay.js.br +0 -0
- data/vendor/assets/dashboard/assets/Limiters-DiWCiVay.js.gz +0 -0
- data/vendor/assets/dashboard/assets/{Metrics-BfSRkQ2U.js → Metrics-DmMS2wo_.js} +1 -1
- data/vendor/assets/dashboard/assets/Metrics-DmMS2wo_.js.br +0 -0
- data/vendor/assets/dashboard/assets/Metrics-DmMS2wo_.js.gz +0 -0
- data/vendor/assets/dashboard/assets/{NotFound-DrAE8U92.js → NotFound-CM1j8-Fv.js} +1 -1
- data/vendor/assets/dashboard/assets/NotFound-CM1j8-Fv.js.br +0 -0
- data/vendor/assets/dashboard/assets/NotFound-CM1j8-Fv.js.gz +0 -0
- data/vendor/assets/dashboard/assets/{PageHeader-w3hA_hMm.js → PageHeader-BcHVxRbX.js} +1 -1
- data/vendor/assets/dashboard/assets/PageHeader-BcHVxRbX.js.br +0 -0
- data/vendor/assets/dashboard/assets/PageHeader-BcHVxRbX.js.gz +0 -0
- data/vendor/assets/dashboard/assets/Profiles-B70MlVYQ.js +1 -0
- data/vendor/assets/dashboard/assets/Profiles-B70MlVYQ.js.br +0 -0
- data/vendor/assets/dashboard/assets/Profiles-B70MlVYQ.js.gz +0 -0
- data/vendor/assets/dashboard/assets/Queues-D3JZtWBv.js +1 -0
- data/vendor/assets/dashboard/assets/Queues-D3JZtWBv.js.br +0 -0
- data/vendor/assets/dashboard/assets/Queues-D3JZtWBv.js.gz +0 -0
- data/vendor/assets/dashboard/assets/Retries-BTWoV6so.js +1 -0
- data/vendor/assets/dashboard/assets/Retries-BTWoV6so.js.br +0 -0
- data/vendor/assets/dashboard/assets/Retries-BTWoV6so.js.gz +0 -0
- data/vendor/assets/dashboard/assets/Scheduled-D3PyiFqr.js +1 -0
- data/vendor/assets/dashboard/assets/Scheduled-D3PyiFqr.js.br +0 -0
- data/vendor/assets/dashboard/assets/Scheduled-D3PyiFqr.js.gz +0 -0
- data/vendor/assets/dashboard/assets/{Search-D42Va7lB.js → Search-bLwIhsaR.js} +1 -1
- data/vendor/assets/dashboard/assets/Search-bLwIhsaR.js.br +0 -0
- data/vendor/assets/dashboard/assets/Search-bLwIhsaR.js.gz +0 -0
- data/vendor/assets/dashboard/assets/ar-CugpXGea.js +1 -0
- data/vendor/assets/dashboard/assets/ar-CugpXGea.js.br +0 -0
- data/vendor/assets/dashboard/assets/ar-CugpXGea.js.gz +0 -0
- data/vendor/assets/dashboard/assets/{charts-C1xMUYFp.js → charts-DZyiygHX.js} +1 -1
- data/vendor/assets/dashboard/assets/charts-DZyiygHX.js.br +0 -0
- data/vendor/assets/dashboard/assets/charts-DZyiygHX.js.gz +0 -0
- data/vendor/assets/dashboard/assets/de-Bl5Jn_0l.js +1 -0
- data/vendor/assets/dashboard/assets/de-Bl5Jn_0l.js.br +0 -0
- data/vendor/assets/dashboard/assets/de-Bl5Jn_0l.js.gz +0 -0
- data/vendor/assets/dashboard/assets/es-lqQrmjYI.js +1 -0
- data/vendor/assets/dashboard/assets/es-lqQrmjYI.js.br +0 -0
- data/vendor/assets/dashboard/assets/es-lqQrmjYI.js.gz +0 -0
- data/vendor/assets/dashboard/assets/fr-D70VBoh3.js +1 -0
- data/vendor/assets/dashboard/assets/fr-D70VBoh3.js.br +0 -0
- data/vendor/assets/dashboard/assets/fr-D70VBoh3.js.gz +0 -0
- data/vendor/assets/dashboard/assets/{i18n-BXp3XejR.js → i18n-DdPClaCG.js} +1 -1
- data/vendor/assets/dashboard/assets/i18n-DdPClaCG.js.br +0 -0
- data/vendor/assets/dashboard/assets/i18n-DdPClaCG.js.gz +0 -0
- data/vendor/assets/dashboard/assets/index-CtK2Dy_G.css +1 -0
- data/vendor/assets/dashboard/assets/index-CtK2Dy_G.css.br +0 -0
- data/vendor/assets/dashboard/assets/index-CtK2Dy_G.css.gz +0 -0
- data/vendor/assets/dashboard/assets/{index-CiLU1zz8.js → index-ygQ-XC-L.js} +3 -3
- data/vendor/assets/dashboard/assets/index-ygQ-XC-L.js.br +0 -0
- data/vendor/assets/dashboard/assets/index-ygQ-XC-L.js.gz +0 -0
- data/vendor/assets/dashboard/assets/ja-BYMqnHjg.js +1 -0
- data/vendor/assets/dashboard/assets/ja-BYMqnHjg.js.br +0 -0
- data/vendor/assets/dashboard/assets/ja-BYMqnHjg.js.gz +0 -0
- data/vendor/assets/dashboard/assets/pt-BR-4k5M2MYH.js +1 -0
- data/vendor/assets/dashboard/assets/pt-BR-4k5M2MYH.js.br +0 -0
- data/vendor/assets/dashboard/assets/pt-BR-4k5M2MYH.js.gz +0 -0
- data/vendor/assets/dashboard/assets/useJobSetList-D-uafkUL.js +2 -0
- data/vendor/assets/dashboard/assets/useJobSetList-D-uafkUL.js.br +0 -0
- data/vendor/assets/dashboard/assets/useJobSetList-D-uafkUL.js.gz +0 -0
- data/vendor/assets/dashboard/assets/{useResetPageOnEmpty-Cuv4BHkC.js → useResetPageOnEmpty-DUA0JTgs.js} +1 -1
- data/vendor/assets/dashboard/assets/useResetPageOnEmpty-DUA0JTgs.js.br +0 -0
- data/vendor/assets/dashboard/assets/useResetPageOnEmpty-DUA0JTgs.js.gz +0 -0
- data/vendor/assets/dashboard/assets/{useSort-V9yUrByY.js → useSort-BwoC7g__.js} +1 -1
- data/vendor/assets/dashboard/assets/useSort-BwoC7g__.js.br +0 -0
- data/vendor/assets/dashboard/assets/useSort-BwoC7g__.js.gz +0 -0
- data/vendor/assets/dashboard/assets/{utils-69XSoGbQ.js → utils-CQj4rqng.js} +1 -1
- data/vendor/assets/dashboard/assets/utils-CQj4rqng.js.br +0 -0
- data/vendor/assets/dashboard/assets/utils-CQj4rqng.js.gz +0 -0
- data/vendor/assets/dashboard/assets/zh-CN-B9E1MvsM.js +1 -0
- data/vendor/assets/dashboard/assets/zh-CN-B9E1MvsM.js.br +0 -0
- data/vendor/assets/dashboard/assets/zh-CN-B9E1MvsM.js.gz +0 -0
- data/vendor/assets/dashboard/index.html +8 -8
- data/vendor/assets/dashboard/wurk-manifest.json +2 -2
- metadata +117 -109
- data/vendor/assets/dashboard/assets/ArgsValue-BSTICTw4.js.br +0 -0
- data/vendor/assets/dashboard/assets/ArgsValue-BSTICTw4.js.gz +0 -0
- data/vendor/assets/dashboard/assets/BatchDetail-BBMiNTok.js.br +0 -0
- data/vendor/assets/dashboard/assets/BatchDetail-BBMiNTok.js.gz +0 -0
- data/vendor/assets/dashboard/assets/Batches-D8I3hCXy.js +0 -1
- data/vendor/assets/dashboard/assets/Batches-D8I3hCXy.js.br +0 -0
- data/vendor/assets/dashboard/assets/Batches-D8I3hCXy.js.gz +0 -0
- data/vendor/assets/dashboard/assets/Busy-CcSvIQFY.js.br +0 -0
- data/vendor/assets/dashboard/assets/Busy-CcSvIQFY.js.gz +0 -0
- data/vendor/assets/dashboard/assets/Cron-ByRxtItH.js.br +0 -0
- data/vendor/assets/dashboard/assets/Cron-ByRxtItH.js.gz +0 -0
- data/vendor/assets/dashboard/assets/Dashboard-CO7_6OUM.js +0 -1
- data/vendor/assets/dashboard/assets/Dashboard-CO7_6OUM.js.br +0 -0
- data/vendor/assets/dashboard/assets/Dashboard-CO7_6OUM.js.gz +0 -0
- data/vendor/assets/dashboard/assets/Dead-C8mDGQAF.js +0 -1
- data/vendor/assets/dashboard/assets/Dead-C8mDGQAF.js.br +0 -0
- data/vendor/assets/dashboard/assets/Dead-C8mDGQAF.js.gz +0 -0
- data/vendor/assets/dashboard/assets/Extension--fRIfdcW.js.br +0 -0
- data/vendor/assets/dashboard/assets/Extension--fRIfdcW.js.gz +0 -0
- data/vendor/assets/dashboard/assets/FilterBox-BS1_G5S5.js +0 -2
- data/vendor/assets/dashboard/assets/FilterBox-BS1_G5S5.js.br +0 -0
- data/vendor/assets/dashboard/assets/FilterBox-BS1_G5S5.js.gz +0 -0
- data/vendor/assets/dashboard/assets/FlowDetail-CxmWxNpF.js.br +0 -0
- data/vendor/assets/dashboard/assets/FlowDetail-CxmWxNpF.js.gz +0 -0
- data/vendor/assets/dashboard/assets/FlowState-ClzInw0-.js.br +0 -0
- data/vendor/assets/dashboard/assets/FlowState-ClzInw0-.js.gz +0 -0
- data/vendor/assets/dashboard/assets/Flows-CCnTVfkN.js.br +0 -0
- data/vendor/assets/dashboard/assets/Flows-CCnTVfkN.js.gz +0 -0
- data/vendor/assets/dashboard/assets/JobDetailModal-Btzt9HOQ.js.br +0 -0
- data/vendor/assets/dashboard/assets/JobDetailModal-Btzt9HOQ.js.gz +0 -0
- data/vendor/assets/dashboard/assets/Limiters-DYxSN0sy.js.br +0 -0
- data/vendor/assets/dashboard/assets/Limiters-DYxSN0sy.js.gz +0 -0
- data/vendor/assets/dashboard/assets/Metrics-BfSRkQ2U.js.br +0 -0
- data/vendor/assets/dashboard/assets/Metrics-BfSRkQ2U.js.gz +0 -0
- data/vendor/assets/dashboard/assets/NotFound-DrAE8U92.js.br +0 -0
- data/vendor/assets/dashboard/assets/NotFound-DrAE8U92.js.gz +0 -0
- data/vendor/assets/dashboard/assets/PageHeader-w3hA_hMm.js.br +0 -0
- data/vendor/assets/dashboard/assets/PageHeader-w3hA_hMm.js.gz +0 -0
- data/vendor/assets/dashboard/assets/Profiles-191Gq7P-.js +0 -1
- data/vendor/assets/dashboard/assets/Profiles-191Gq7P-.js.br +0 -0
- data/vendor/assets/dashboard/assets/Profiles-191Gq7P-.js.gz +0 -0
- data/vendor/assets/dashboard/assets/Queues-CIvl1fjf.js +0 -1
- data/vendor/assets/dashboard/assets/Queues-CIvl1fjf.js.br +0 -0
- data/vendor/assets/dashboard/assets/Queues-CIvl1fjf.js.gz +0 -0
- data/vendor/assets/dashboard/assets/Retries-sdaiHACO.js +0 -1
- data/vendor/assets/dashboard/assets/Retries-sdaiHACO.js.br +0 -0
- data/vendor/assets/dashboard/assets/Retries-sdaiHACO.js.gz +0 -0
- data/vendor/assets/dashboard/assets/Scheduled-CcildKBh.js +0 -1
- data/vendor/assets/dashboard/assets/Scheduled-CcildKBh.js.br +0 -0
- data/vendor/assets/dashboard/assets/Scheduled-CcildKBh.js.gz +0 -0
- data/vendor/assets/dashboard/assets/Search-D42Va7lB.js.br +0 -0
- data/vendor/assets/dashboard/assets/Search-D42Va7lB.js.gz +0 -0
- data/vendor/assets/dashboard/assets/ar-Br6DtdyK.js +0 -1
- data/vendor/assets/dashboard/assets/ar-Br6DtdyK.js.br +0 -0
- data/vendor/assets/dashboard/assets/ar-Br6DtdyK.js.gz +0 -0
- data/vendor/assets/dashboard/assets/charts-C1xMUYFp.js.br +0 -0
- data/vendor/assets/dashboard/assets/charts-C1xMUYFp.js.gz +0 -0
- data/vendor/assets/dashboard/assets/de-B2NCIuzo.js +0 -1
- data/vendor/assets/dashboard/assets/de-B2NCIuzo.js.br +0 -0
- data/vendor/assets/dashboard/assets/de-B2NCIuzo.js.gz +0 -0
- data/vendor/assets/dashboard/assets/es-BGeu_JNB.js +0 -1
- data/vendor/assets/dashboard/assets/es-BGeu_JNB.js.br +0 -0
- data/vendor/assets/dashboard/assets/es-BGeu_JNB.js.gz +0 -0
- data/vendor/assets/dashboard/assets/fr-DQVBWFId.js +0 -1
- data/vendor/assets/dashboard/assets/fr-DQVBWFId.js.br +0 -0
- data/vendor/assets/dashboard/assets/fr-DQVBWFId.js.gz +0 -0
- data/vendor/assets/dashboard/assets/i18n-BXp3XejR.js.br +0 -0
- data/vendor/assets/dashboard/assets/i18n-BXp3XejR.js.gz +0 -0
- data/vendor/assets/dashboard/assets/index-CiLU1zz8.js.br +0 -0
- data/vendor/assets/dashboard/assets/index-CiLU1zz8.js.gz +0 -0
- data/vendor/assets/dashboard/assets/index-r3T9Ugl4.css +0 -1
- data/vendor/assets/dashboard/assets/index-r3T9Ugl4.css.br +0 -0
- data/vendor/assets/dashboard/assets/index-r3T9Ugl4.css.gz +0 -0
- data/vendor/assets/dashboard/assets/ja-D06IBqzL.js +0 -1
- data/vendor/assets/dashboard/assets/ja-D06IBqzL.js.br +0 -0
- data/vendor/assets/dashboard/assets/ja-D06IBqzL.js.gz +0 -0
- data/vendor/assets/dashboard/assets/pt-BR-Dn_okdxf.js +0 -1
- data/vendor/assets/dashboard/assets/pt-BR-Dn_okdxf.js.br +0 -0
- data/vendor/assets/dashboard/assets/pt-BR-Dn_okdxf.js.gz +0 -0
- data/vendor/assets/dashboard/assets/useResetPageOnEmpty-Cuv4BHkC.js.br +0 -0
- data/vendor/assets/dashboard/assets/useResetPageOnEmpty-Cuv4BHkC.js.gz +0 -0
- data/vendor/assets/dashboard/assets/useSort-V9yUrByY.js.br +0 -0
- data/vendor/assets/dashboard/assets/useSort-V9yUrByY.js.gz +0 -0
- data/vendor/assets/dashboard/assets/utils-69XSoGbQ.js.br +0 -0
- data/vendor/assets/dashboard/assets/utils-69XSoGbQ.js.gz +0 -0
- data/vendor/assets/dashboard/assets/zh-CN-B1ObO-uZ.js +0 -1
- data/vendor/assets/dashboard/assets/zh-CN-B1ObO-uZ.js.br +0 -0
- data/vendor/assets/dashboard/assets/zh-CN-B1ObO-uZ.js.gz +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 96bee6b140f21dd1b2fb9d8cf382f6942600a91896dcae3bde52bbcb615fd7ff
|
|
4
|
+
data.tar.gz: 0f0a74b458b2bc9de92759ee0c20a3ffa8ba9ca3fa40dcd891abe07afcb8a3db
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c46917c8d37f35ae24aec5c0f6305a05d1c2d85af050da7dfda1eff8f73f0537898dcc3957849bede6ad3128836fbfd3db1782397771e0d8af36096098948838
|
|
7
|
+
data.tar.gz: 59fd02cb8bbbf4e66b4ffda4e5260c6052ea1b0d7708f069afcdc7d22d88408b0fd72ff65f36958629d4b75cbf85cb2a95ce37a6e76358ff85013e7cbae5e818
|
data/README.md
CHANGED
|
@@ -305,7 +305,7 @@ Wurk is MIT and stays that way. If what you need is a commercial support contrac
|
|
|
305
305
|
|
|
306
306
|
`bundle install && restart`. The worker command stays as it was: Wurk ships `sidekiq` and `sidekiqswarm` executables, so `bundle exec sidekiq -C config/sidekiq.yml` in a Procfile or manifest keeps working. Wurk reads and writes the same Redis schema, so there is no data migration: Wurk picks up the queues, schedules, retries, batches and periodic loops Sidekiq left behind. Running Sidekiq and Wurk workers against one Redis *at the same time* is not tested yet, so a live production move is a **drain cutover** (stop Sidekiq's workers, confirm nothing is in flight, start Wurk), with a matching rollback; the [production cutover](https://github.com/developerz-ai/wurk/blob/main/docs/migrate-from-sidekiq.md#9-production-cutover) section has every step and command. The upstream suites of sidekiq-cron, sidekiq-unique-jobs, sidekiq-failures and sentry-sidekiq run against Wurk in the [`ecosystem` CI job](https://github.com/developerz-ai/wurk/blob/main/.github/workflows/ecosystem.yml) (see [`test/ecosystem/`](https://github.com/developerz-ai/wurk/tree/main/test/ecosystem)). sidekiq-scheduler, sidekiq-status and sidekiq-throttled are target additions tracked in [docs/idea/14-ecosystem-compat.md](https://github.com/developerz-ai/wurk/blob/main/docs/idea/14-ecosystem-compat.md).
|
|
307
307
|
|
|
308
|
-
**Keeping a `sidekiq-*` add-on gem?** Those gems declare `add_dependency "sidekiq"`, which would reinstall real Sidekiq next to Wurk. Satisfy it with Wurk's git-only [`sidekiq` shim gem](https://github.com/developerz-ai/wurk/tree/main/ecosystem/sidekiq-shim) instead, pinned to the tag of the Wurk release you run: `gem "sidekiq", github: "developerz-ai/wurk", tag: "v1.
|
|
308
|
+
**Keeping a `sidekiq-*` add-on gem?** Those gems declare `add_dependency "sidekiq"`, which would reinstall real Sidekiq next to Wurk. Satisfy it with Wurk's git-only [`sidekiq` shim gem](https://github.com/developerz-ai/wurk/tree/main/ecosystem/sidekiq-shim) instead, pinned to the tag of the Wurk release you run: `gem "sidekiq", github: "developerz-ai/wurk", tag: "v1.15.0", glob: "ecosystem/sidekiq-shim/*.gemspec"`. Only sidekiq-cron, sidekiq-unique-jobs, sidekiq-failures and sentry-sidekiq are exercised that way, by the `ecosystem` workflow; treat the others as untested.
|
|
309
309
|
|
|
310
310
|
Full walkthrough — config side-by-side, the Redis key/`sidekiq_options` mapping, known incompatibilities, moving sidekiq-cron schedules over (`rake wurk:import:cron`), and the production cutover and rollback playbook: **[docs/migrate-from-sidekiq.md](https://github.com/developerz-ai/wurk/blob/main/docs/migrate-from-sidekiq.md)**. On the night, keep the **[incident runbook](https://github.com/developerz-ai/wurk/blob/main/docs/runbook.md)** open.
|
|
311
311
|
|
|
@@ -6,12 +6,18 @@ module Wurk
|
|
|
6
6
|
# extension forms send no Rails authenticity token, so `protect_from_forgery`
|
|
7
7
|
# can't apply — guard unsafe methods with a same-origin check instead. A
|
|
8
8
|
# cross-site page can drive a victim's browser but cannot forge
|
|
9
|
-
# `Sec-Fetch-Site: same-origin` (the browser sets it)
|
|
10
|
-
# denied too, since only a non-browser client omits it and it carries no
|
|
11
|
-
# ambient session cookie to abuse.
|
|
9
|
+
# `Sec-Fetch-Site: same-origin` (the browser sets it).
|
|
12
10
|
#
|
|
13
|
-
#
|
|
14
|
-
#
|
|
11
|
+
# Browsers send Fetch Metadata only to potentially-trustworthy origins
|
|
12
|
+
# (HTTPS, localhost), so a dashboard over plain HTTP on a LAN host never sees
|
|
13
|
+
# it. Then the request's `Origin` — or, when absent, its `Referer` — must be
|
|
14
|
+
# exactly this request's scheme, host and port (owner decision U9, #101 W3).
|
|
15
|
+
# Neither header present is denied: only a non-browser client omits both,
|
|
16
|
+
# and it carries no ambient session cookie to abuse.
|
|
17
|
+
#
|
|
18
|
+
# The standalone Rack surface (Wurk::Web#safe_request?) applies the same
|
|
19
|
+
# Sec-Fetch-Site rule without this fallback: it stays strict, so a
|
|
20
|
+
# plain-HTTP standalone mount refuses unsafe requests (parity-divergences).
|
|
15
21
|
module SameOriginGuard
|
|
16
22
|
extend ActiveSupport::Concern
|
|
17
23
|
|
|
@@ -28,13 +34,29 @@ module Wurk
|
|
|
28
34
|
|
|
29
35
|
private
|
|
30
36
|
|
|
37
|
+
# The SPA's toast branches on this body to name the cause instead of
|
|
38
|
+
# reading the 403 as read-only mode.
|
|
31
39
|
def verify_same_origin!
|
|
32
|
-
|
|
40
|
+
render json: { error: 'cross_origin' }, status: :forbidden unless safe_request?
|
|
33
41
|
end
|
|
34
42
|
|
|
35
43
|
def safe_request?
|
|
36
|
-
SAFE_METHODS.include?(request.request_method)
|
|
37
|
-
|
|
44
|
+
return true if SAFE_METHODS.include?(request.request_method)
|
|
45
|
+
|
|
46
|
+
site = request.headers['Sec-Fetch-Site']
|
|
47
|
+
site ? site == 'same-origin' : same_origin_source?
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def same_origin_source?
|
|
51
|
+
source = request.headers['Origin'].presence || request.referer.presence
|
|
52
|
+
return false unless source
|
|
53
|
+
|
|
54
|
+
uri = ::URI.parse(source)
|
|
55
|
+
[uri.scheme, uri.host, uri.port] == own_origin
|
|
56
|
+
rescue ::URI::InvalidURIError
|
|
57
|
+
false
|
|
38
58
|
end
|
|
59
|
+
|
|
60
|
+
def own_origin = [request.scheme, request.host, request.port]
|
|
39
61
|
end
|
|
40
62
|
end
|
|
@@ -5,7 +5,8 @@ module Wurk
|
|
|
5
5
|
# Pagination helpers shared by every listing endpoint. The contract:
|
|
6
6
|
# * `?count=` page size (default 25, clamped to 1..200)
|
|
7
7
|
# * `?page=` 0-indexed page number
|
|
8
|
-
# * `?substr=` case-insensitive
|
|
8
|
+
# * `?substr=` case-insensitive filter on a row's klass, jid, error
|
|
9
|
+
# class, error message or args
|
|
9
10
|
#
|
|
10
11
|
# Helpers expect an Enumerable that yields whatever JSON-shaped Hash the
|
|
11
12
|
# caller built; substr filtering and slicing happen after serialization so
|
|
@@ -14,15 +15,25 @@ module Wurk
|
|
|
14
15
|
DEFAULT_PAGE_SIZE = 25
|
|
15
16
|
MAX_PAGE_SIZE = 200
|
|
16
17
|
# An unfiltered listing reads its page at the offset (the set's
|
|
17
|
-
# #snapshot), whatever the depth; the walks that remain (
|
|
18
|
-
#
|
|
19
|
-
#
|
|
18
|
+
# #snapshot), whatever the depth; the walks that remain (a filtered
|
|
19
|
+
# #slice, the Limits names) still pay per skipped row, and 1000 pages is
|
|
20
|
+
# far beyond any real UI depth while bounding them.
|
|
20
21
|
MAX_PAGE = 1_000
|
|
21
22
|
# A substr that matches nothing would otherwise stream the whole backing
|
|
22
|
-
# set through Ruby
|
|
23
|
-
#
|
|
24
|
-
#
|
|
25
|
-
FILTER_SCAN_LIMIT =
|
|
23
|
+
# set through Ruby, so a filtered request examines at most Web::Search's
|
|
24
|
+
# per-request budget of raw rows; results within it are exact, beyond it
|
|
25
|
+
# the page just comes back short.
|
|
26
|
+
FILTER_SCAN_LIMIT = ::Wurk::Web::Search::SCAN_BUDGET
|
|
27
|
+
# A filter walk reads the set through its #snapshot, starting at an
|
|
28
|
+
# ordinary listing page and doubling to FILTER_PAGE: a match near the
|
|
29
|
+
# top costs what it did, and the full budget costs ~25 round trips
|
|
30
|
+
# rather than one per 50 rows.
|
|
31
|
+
FIRST_FILTER_PAGE = 50
|
|
32
|
+
FILTER_PAGE = 1_000
|
|
33
|
+
# Entries one filtered `<set>/all/:cmd` request acts on, the cap the
|
|
34
|
+
# bulk `keys[]` action already has.
|
|
35
|
+
SWEEP_LIMIT = 1_000
|
|
36
|
+
MATCHED_FIELDS = %i[klass jid error_class error_message].freeze
|
|
26
37
|
|
|
27
38
|
module_function
|
|
28
39
|
|
|
@@ -61,49 +72,15 @@ module Wurk
|
|
|
61
72
|
default
|
|
62
73
|
end
|
|
63
74
|
|
|
64
|
-
#
|
|
65
|
-
#
|
|
66
|
-
#
|
|
67
|
-
#
|
|
68
|
-
#
|
|
69
|
-
#
|
|
70
|
-
#
|
|
71
|
-
#
|
|
72
|
-
|
|
73
|
-
def slice(enumerable, page, &)
|
|
74
|
-
if page[:substr].empty?
|
|
75
|
-
slice_raw(enumerable, offset(page), page[:count], &)
|
|
76
|
-
else
|
|
77
|
-
slice_filtered(enumerable, offset(page), page, &)
|
|
78
|
-
end
|
|
79
|
-
end
|
|
80
|
-
|
|
81
|
-
# Fast path: skip serialization entirely for rows before the offset.
|
|
82
|
-
def slice_raw(enumerable, offset, count)
|
|
83
|
-
results = []
|
|
84
|
-
seen = 0
|
|
85
|
-
enumerable.each do |member|
|
|
86
|
-
if seen < offset
|
|
87
|
-
seen += 1
|
|
88
|
-
next
|
|
89
|
-
end
|
|
90
|
-
|
|
91
|
-
payload = yield(member)
|
|
92
|
-
next unless payload
|
|
93
|
-
|
|
94
|
-
results << payload
|
|
95
|
-
break if results.size >= count
|
|
96
|
-
end
|
|
97
|
-
results
|
|
98
|
-
end
|
|
99
|
-
|
|
100
|
-
# Filtered path: the offset counts MATCHING rows, so page boundaries
|
|
101
|
-
# stay stable (raw-index offsets re-emit or skip matches across pages).
|
|
102
|
-
# Records the matches seen in `page[:matched]` and whether the set was
|
|
103
|
-
# walked to its end in `page[:exhausted]`: stopping once the page fills
|
|
104
|
-
# is what keeps a filtered request cheap, so the count is only exact
|
|
105
|
-
# when nothing was left unread.
|
|
106
|
-
def slice_filtered(enumerable, offset, page)
|
|
75
|
+
# One page of a filtered listing: up to `count` payloads (the block maps
|
|
76
|
+
# each member to one; nil skips it) from the matches of `substr`, in
|
|
77
|
+
# `enumerable`'s order. The offset counts MATCHING rows, so page
|
|
78
|
+
# boundaries stay stable (raw-index offsets re-emit or skip matches
|
|
79
|
+
# across pages). Records the matches seen in `page[:matched]` and whether
|
|
80
|
+
# the set was walked to its end in `page[:exhausted]`: stopping once the
|
|
81
|
+
# page fills is what keeps a filtered request cheap, so the count is only
|
|
82
|
+
# exact when nothing was left unread.
|
|
83
|
+
def slice(enumerable, page)
|
|
107
84
|
results = []
|
|
108
85
|
matched = 0
|
|
109
86
|
examined = 0
|
|
@@ -113,7 +90,7 @@ module Wurk
|
|
|
113
90
|
payload = yield(member)
|
|
114
91
|
next unless payload && match?(payload, page[:substr])
|
|
115
92
|
|
|
116
|
-
results << payload if (matched += 1) > offset
|
|
93
|
+
results << payload if (matched += 1) > offset(page)
|
|
117
94
|
break if results.size >= page[:count]
|
|
118
95
|
end
|
|
119
96
|
record_match_count(page, matched, examined, results.size)
|
|
@@ -125,11 +102,51 @@ module Wurk
|
|
|
125
102
|
page[:exhausted] = examined <= FILTER_SCAN_LIMIT && served < page[:count]
|
|
126
103
|
end
|
|
127
104
|
|
|
105
|
+
# Up to SWEEP_LIMIT of `rows`' members whose row (the block maps a member
|
|
106
|
+
# to it) matches `substr`, within FILTER_SCAN_LIMIT examined:
|
|
107
|
+
# [members, rows examined, whether `rows` ran out].
|
|
108
|
+
def matching(rows, substr)
|
|
109
|
+
members = []
|
|
110
|
+
examined = 0
|
|
111
|
+
rows.each do |member|
|
|
112
|
+
return [members, examined, false] if examined >= FILTER_SCAN_LIMIT || members.size >= SWEEP_LIMIT
|
|
113
|
+
|
|
114
|
+
examined += 1
|
|
115
|
+
members << member if match?(yield(member), substr)
|
|
116
|
+
end
|
|
117
|
+
[members, examined, true]
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
# Every row from raw offset `from` on, read page by page through the
|
|
121
|
+
# block, which answers `count` rows from `offset` in listing order.
|
|
122
|
+
# Stops after the first short page.
|
|
123
|
+
def walk(from = 0, &read)
|
|
124
|
+
::Enumerator.new do |out|
|
|
125
|
+
offset = from
|
|
126
|
+
size = FIRST_FILTER_PAGE
|
|
127
|
+
loop do
|
|
128
|
+
rows = read.call(offset, size)
|
|
129
|
+
rows.each { |row| out << row }
|
|
130
|
+
break if rows.size < size
|
|
131
|
+
|
|
132
|
+
offset += size
|
|
133
|
+
size = [size * 2, FILTER_PAGE].min
|
|
134
|
+
end
|
|
135
|
+
end
|
|
136
|
+
end
|
|
137
|
+
|
|
128
138
|
def match?(payload, substr)
|
|
129
139
|
return true if substr.nil? || substr.empty?
|
|
130
140
|
|
|
131
141
|
needle = substr.downcase
|
|
132
|
-
|
|
142
|
+
MATCHED_FIELDS.any? { |field| payload[field].to_s.downcase.include?(needle) } ||
|
|
143
|
+
args_match?(payload[:args], needle)
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
# Against the args as the SPA shows them: JSON, so `"a@b.c"` or `42]`
|
|
147
|
+
# match as typed.
|
|
148
|
+
def args_match?(args, needle)
|
|
149
|
+
!args.nil? && ::Wurk.dump_json(args).downcase.include?(needle)
|
|
133
150
|
end
|
|
134
151
|
end
|
|
135
152
|
end
|
|
@@ -35,6 +35,10 @@ module Wurk
|
|
|
35
35
|
|
|
36
36
|
HISTORY_WINDOW_UNITS = { 's' => 1, 'm' => 60, 'h' => 3600, 'd' => 86_400 }.freeze
|
|
37
37
|
DEFAULT_HISTORY_WINDOW = 24 * 3600
|
|
38
|
+
# Sidekiq Web's dashboard `?days=N` range (free §25.4).
|
|
39
|
+
MAX_HISTORY_DAYS = 180
|
|
40
|
+
# Far past any real set; bounds a `?cursor=` before it reaches LRANGE.
|
|
41
|
+
MAX_CURSOR = 1 << 40
|
|
38
42
|
|
|
39
43
|
# Per-set action whitelists. Maps the SPA's action name to the
|
|
40
44
|
# SortedEntry/JobSet method. Anything not listed 400s — keeps the bulk/
|
|
@@ -67,10 +71,12 @@ module Wurk
|
|
|
67
71
|
}
|
|
68
72
|
end
|
|
69
73
|
|
|
74
|
+
# `?direction=asc` lists oldest first, the job the next fetch takes at the
|
|
75
|
+
# top, as Sidekiq Web's queue page does (free §25.4).
|
|
70
76
|
def queue
|
|
71
77
|
q = ::Wurk::Queue.new(params[:name].to_s)
|
|
72
78
|
page = ::Wurk::Api::Pagination.window(params)
|
|
73
|
-
gauges, jobs = queue_page(q, page)
|
|
79
|
+
gauges, jobs = queue_page(q, page, params[:direction].to_s == 'asc')
|
|
74
80
|
render json: {
|
|
75
81
|
name: q.name, size: gauges.size, latency: gauges.latency, paused: gauges.paused?,
|
|
76
82
|
**::Wurk::Api::Pagination.meta(page), jobs: jobs
|
|
@@ -121,6 +127,8 @@ module Wurk
|
|
|
121
127
|
|
|
122
128
|
def retries_all
|
|
123
129
|
set = ::Wurk::RetrySet.new
|
|
130
|
+
return sweep_matching(set, RETRY_ACTIONS) if filtered_sweep?
|
|
131
|
+
|
|
124
132
|
count = case params[:cmd].to_s
|
|
125
133
|
when 'retry' then set.retry_all
|
|
126
134
|
when 'kill' then set.kill_all
|
|
@@ -136,6 +144,8 @@ module Wurk
|
|
|
136
144
|
|
|
137
145
|
def scheduled_all
|
|
138
146
|
set = ::Wurk::ScheduledSet.new
|
|
147
|
+
return sweep_matching(set, SCHEDULED_ACTIONS) if filtered_sweep?
|
|
148
|
+
|
|
139
149
|
case params[:cmd].to_s
|
|
140
150
|
when 'delete' then render json: { ok: true, count: clear_set(set) }
|
|
141
151
|
when 'add_to_queue' then drain_set(set, :add_to_queue)
|
|
@@ -149,6 +159,8 @@ module Wurk
|
|
|
149
159
|
|
|
150
160
|
def dead_all
|
|
151
161
|
set = ::Wurk::DeadSet.new
|
|
162
|
+
return sweep_matching(set, DEAD_ACTIONS) if filtered_sweep?
|
|
163
|
+
|
|
152
164
|
count = case params[:cmd].to_s
|
|
153
165
|
when 'retry' then set.retry_all
|
|
154
166
|
when 'delete' then clear_set(set)
|
|
@@ -179,11 +191,13 @@ module Wurk
|
|
|
179
191
|
|
|
180
192
|
# Rows are Batch::Status#summary: #data with the failed and dead jid sets
|
|
181
193
|
# counted rather than listed. GET /api/batches/:bid carries the jids.
|
|
194
|
+
# `?dead=1` lists `dead-batches` instead (Pro's Dead batches tab);
|
|
195
|
+
# `?tag=` narrows either to the batches carrying that tag, and takes the
|
|
196
|
+
# place of `?substr=` (BatchSet#tagged_snapshot).
|
|
182
197
|
def batches
|
|
183
198
|
page = ::Wurk::Api::Pagination.window(params)
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
end
|
|
199
|
+
set = %w[1 true].include?(params[:dead].to_s) ? ::Wurk::Batch::DeadSet.new : ::Wurk::BatchSet.new
|
|
200
|
+
total, rows = batch_rows(set, page, params[:tag].to_s)
|
|
187
201
|
render json: { total: total, **::Wurk::Api::Pagination.meta(page), batches: rows }
|
|
188
202
|
end
|
|
189
203
|
|
|
@@ -284,10 +298,11 @@ module Wurk
|
|
|
284
298
|
end
|
|
285
299
|
|
|
286
300
|
# Cluster-total throughput/failures time-series for the dashboard charts.
|
|
287
|
-
# `:bucket` is 1m/5m/1h; `?window=24h` (s/m/h/d suffix)
|
|
288
|
-
# bucket's retention.
|
|
301
|
+
# `:bucket` is 1m/5m/1h; `?window=24h` (s/m/h/d suffix) or `?days=N`
|
|
302
|
+
# (1..180, wins over window) is clamped to the bucket's retention.
|
|
303
|
+
# Chart-ready array under `series`.
|
|
289
304
|
def history
|
|
290
|
-
window =
|
|
305
|
+
window = history_window(params)
|
|
291
306
|
series = ::Wurk::Web::Enterprise::Historical.history(params[:bucket].to_s, window: window)
|
|
292
307
|
render json: { bucket: params[:bucket].to_s, window: window, series: series.map { |row| ::Wurk::Api::Serializers.history_point(row) } }
|
|
293
308
|
rescue ::ArgumentError => e
|
|
@@ -307,10 +322,10 @@ module Wurk
|
|
|
307
322
|
|
|
308
323
|
# Per-queue size/latency gauge time-series for the Metrics/Historical tab.
|
|
309
324
|
# `:bucket` is 1m/5m/1h; `?window=24h` (s/m/h/d) is clamped to the bucket's
|
|
310
|
-
# retention; optional `?queue=<name>` narrows
|
|
311
|
-
# `points` are chart-ready.
|
|
325
|
+
# retention (`?days=N` as on #history); optional `?queue=<name>` narrows
|
|
326
|
+
# to one queue. Each queue's `points` are chart-ready.
|
|
312
327
|
def queue_history # rubocop:disable Metrics/AbcSize
|
|
313
|
-
window =
|
|
328
|
+
window = history_window(params)
|
|
314
329
|
queues = params[:queue].present? ? [params[:queue].to_s] : nil
|
|
315
330
|
series = ::Wurk::Web::Enterprise::Historical.queue_history(params[:bucket].to_s, window: window, queues: queues)
|
|
316
331
|
render json: {
|
|
@@ -413,7 +428,7 @@ module Wurk
|
|
|
413
428
|
return render(json: { error: 'unknown action' }, status: :bad_request) unless method
|
|
414
429
|
|
|
415
430
|
keys = Array(params[:keys]).map(&:to_s).uniq
|
|
416
|
-
# Each key costs a ZRANGEBYSCORE plus per-entry mutations; an uncapped
|
|
431
|
+
# Each key costs a pipelined ZRANGEBYSCORE plus per-entry mutations; an uncapped
|
|
417
432
|
# list lets one POST issue tens of thousands of round-trips. The UI's
|
|
418
433
|
# per-row selections accumulate across pages (toggleAll works against
|
|
419
434
|
# the visible page's keys only) and the bulk POST sends the whole Set,
|
|
@@ -443,8 +458,8 @@ module Wurk
|
|
|
443
458
|
|
|
444
459
|
# 422 when any entry failed, so the SPA's error toast fires; `count` is
|
|
445
460
|
# what was applied either way.
|
|
446
|
-
def render_applied(total, failures)
|
|
447
|
-
body = { ok: failures.empty?, count: total - failures.size }
|
|
461
|
+
def render_applied(total, failures, extra = {})
|
|
462
|
+
body = { ok: failures.empty?, count: total - failures.size, **extra }
|
|
448
463
|
return render(json: body) if failures.empty?
|
|
449
464
|
|
|
450
465
|
render json: body.merge(failed: failures), status: 422
|
|
@@ -471,13 +486,50 @@ module Wurk
|
|
|
471
486
|
# Maps "<score>|<jid>" keys to live SortedEntry objects via score-bracketed
|
|
472
487
|
# fetch (exact float match, narrowed by jid) — avoids depending on float→
|
|
473
488
|
# string round-tripping between JS and Ruby. Skips malformed/empty keys.
|
|
489
|
+
# One pipelined round trip for every key (JobSet#fetch_pairs).
|
|
474
490
|
def entries_for(set, keys)
|
|
475
|
-
keys.
|
|
491
|
+
pairs = keys.filter_map do |key|
|
|
476
492
|
score, jid = key.to_s.split('|', 2)
|
|
477
|
-
|
|
493
|
+
[score.to_f, jid] unless jid.nil? || jid.empty?
|
|
494
|
+
end
|
|
495
|
+
set.fetch_pairs(pairs)
|
|
496
|
+
end
|
|
497
|
+
|
|
498
|
+
def batch_rows(set, page, tag)
|
|
499
|
+
symbolize = ->(summary) { summary.transform_keys(&:to_sym) }
|
|
500
|
+
return page_rows(set, page, &symbolize) if tag.empty?
|
|
501
|
+
|
|
502
|
+
total, summaries = set.tagged_snapshot(tag, ::Wurk::Api::Pagination.offset(page), page[:count])
|
|
503
|
+
[total, summaries.map(&symbolize)]
|
|
504
|
+
end
|
|
505
|
+
|
|
506
|
+
def filtered_sweep? = !params[:substr].to_s.empty?
|
|
478
507
|
|
|
479
|
-
|
|
508
|
+
# `<set>/all/:cmd?substr=`: applies `cmd` to the entries the same filtered
|
|
509
|
+
# listing shows, newest first, at most SWEEP_LIMIT of them within the
|
|
510
|
+
# filter's scan budget per request. The answer carries `done` (the walk
|
|
511
|
+
# reached the end of the set) and `cursor`, the raw offset to send back as
|
|
512
|
+
# `?cursor=` to carry on: the rows examined minus those this request moved
|
|
513
|
+
# out of the set. Entries added or removed meanwhile above that offset
|
|
514
|
+
# shift it, so a resumed sweep can re-examine or skip a few rows.
|
|
515
|
+
def sweep_matching(set, actions)
|
|
516
|
+
method = actions[params[:cmd].to_s]
|
|
517
|
+
return render(json: { error: 'unknown action' }, status: :bad_request) unless method
|
|
518
|
+
|
|
519
|
+
entries, scanned_to, done = matching_entries(set)
|
|
520
|
+
failures = apply_each(entries, method)
|
|
521
|
+
cursor = scanned_to - (entries.size - failures.size)
|
|
522
|
+
render_applied(entries.size, failures, matched: entries.size, done: done, cursor: cursor)
|
|
523
|
+
end
|
|
524
|
+
|
|
525
|
+
# [the matches from `?cursor=`, the raw offset the walk stopped at, done].
|
|
526
|
+
def matching_entries(set)
|
|
527
|
+
from = ::Wurk::Api::Pagination.clamp_int(params[:cursor], 0, MAX_CURSOR, 0)
|
|
528
|
+
rows = ::Wurk::Api::Pagination.walk(from) { |offset, count| set.snapshot(offset, count).last }
|
|
529
|
+
entries, examined, done = ::Wurk::Api::Pagination.matching(rows, params[:substr].to_s) do |entry|
|
|
530
|
+
::Wurk::Api::Serializers.sorted_entry(entry)
|
|
480
531
|
end
|
|
532
|
+
[entries, from + examined, done]
|
|
481
533
|
end
|
|
482
534
|
|
|
483
535
|
# UNLINKs the whole set, returning the count removed (read before clearing
|
|
@@ -507,26 +559,36 @@ module Wurk
|
|
|
507
559
|
|
|
508
560
|
# [total, rows] of one listing page. Unfiltered, the page is read straight
|
|
509
561
|
# off Redis at its offset (the set's #snapshot), so page 999 costs what
|
|
510
|
-
# page 0 does; a filter counts matching rows, so it
|
|
511
|
-
#
|
|
512
|
-
|
|
513
|
-
def page_rows(set, page, walk = nil, &serialize)
|
|
562
|
+
# page 0 does; a filter counts matching rows, so it walks the set through
|
|
563
|
+
# the same #snapshot, bounded by FILTER_SCAN_LIMIT.
|
|
564
|
+
def page_rows(set, page, &)
|
|
514
565
|
if page[:substr].empty?
|
|
515
566
|
total, members = set.snapshot(::Wurk::Api::Pagination.offset(page), page[:count])
|
|
516
|
-
return [total, members.map(&
|
|
567
|
+
return [total, members.map(&)]
|
|
517
568
|
end
|
|
518
569
|
|
|
519
|
-
rows = ::Wurk::Api::Pagination.
|
|
520
|
-
[set.size, rows]
|
|
570
|
+
rows = ::Wurk::Api::Pagination.walk { |offset, count| set.snapshot(offset, count).last }
|
|
571
|
+
[set.size, ::Wurk::Api::Pagination.slice(rows, page, &)]
|
|
521
572
|
end
|
|
522
573
|
|
|
523
574
|
# The gauges (anything answering size/latency/paused?) and the page's rows.
|
|
524
|
-
def queue_page(queue, page)
|
|
575
|
+
def queue_page(queue, page, oldest_first)
|
|
525
576
|
serialize = ->(rec) { ::Wurk::Api::Serializers.job_record(rec) }
|
|
526
|
-
|
|
577
|
+
unless page[:substr].empty?
|
|
578
|
+
rows = ::Wurk::Api::Pagination.walk { |offset, count| queue_records(queue, offset, count, oldest_first).last }
|
|
579
|
+
return [queue, ::Wurk::Api::Pagination.slice(rows, page, &serialize)]
|
|
580
|
+
end
|
|
581
|
+
|
|
582
|
+
snapshot, records = queue_records(queue, ::Wurk::Api::Pagination.offset(page), page[:count], oldest_first)
|
|
583
|
+
[snapshot, records.map(&serialize)]
|
|
584
|
+
end
|
|
527
585
|
|
|
528
|
-
|
|
529
|
-
|
|
586
|
+
# [snapshot, its records in listing order]. Oldest first reads the same
|
|
587
|
+
# LRANGE from the tail: negative indexes `-(offset + count)..-(offset + 1)`,
|
|
588
|
+
# which Redis clamps at the head, then reversed.
|
|
589
|
+
def queue_records(queue, offset, count, oldest_first)
|
|
590
|
+
snapshot = queue.snapshot(oldest_first ? -(offset + count) : offset, count)
|
|
591
|
+
[snapshot, oldest_first ? snapshot.records.reverse : snapshot.records]
|
|
530
592
|
end
|
|
531
593
|
|
|
532
594
|
def render_sorted_entry(set)
|
|
@@ -552,6 +614,13 @@ module Wurk
|
|
|
552
614
|
)
|
|
553
615
|
end
|
|
554
616
|
|
|
617
|
+
# `?days=N` (1..MAX_HISTORY_DAYS) in seconds when it parses, else
|
|
618
|
+
# `?window=`.
|
|
619
|
+
def history_window(params)
|
|
620
|
+
days = ::Wurk::Api::Pagination.clamp_int(params[:days], 1, MAX_HISTORY_DAYS, nil)
|
|
621
|
+
days ? days * HISTORY_WINDOW_UNITS.fetch('d') : parse_window(params[:window])
|
|
622
|
+
end
|
|
623
|
+
|
|
555
624
|
# Resolves the per-class metrics window. `minutes:` wins when present;
|
|
556
625
|
# `hours:` is used otherwise; default falls back to 60 minutes so callers
|
|
557
626
|
# that pass neither still get a useful series.
|
|
@@ -38,6 +38,12 @@ module Wurk
|
|
|
38
38
|
# pre-paint script reads it, and that script runs before the stylesheet so
|
|
39
39
|
# a host default never flashes the other palette.
|
|
40
40
|
HEAD_OPEN = '<head>'
|
|
41
|
+
# The built shell's asset URLs: Vite builds with a relative `base`
|
|
42
|
+
# (frontend/vite.config.ts) so the bundle's own chunk and font URLs resolve
|
|
43
|
+
# against wherever it is served from; only the shell needs an absolute
|
|
44
|
+
# prefix, because it is served from the page URL, not the asset mount.
|
|
45
|
+
RELATIVE_ASSET_URL = %r{(["'])\./}
|
|
46
|
+
SCRIPT_OPEN = '<script'
|
|
41
47
|
|
|
42
48
|
def index
|
|
43
49
|
render layout: false, html: decorate_shell(spa_html).html_safe
|
|
@@ -46,7 +52,18 @@ module Wurk
|
|
|
46
52
|
private
|
|
47
53
|
|
|
48
54
|
def decorate_shell(html)
|
|
49
|
-
inject_theme_default(inject_locale_hint(inject_head(html)))
|
|
55
|
+
stamp_csp_nonce(inject_theme_default(inject_locale_hint(inject_head(html))))
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
# A host policy with a nonce generator (`script-src 'self' 'nonce-…'`)
|
|
59
|
+
# refuses every inline script without the request's nonce, and the shell
|
|
60
|
+
# cannot run without its injected mount base. Every <script> gets it, the
|
|
61
|
+
# external module included, so a `'strict-dynamic'` policy loads it too.
|
|
62
|
+
def stamp_csp_nonce(html)
|
|
63
|
+
nonce = request.content_security_policy_nonce
|
|
64
|
+
return html unless nonce
|
|
65
|
+
|
|
66
|
+
html.gsub(SCRIPT_OPEN) { %(#{SCRIPT_OPEN} nonce="#{::ERB::Util.html_escape(nonce)}") }
|
|
50
67
|
end
|
|
51
68
|
|
|
52
69
|
def spa_html
|
|
@@ -143,7 +160,14 @@ module Wurk
|
|
|
143
160
|
raise "Wurk dashboard: precompiled SPA index.html missing at #{path}. " \
|
|
144
161
|
'Run `bin/rake frontend:build`.'
|
|
145
162
|
end
|
|
146
|
-
path.read
|
|
163
|
+
path.read.gsub(RELATIVE_ASSET_URL) { "#{::Regexp.last_match(1)}#{asset_base}/" }
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
# AssetMount sits in the host's stack, so its URL carries the host's own
|
|
167
|
+
# prefix (RAILS_RELATIVE_URL_ROOT, or a proxy's SCRIPT_NAME), not the
|
|
168
|
+
# engine mount: `/app/wurk` serves its assets from `/app/wurk-assets`.
|
|
169
|
+
def asset_base
|
|
170
|
+
"#{request.get_header('ORIGINAL_SCRIPT_NAME').to_s.chomp('/')}#{::Wurk::Engine::AssetMount::PREFIX}"
|
|
147
171
|
end
|
|
148
172
|
end
|
|
149
173
|
end
|
|
@@ -6,16 +6,21 @@ require 'uri'
|
|
|
6
6
|
module Wurk
|
|
7
7
|
# Profiles pane non-JSON endpoints (spec §25.4):
|
|
8
8
|
#
|
|
9
|
-
# GET
|
|
9
|
+
# GET /profiles/:key/data → the stored gzipped gecko JSON, streamed with a
|
|
10
10
|
# gzip Content-Encoding (Firefox profiler pulls
|
|
11
11
|
# this when given a `from-url` source).
|
|
12
|
-
#
|
|
12
|
+
# POST /profiles/:key → upload the profile to the Firefox profiler
|
|
13
13
|
# store and 302 to its public view URL.
|
|
14
|
+
# GET /profiles/:key → 302 to an upload already made (by either UI),
|
|
15
|
+
# 405 when there is none yet.
|
|
16
|
+
#
|
|
17
|
+
# Sidekiq uploads on the GET. Sending job data to a third party is a side
|
|
18
|
+
# effect, so here only a POST does it: SameOriginGuard covers it like every
|
|
19
|
+
# other mutation, and read-only mode refuses it (#101 W5).
|
|
14
20
|
#
|
|
15
21
|
# `:key` is "<token>-<jid>". The JSON list lives at /api/profiles.
|
|
16
22
|
class ProfilesController < ApplicationController
|
|
17
|
-
|
|
18
|
-
skip_forgery_protection
|
|
23
|
+
include SameOriginGuard
|
|
19
24
|
|
|
20
25
|
def data
|
|
21
26
|
blob = profile_blob(params[:key])
|
|
@@ -26,36 +31,36 @@ module Wurk
|
|
|
26
31
|
end
|
|
27
32
|
|
|
28
33
|
def show
|
|
29
|
-
# GET-shaped for Sidekiq parity, but uploading the profile to the public
|
|
30
|
-
# Firefox profiler store is a side effect — read-only deploys (e.g. the
|
|
31
|
-
# public demo) must not let any visitor exfiltrate profiling data.
|
|
32
34
|
return head(:forbidden) if ::Wurk::Web.config.read_only?
|
|
33
|
-
return head(:forbidden) unless navigated_from_dashboard?
|
|
34
35
|
|
|
36
|
+
sid = cached_sid(params[:key])
|
|
37
|
+
return redirect_to_profile(sid) if sid
|
|
38
|
+
return head(:not_found) unless profile_exists?(params[:key])
|
|
39
|
+
|
|
40
|
+
response.headers['Allow'] = 'POST'
|
|
41
|
+
head :method_not_allowed
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# Read-only mode 403s this POST in Wurk::Web::Authorization, before it
|
|
45
|
+
# gets here.
|
|
46
|
+
def upload
|
|
35
47
|
sid = profile_sid(params[:key])
|
|
36
48
|
return head(:not_found) if sid == :missing
|
|
37
49
|
return head(:bad_gateway) unless sid
|
|
38
50
|
|
|
39
|
-
|
|
51
|
+
redirect_to_profile(sid)
|
|
40
52
|
end
|
|
41
53
|
|
|
42
54
|
private
|
|
43
55
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
# link (same-origin) and a typed URL or bookmark (`none`). A browser too
|
|
47
|
-
# old to send Sec-Fetch-Site still sends a Referer, which must then be
|
|
48
|
-
# this host.
|
|
49
|
-
def navigated_from_dashboard?
|
|
50
|
-
site = request.headers['Sec-Fetch-Site']
|
|
51
|
-
return %w[same-origin none].include?(site) if site
|
|
52
|
-
|
|
53
|
-
referer = URI.parse(request.referer.to_s)
|
|
54
|
-
referer.host == request.host && referer.port == request.port
|
|
55
|
-
rescue URI::InvalidURIError
|
|
56
|
-
false
|
|
56
|
+
def redirect_to_profile(sid)
|
|
57
|
+
redirect_to(format(::Wurk::Web.config.profile_view_url, sid), allow_other_host: true)
|
|
57
58
|
end
|
|
58
59
|
|
|
60
|
+
def profile_exists?(key) = ::Wurk.redis { |c| c.call('EXISTS', key) }.positive?
|
|
61
|
+
|
|
62
|
+
def cached_sid(key) = ::Wurk.redis { |c| c.call('HGET', key, 'sid') }
|
|
63
|
+
|
|
59
64
|
def profile_blob(key)
|
|
60
65
|
::Wurk::ProfileRecord.data_for(key)
|
|
61
66
|
end
|
|
@@ -64,7 +69,7 @@ module Wurk
|
|
|
64
69
|
# upload exactly as Sidekiq's Web UI does, so either UI reuses the other's
|
|
65
70
|
# upload. :missing when the profile is gone, nil when the upload failed.
|
|
66
71
|
def profile_sid(key)
|
|
67
|
-
sid =
|
|
72
|
+
sid = cached_sid(key)
|
|
68
73
|
return sid if sid
|
|
69
74
|
|
|
70
75
|
blob = profile_blob(key)
|
data/config/routes.rb
CHANGED
|
@@ -126,12 +126,14 @@ Wurk::Engine.routes.draw do
|
|
|
126
126
|
mount Wurk::API => Wurk::API::ENGINE_MOUNT, constraints: ->(request) { Wurk::API.serves?(request.path_info) }
|
|
127
127
|
|
|
128
128
|
# Profiles (v8.0+) — not under /api: `:key/data` streams the gzipped gecko
|
|
129
|
-
# blob with a gzip Content-Encoding
|
|
130
|
-
#
|
|
131
|
-
#
|
|
132
|
-
#
|
|
133
|
-
|
|
134
|
-
get
|
|
129
|
+
# blob with a gzip Content-Encoding; `POST :key` uploads the profile to the
|
|
130
|
+
# Firefox profiler then 302s to its public view, and `GET :key` only follows
|
|
131
|
+
# an upload already made (Sidekiq uploads on the GET; #101 W5). `:key` is
|
|
132
|
+
# "<token>-<jid>". The `/data` route is declared first so it wins over the
|
|
133
|
+
# bare `:key` match. Spec: docs/target/sidekiq-free.md §25.4.
|
|
134
|
+
get 'profiles/:key/data', to: 'profiles#data', as: :profile_data, constraints: { key: %r{[^/]+} }
|
|
135
|
+
get 'profiles/:key', to: 'profiles#show', as: :profile, constraints: { key: %r{[^/]+} }
|
|
136
|
+
post 'profiles/:key', to: 'profiles#upload', as: :profile_upload, constraints: { key: %r{[^/]+} }
|
|
135
137
|
|
|
136
138
|
# Third-party Web extensions (#187): server-rendered route + assets. The SPA's
|
|
137
139
|
# Extension page fetches `ext/:name/<subpath>` and embeds the returned HTML;
|