Skip to content

B1 correlation id default doc#20

Merged
lesnik512 merged 4 commits intomainfrom
b1-correlation-id-default-doc
May 4, 2026
Merged

B1 correlation id default doc#20
lesnik512 merged 4 commits intomainfrom
b1-correlation-id-default-doc

Conversation

@lesnik512
Copy link
Copy Markdown
Member

No description provided.

lesnik512 added 4 commits May 4, 2026 09:01
`has_pending` returned `True` for any input under `TestTimersBroker`
because `mock_client.zscore` was an unstubbed `AsyncMock` and
`score is not None` evaluated to a truthy mock. `cancel_all` would
also have failed: `client.pipeline(...)` returned an awaitable mock
that could not be entered with `async with`.

The test broker's contract is "messages deliver immediately, so no
timer is ever pending." Make the inspection paths reflect that:

- `mock_client.zscore.return_value = None` → `has_pending` returns
  `False`.
- `mock_client.zrangebyscore.return_value = []` (already set) →
  `get_pending_timers` returns `[]`.
- Stub the pipeline so `cancel_all` returns `0`. Use `MagicMock` for
  the `pipeline()` call (returns the AsyncMock directly) and set
  `__aenter__.return_value = mock_pipe` so `async with ... as pipe`
  binds the same mock that exposes `execute() -> [0]`.

Add a regression test in `tests/test_fake.py` and document the new
contract in `docs/usage/testing.md`.
…tivation

- basic.md: mark `client` as required for production. The previous
  `None` default suggested the broker was usable without one — it
  raises `IncorrectState` on the first operation. Point readers at
  the testing page for the no-client shape.
- subscriber.md: replace `broker = TimersBroker()` in the timer-id
  example with the prod-flavoured `Redis.from_url(...)` snippet used
  on every other page (was the only no-client example outside the
  testing docs).
- subscriber.md: extend the worst-case-latency line — `× 1.5` is the
  poll backoff alone; in-flight handlers holding the `max_concurrent`
  limiter add back-pressure on top.
- subscriber.md: document the retry-rate consequence of NACK_ON_ERROR
  + lease_ttl. A handler that always raises retries every `lease_ttl`
  seconds; default `lease_ttl=30` is also the poison-pill retry rate.
  Point at `RejectMessage` for permanent drop.
- publisher.md: mirror the basic.md "past activation fires
  immediately" note so readers who only see the publisher table know
  about it.
The "Failure modes" bullet promised a `max_attempts` counter "planned
for a future release" but there is no tracking issue and no scheduled
work. Replace the speculation with the truthful current state: a buggy
handler retries every `lease_ttl` seconds indefinitely; use
`RejectMessage` to drop, or track attempts in your own state if you
need a hard cap.
…t_no_pending

Test name + assertions document the intent; the testing.py comments
and the previous commit message capture the WHY (avoid lying via
unstubbed AsyncMock). Removes the only ruff D205 issue.
@lesnik512 lesnik512 self-assigned this May 4, 2026
@lesnik512 lesnik512 merged commit 9715948 into main May 4, 2026
3 checks passed
@lesnik512 lesnik512 deleted the b1-correlation-id-default-doc branch May 4, 2026 06:07
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