Skip to content

Add guides covering every part of the library to the docs site - #145

Closed
phelma wants to merge 4 commits into
docs-starlight-sitefrom
docs-guides
Closed

phelma wants to merge 4 commits into
docs-starlight-sitefrom
docs-guides

Conversation

@phelma

@phelma phelma commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

The docs site only covered writing events and building a projector. Everything else (Postgres setup, write conditions, the projection store and queries, the event broker, services) existed only in the generated API reference. Postgres users also had no documented way to create the schema.

This adds a how-to guide for each part of the library, plus a concepts page, and links them from the sidebar and the home page.

  • Guides:
    • streams, categories and the log
    • concurrency and write conditions
    • storing and querying projections
    • processing events asynchronously
    • services and error handling
    • using PostgreSQL
    • running PostgreSQL in production: keeping the schema in step with the library, choosing the serialisation guarantee, keeping subscriber state small, diagnosing slow writes, and common pitfalls
    • custom payload and state types
    • testing
    • logging
    • writing a storage adapter
  • Concepts: how the distributed event broker works, based on the current code rather than processing/NOTES.md.
  • Home page: a features grid that replaces the README's feature list. It drops the "coming soon" items.
  • PostgreSQL: the guide documents the sql/ files as they are. They live in the repo, aren't in the package, and you apply them with your own migration tooling. Nothing about how they're shipped changes.
  • Library change: logicblocks.event.utils now exports the clocks through __all__. The reference generator then produces a utils page, so Clock and SystemClock in public signatures become links.

Every code example was run, against the in-memory adapters and against a scratch Postgres 16 database. For the production guide, that included reproducing the slow generic plan without events_category_stream_sequence_number_index and checking it goes away once the index is built. mise run docs:build passes, including link validation. Lint, format, type checks and unit tests pass.

Library issues found while writing

None of these are fixed here. Where they affect users, the guides document the current behaviour or add a caution.

  • PostgresLockManager: lock_timeout uses timeout.microseconds, so whole seconds are dropped. timedelta(seconds=5) becomes 0, which waits forever.
  • ConnectionSettings: the connection string doesn't URL-encode the user or password, so passwords containing @, / or % break.
  • Broker error handling: the default RetryErrorHandler retries with no wait. A persistent failure becomes a tight loop that starves the event loop.
  • Log subscribers: if a log subscriber keeps its consumer state in the same store, it sees its own state-changed events and never goes idle.
  • Reassigned sources: when an event source returns to a previous subscriber, it reprocesses from out-of-date in-memory state and fails with UnmetWriteConditionError.
  • subscriptions.node_id: this records the leader's node, not the subscriber's.
  • InMemoryEventSubscriberStateStore.purge: it mutates the list while iterating, so it skips every other stale subscriber.
  • ServiceManager: stop() twice raises Event loop is closed. A thread-isolated service raising SystemExit hangs shutdown. ExitErrorHandler exits on cancellation.
  • Query differences between the in-memory and Postgres adapters:
    • REGEX_MATCHES anchoring
    • CONTAINS semantics
    • EQUAL None on missing nested keys
    • nested and integer Paths
    • key-set paging edge cases
  • Logging through stdlib: structlog.stdlib.BoundLogger makes EventStream.publish and ProjectionStore.save raise AttributeError on is_enabled_for.
  • Builders: NewEventBuilder and StoredEventBuilder treat None as "not given", so you can't build an event with None metadata.
  • Minor:
    • EventCategory.publish doesn't log.
    • retry_on_error(3) can be instantiated directly and then fails at runtime.
    • The singleton broker's distribution_interval default is 30s in the class but 60s in its settings.

Created with Opus 5.5 (including subagents) in Claude Code.

The reference generator skipped utils because it exported nothing, which
left Clock and SystemClock unlinked in public signatures.
Covers streams and categories, concurrency, the projection store and
queries, asynchronous processing, services and error handling,
PostgreSQL, serialisation, testing, logging and storage adapters, plus a
concepts page on the distributed event broker.
Covers keeping the schema in step with the library, choosing the
serialisation guarantee, keeping subscriber state small, keeping slow
writers apart, diagnosing slow writes and common pitfalls, and links to
it from the PostgreSQL, concurrency and event processing guides.
Copilot AI balanced review requested due to automatic review settings November 13, 2026 15:07

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@phelma

phelma commented Nov 18, 2026

Copy link
Copy Markdown
Contributor Author

Closed in favour of #148, which combines the whole docs stack into one PR.

@phelma phelma closed this Nov 18, 2026
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.

2 participants