PersistedQueue: offer option that de-duplicates an id only while it is pending or processing
Maintainer thường phản hồi trong vòng 1 ngày
@effect-bot đang làm issue này rồi.
Từ ngày 2/11/2026.
Đánh giá
Issue này chưa được đánh giá.
Mô tả
Use case
A common queue pattern is "at most one job per key at a time, but run again when the next trigger arrives after the previous one finished". For example, a recompute job keyed by an entity id. Ten triggers in a burst should coalesce into one pending job. A trigger that arrives after that job has completed should enqueue a new one.
Today offer with an id de-duplicates until layerCleanup deletes the settled element (default timeToLive is 30 days). So a later trigger with the same id is silently dropped, and the work doesn't run again.
Current workaround
Before offering, rename the settled row's id so the ON CONFLICT (id, queue_name) DO NOTHING in the SQL store no longer matches:
UPDATE effect_queue SET id = id || '#' || sequence
WHERE queue_name = $1 AND id = $2 AND state IN ('completed', 'failed')
This works, but it writes to the store's own table from outside the module, so it depends on the table's schema and breaks if the store's migrations change it.
Proposal
An option on offer, for example:
queue.offer(value, { id, deduplicate: "whilePending" }) // default stays "untilCleanup"
With "whilePending", an offer is ignored while an element with that id is pending or processing, and enqueues anew once it is completed (and possibly failed, see below).
For Postgres, the offer could become:
INSERT INTO effect_queue (id, queue_name, element, state, attempts, visible_at, created_at, updated_at)
VALUES ($id, $name, $element, 'pending', 0, $visible_at, now(), now())
ON CONFLICT (id, queue_name) DO UPDATE SET
element = EXCLUDED.element, state = 'pending', attempts = 0, last_failure = NULL,
acquired_at = NULL, acquired_by = NULL,
visible_at = EXCLUDED.visible_at, updated_at = EXCLUDED.updated_at
WHERE effect_queue.state IN ('completed', 'failed')
The Redis and memory stores would need the same check on the stored state.
Open questions
- Failed elements: they are the dead-letter record, so reusing that row on a new offer erases the previous failure. An alternative is to keep the failed row and insert a new one, which needs the unique key to allow several settled rows per id. Or
"whilePending"could apply to completed elements only. - Ordering: reusing the row keeps the old
sequence, so among elements with the samevisible_atthe re-offered one sorts first. A delete followed by an insert would avoid that.
I'm happy to open a PR once you're fine with the shape.
- Ngôn ngữ chính
- TypeScript
- Star
- 16.7k
- Fork
- 808
- Merge trung bình
- 11 giờ 40 phút
- Pull request đã merge (30 ngày)
- 827
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của Effect-TS/effect
-
Xml: `positions` decode option that puts `line` and `column` on `StartElement` eventsCó thể đã có người làm @effect-bot đã nhận hôm nay. Đang mở
Effect-TS/effect#10400 · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
effect/ai: support the MCP Apps extension (`io.modelcontextprotocol/ui`)Có thể đã có người làm @effect-bot đã nhận 1 ngày trước. Đang mở
Effect-TS/effect#10399 · 2 bình luận · 1 reaction · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Flat RPC client and AtomRpc query/mutation: type-check cost grows with RPCs in the group × tags calledCó thể đã có người làm @effect-bot đã nhận 1 ngày trước. Đang mở
Effect-TS/effect#10396 · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Support `format: "password"` as `Redacted` in JSON Schema import/export and the OpenAPI generatorCó thể đã có người làm @effect-bot đã nhận 1 ngày trước. Đang mởenhancement
Effect-TS/effect#10394 · 2 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Versioned schemas with version negotiation in HttpApi, Rpc and clusterCó thể đã có người làm @effect-bot đã nhận 1 ngày trước. Đang mở
Effect-TS/effect#10383 · 2 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của Effect-TS/effect
Issue tương tự
-
Add: Upin & Ipin Channel HDĐang mởcheck:passed streams:add
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
S: triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Maintainer thường phản hồi trong vòng 1 ngày
-
iot client
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Open-Locker/Open-Locker#365 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 69/100
inmanta/web-console#7787 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
shoelace-style/webawesome#2979 ·
Maintainer thường phản hồi trong vòng 1 ngày