Add activate_at parameter and return timer_id from publish()#8
Merged
Conversation
Two small UX gaps in the publish API: - Users could only schedule a timer relative to *now*, recomputing `target - datetime.now(UTC)` at every call site. Add `activate_at: datetime | None` to both `broker.publish()` and `publisher.publish()`. Mutually exclusive with `activate_in` (raises); naive datetimes raise to fail fast on timezone bugs. - Both publish methods returned `None`, dropping auto-generated `timer_id`s on the floor — callers couldn't cancel a timer they had just scheduled. Return the resolved `timer_id` instead. Existing callers that ignore the return value still work. Refactored `TimerPublishCommand` to carry `activate_at: datetime` directly (was `activate_in: timedelta`); the producer no longer recomputes `now()` when writing the timeline score. The new `resolve_activate_at` helper in `response.py` is shared between `broker.py` and `publisher/usecase.py`.
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.
Two small UX gaps in the publish API:
Users could only schedule a timer relative to now, recomputing
target - datetime.now(UTC)at every call site. Addactivate_at: datetime | Noneto bothbroker.publish()andpublisher.publish(). Mutually exclusive withactivate_in(raises); naive datetimes raise to fail fast on timezone bugs.Both publish methods returned
None, dropping auto-generatedtimer_ids on the floor — callers couldn't cancel a timer they had just scheduled. Return the resolvedtimer_idinstead. Existing callers that ignore the return value still work.Refactored
TimerPublishCommandto carryactivate_at: datetimedirectly (wasactivate_in: timedelta); the producer no longer recomputesnow()when writing the timeline score. The newresolve_activate_athelper inresponse.pyis shared betweenbroker.pyandpublisher/usecase.py.