Initial release
[websub-hub] / src / db / postgres / sql / subscription-delivery-claim.sql
1 --
2 INSERT INTO subscription_delivery_in_progress (id, claimant, claimed, claim_expires)
3 SELECT id, $(claimant) AS claimant, now() AS claimed, now() + $(claimTimeoutSeconds)::text::interval AS claim_expires
4 FROM subscription_delivery_needed
5 ORDER BY topic_id -- cluster topics together, so processing nodes can cache topic content
6 LIMIT $(wanted)
7 FOR UPDATE OF subscription_delivery_needed SKIP LOCKED
8 ON CONFLICT (id) DO UPDATE
9 SET
10 claimant = $(claimant),
11 claimed = now(),
12 claim_expires = now() + $(claimTimeoutSeconds)::text::interval
13 RETURNING id