Skip to content

Design: put the event outbox behind a framework transport protocol instead of inside background_tasks #502

Closed

Description

@antosubash

Tier 2: structural (needs a design note first)

Problem

background_tasks is about 6k lines across 37 files and now owns four separate concerns:

The outbox is a delivery guarantee for domain events. That is a framework concern, but today it only exists when Celery is installed. InvalidationBus already shows the right pattern: a framework protocol with a transport plugged in from background_tasks.

There is also undeclared coupling. file_storage lazily imports background_tasks (checksum.py:50, tasks.py:39,51,143-144) without declaring it in depends_on.

Proposal

  • Define an EventTransport (or OutboxStore / OutboxDispatcher) protocol in core, modelled on InvalidationBus.
  • Keep the outbox tables and claim/fence logic wherever the protocol is implemented. Keep the Celery-specific dispatcher in background_tasks.
  • Declare background_tasks as an optional dependency of file_storage, or route through the protocol.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions