Skip to content

Add activate_at parameter and return timer_id from publish()#8

Merged
lesnik512 merged 1 commit into
mainfrom
u1-u2-publish-api
May 3, 2026
Merged

Add activate_at parameter and return timer_id from publish()#8
lesnik512 merged 1 commit into
mainfrom
u1-u2-publish-api

Conversation

@lesnik512
Copy link
Copy Markdown
Member

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_ids 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.

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`.
@lesnik512 lesnik512 self-assigned this May 3, 2026
@lesnik512 lesnik512 merged commit f8815b9 into main May 3, 2026
2 checks passed
@lesnik512 lesnik512 deleted the u1-u2-publish-api branch May 3, 2026 12:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant