wurk 1.16.0 → 1.17.1
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 +3 -1
- data/app/controllers/concerns/wurk/same_origin_guard.rb +8 -39
- data/app/controllers/concerns/wurk/sse_streaming.rb +3 -38
- data/app/controllers/wurk/api_controller.rb +8 -642
- data/app/controllers/wurk/dashboard_controller.rb +5 -156
- data/app/controllers/wurk/extensions_controller.rb +5 -43
- data/app/controllers/wurk/profiles_controller.rb +4 -117
- data/lib/wurk/api/serializers.rb +2 -2
- data/lib/wurk/batch/server_middleware.rb +3 -3
- data/lib/wurk/component.rb +1 -0
- data/lib/wurk/engine.rb +3 -111
- data/lib/wurk/fetcher/private_list_key.rb +40 -8
- data/lib/wurk/fetcher/reaper.rb +12 -4
- data/lib/wurk/fetcher/unparseable_keys.rb +8 -9
- data/lib/wurk/finished_job_cleanup.rb +155 -0
- data/lib/wurk/job_retry.rb +2 -10
- data/lib/wurk/processor.rb +26 -47
- data/lib/wurk/redis_pool.rb +16 -1
- data/lib/wurk/unique_jobs_compat/private_list_digests.rb +121 -0
- data/lib/wurk/unique_jobs_compat.rb +87 -0
- data/lib/wurk/version.rb +1 -1
- data/lib/wurk/web/asset_mount.rb +119 -0
- data/lib/wurk/web/dashboard/api_actions.rb +657 -0
- data/lib/wurk/web/dashboard/controller.rb +146 -0
- data/lib/wurk/web/dashboard/endpoints.rb +92 -0
- data/lib/wurk/web/dashboard/extension_actions.rb +53 -0
- data/lib/wurk/web/dashboard/profile_actions.rb +130 -0
- data/lib/wurk/web/dashboard/routes.rb +134 -0
- data/lib/wurk/web/dashboard/shell.rb +181 -0
- data/lib/wurk/web/dashboard/stats_tick.rb +49 -0
- data/lib/wurk/web/dashboard/stream_concurrency_guard.rb +97 -0
- data/lib/wurk/web/rack_app.rb +27 -29
- data/lib/wurk/web/same_origin.rb +43 -0
- data/lib/wurk.rb +1 -0
- data/vendor/assets/dashboard/wurk-manifest.json +2 -2
- metadata +17 -4
- data/app/controllers/concerns/wurk/stream_concurrency_guard.rb +0 -94
- /data/{app/controllers/wurk/api → lib/wurk/web/dashboard}/pagination.rb +0 -0
- /data/{app/controllers/wurk/api → lib/wurk/web/dashboard}/serializers.rb +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 38e891f5c26931fc61deb3b165cc5a7c4e9c952ee7ed98e2ba121bc89c06476f
|
|
4
|
+
data.tar.gz: '09c9fb93ef3cbe927925d714138c98dd3795977c9bc775806b90338adcdf5d00'
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: dbbd540b3082626c6de579a8dfc841bf27e0c51344a023f9be30a7f411e5021647c5fb531147fe1fbeaee706bb8e6c8a174195ec3c2b741c70b47cbcb80487d6
|
|
7
|
+
data.tar.gz: b994abcc5dba5e22aeb892d46a4f619540eec963546ded5456f1d6dd3eca47d0232d5db41b7b31717c9a69ef9fc703579d31439f91814f03a961eadb41324d48
|
data/README.md
CHANGED
|
@@ -197,6 +197,8 @@ Mount the engine wherever you like:
|
|
|
197
197
|
mount Wurk::Engine => "/wurk"
|
|
198
198
|
```
|
|
199
199
|
|
|
200
|
+
No Rails? `map("/sidekiq") { run Sidekiq::Web }` in a `config.ru` serves the same dashboard ([Dashboard → Without Rails](https://github.com/developerz-ai/wurk/blob/main/docs/dashboard.md#without-rails-run-sidekiqweb)).
|
|
201
|
+
|
|
200
202
|
On Devise, wrap it in `authenticate` so only signed-in admins reach it — unauthenticated visitors get bounced to your login page:
|
|
201
203
|
|
|
202
204
|
```ruby
|
|
@@ -306,7 +308,7 @@ Wurk is MIT and stays that way. If what you need is a commercial support contrac
|
|
|
306
308
|
|
|
307
309
|
`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 tested for stock Sidekiq 8 only, which may roll from one to the other under the conditions the guide lists; for a Sidekiq 7.x, Pro or Enterprise app 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).
|
|
308
310
|
|
|
309
|
-
**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.
|
|
311
|
+
**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.17.1", 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.
|
|
310
312
|
|
|
311
313
|
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.
|
|
312
314
|
|
|
@@ -1,29 +1,17 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require 'wurk/web/same_origin'
|
|
4
|
+
|
|
3
5
|
module Wurk
|
|
4
|
-
# Sidekiq's CSRF model (spec §25.1) for the
|
|
5
|
-
# authenticated
|
|
6
|
+
# Sidekiq's CSRF model (spec §25.1) for the engine's token-less, cookie-
|
|
7
|
+
# authenticated controllers: the SolidJS SPA (JSON fetch) and host-registered
|
|
6
8
|
# extension forms send no Rails authenticity token, so `protect_from_forgery`
|
|
7
|
-
# can't apply
|
|
8
|
-
#
|
|
9
|
-
# `Sec-Fetch-Site: same-origin` (the browser sets it).
|
|
10
|
-
#
|
|
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).
|
|
9
|
+
# can't apply. Unsafe methods must pass Wurk::Web::SameOrigin instead, the
|
|
10
|
+
# same rule the standalone Rack mount applies.
|
|
21
11
|
module SameOriginGuard
|
|
22
12
|
extend ActiveSupport::Concern
|
|
23
13
|
|
|
24
|
-
|
|
25
|
-
# kept local so this engine concern carries no lib load-order dependency.
|
|
26
|
-
SAFE_METHODS = %w[GET HEAD OPTIONS TRACE].freeze
|
|
14
|
+
SAFE_METHODS = ::Wurk::Web::SameOrigin::SAFE_METHODS
|
|
27
15
|
|
|
28
16
|
included do
|
|
29
17
|
# SPA/extension requests never carry a Rails CSRF token; the same-origin
|
|
@@ -37,26 +25,7 @@ module Wurk
|
|
|
37
25
|
# The SPA's toast branches on this body to name the cause instead of
|
|
38
26
|
# reading the 403 as read-only mode.
|
|
39
27
|
def verify_same_origin!
|
|
40
|
-
render json: { error: 'cross_origin' }, status: :forbidden unless
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
def safe_request?
|
|
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?
|
|
28
|
+
render json: { error: 'cross_origin' }, status: :forbidden unless ::Wurk::Web::SameOrigin.allowed?(request.env)
|
|
48
29
|
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
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
def own_origin = [request.scheme, request.host, request.port]
|
|
61
30
|
end
|
|
62
31
|
end
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require 'wurk/web/dashboard/stats_tick'
|
|
4
|
+
|
|
3
5
|
module Wurk
|
|
4
6
|
# Drives the `/api/stream` SSE loop (headers, tick cadence, tear-down).
|
|
5
7
|
# Split out of ApiController so the periodic-stats-push mechanics — which
|
|
@@ -8,40 +10,6 @@ module Wurk
|
|
|
8
10
|
module SseStreaming
|
|
9
11
|
extend ActiveSupport::Concern
|
|
10
12
|
|
|
11
|
-
# One stats payload per process per TTL, shared by every open stream: ten
|
|
12
|
-
# dashboard tabs ticking every 2s cost one Redis read, not ten. Streams
|
|
13
|
-
# that tick together wait on the lock and take the payload the first one
|
|
14
|
-
# read. Keyed on the pool so a payload read from one Redis never answers
|
|
15
|
-
# for another; a raising read caches nothing.
|
|
16
|
-
class SharedTick
|
|
17
|
-
def initialize(ttl)
|
|
18
|
-
@ttl = ttl
|
|
19
|
-
@lock = ::Mutex.new
|
|
20
|
-
clear!
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
def fetch
|
|
24
|
-
pool = ::Wurk.redis_pool
|
|
25
|
-
@lock.synchronize do
|
|
26
|
-
now = ::Process.clock_gettime(::Process::CLOCK_MONOTONIC)
|
|
27
|
-
return @payload if @payload && @pool.equal?(pool) && now - @read_at < @ttl
|
|
28
|
-
|
|
29
|
-
payload = yield.freeze
|
|
30
|
-
@payload = payload
|
|
31
|
-
@pool = pool
|
|
32
|
-
@read_at = now
|
|
33
|
-
payload
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
def clear!
|
|
38
|
-
@lock.synchronize { @payload = @pool = @read_at = nil }
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
# Under the 2s tick, so one stream never reads its own previous payload.
|
|
43
|
-
SHARED_TICK = SharedTick.new(1.0)
|
|
44
|
-
|
|
45
13
|
private
|
|
46
14
|
|
|
47
15
|
def stream_headers!
|
|
@@ -76,9 +44,6 @@ module Wurk
|
|
|
76
44
|
::Process.clock_gettime(::Process::CLOCK_MONOTONIC)
|
|
77
45
|
end
|
|
78
46
|
|
|
79
|
-
def stream_tick_payload
|
|
80
|
-
SHARED_TICK.fetch { ::Wurk::Api::Serializers.stats_payload(::Wurk::Stats::Snapshot.new) }
|
|
81
|
-
.merge(at: ::Time.now.to_f)
|
|
82
|
-
end
|
|
47
|
+
def stream_tick_payload = ::Wurk::Web::Dashboard::StatsTick.payload
|
|
83
48
|
end
|
|
84
49
|
end
|