feat: timer mechanics (activate_in/activate_at, timer_id dedup, cancel_timer)#5
Merged
feat: timer mechanics (activate_in/activate_at, timer_id dedup, cancel_timer)#5
Conversation
…l_timer) Add scheduled / delayed delivery to OutboxBroker for parity with the faststream-redis-timers API surface: - publish(activate_in=timedelta) / publish(activate_at=datetime) set next_attempt_at so the row is invisible to fetch until the gate opens. publish_batch accepts the same params (applied to every row). - publish(timer_id="x") dedupes per (queue, timer_id) via pg_insert ON CONFLICT DO NOTHING, backed by a partial unique index on the outbox table. Re-publishing the same id is a silent no-op (returns None). - cancel_timer(queue, timer_id, session) deletes a not-yet-leased row; the acquired_token IS NULL guard preserves the lease invariant so in-flight handlers are never clobbered. - NOTIFY is skipped when next_attempt_at is in the future or when an ON CONFLICT made the insert a no-op — listeners can't act on either. The fetch CTE already gated on next_attempt_at <= now(), so no subscriber-side change was needed. Coverage stays at 100%.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add scheduled / delayed delivery to OutboxBroker for parity with the faststream-redis-timers API surface:
The fetch CTE already gated on next_attempt_at <= now(), so no subscriber-side change was needed. Coverage stays at 100%.