Skip to content

refactor: migrate worker functionality to outbox use case#11

Merged
allisson merged 1 commit intomainfrom
outbox-usecase
Jan 26, 2026
Merged

refactor: migrate worker functionality to outbox use case#11
allisson merged 1 commit intomainfrom
outbox-usecase

Conversation

@allisson
Copy link
Owner

Replace the worker package with a proper use case implementation in the outbox domain, following Clean Architecture principles and improving extensibility.

Changes:

  • Create internal/outbox/usecase/outbox_usecase.go with OutboxUseCase implementation that handles event processing with configurable retry logic and transaction management
  • Introduce EventProcessor interface for extensible event handling, allowing custom processors to be plugged in
  • Add DefaultEventProcessor as the default implementation for basic event processing with logging
  • Migrate all tests from worker package to outbox usecase with full coverage (78.8%)
  • Update DI container (internal/app/di.go) to initialize and provide OutboxUseCase instead of EventWorker
  • Update cmd/app/main.go runWorker function to use OutboxUseCase
  • Remove internal/worker package entirely

Documentation updates:

  • Update README.md project structure to show complete outbox module with domain, usecase, and repository layers
  • Enhance README.md transactional outbox pattern section to explain use case-based approach and extensibility via EventProcessor
  • Rewrite docs/architecture.md transactional outbox section with detailed explanations of the new architecture, including code examples for custom event processors
  • Update docs/getting-started.md to clarify that worker command runs the outbox event processor
  • Update docs/development.md to reflect new terminology

Benefits:

  • Better architecture: Follows Clean Architecture with proper separation of concerns
  • Improved extensibility: EventProcessor interface allows custom event handling without modifying core logic
  • Enhanced maintainability: Outbox functionality now properly organized within the outbox domain
  • Consistent with existing patterns: Matches the structure of other domains (user, etc.)
  • Same functionality: Worker command continues to work identically

Replace the worker package with a proper use case implementation in the
outbox domain, following Clean Architecture principles and improving
extensibility.

Changes:
- Create internal/outbox/usecase/outbox_usecase.go with OutboxUseCase
  implementation that handles event processing with configurable retry
  logic and transaction management
- Introduce EventProcessor interface for extensible event handling,
  allowing custom processors to be plugged in
- Add DefaultEventProcessor as the default implementation for basic
  event processing with logging
- Migrate all tests from worker package to outbox usecase with full
  coverage (78.8%)
- Update DI container (internal/app/di.go) to initialize and provide
  OutboxUseCase instead of EventWorker
- Update cmd/app/main.go runWorker function to use OutboxUseCase
- Remove internal/worker package entirely

Documentation updates:
- Update README.md project structure to show complete outbox module
  with domain, usecase, and repository layers
- Enhance README.md transactional outbox pattern section to explain
  use case-based approach and extensibility via EventProcessor
- Rewrite docs/architecture.md transactional outbox section with
  detailed explanations of the new architecture, including code
  examples for custom event processors
- Update docs/getting-started.md to clarify that worker command runs
  the outbox event processor
- Update docs/development.md to reflect new terminology

Benefits:
- Better architecture: Follows Clean Architecture with proper
  separation of concerns
- Improved extensibility: EventProcessor interface allows custom event
  handling without modifying core logic
- Enhanced maintainability: Outbox functionality now properly organized
  within the outbox domain
- Consistent with existing patterns: Matches the structure of other
  domains (user, etc.)
- Same functionality: Worker command continues to work identically
@allisson allisson merged commit 76efed9 into main Jan 26, 2026
1 check passed
@allisson allisson deleted the outbox-usecase branch January 26, 2026 11:19
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