Skip to content

refactor: decompose GenerateQRHandler into focused components (004)#26

Merged
bumbaRasch merged 1 commit into
mainfrom
refactor/004-generate-qr-handler-decomposition
Feb 7, 2026
Merged

refactor: decompose GenerateQRHandler into focused components (004)#26
bumbaRasch merged 1 commit into
mainfrom
refactor/004-generate-qr-handler-decomposition

Conversation

@bumbaRasch

Copy link
Copy Markdown
Owner

Extract DynamicQRCodeResolver service from GenerateQRHandler to follow SRP:

  • DynamicQRCodeResolver: short code generation, collision resolution, redirect URL building
  • DynamicQRSetup: immutable DTO for dynamic QR preparation result

Refactor GenerateQRHandler into 4-phase architecture:

  1. _prepare_content() — build content + optional dynamic setup
  2. _generate_image() — QR image I/O (outside transaction)
  3. _persist_with_retry() — DB writes with collision retry
  4. Event publishing with BaseEvent.with_updated()

Key improvements:

  • I/O (image generation) now happens OUTSIDE database transactions
  • Collision handling simplified: single check per tx, retry externally
  • BaseEvent.with_updated() replaces fragile manual event reconstruction
  • DI container wired with new singleton services

Tests: 1667 passed (18 new tests for DynamicQRCodeResolver + BaseEvent.with_updated)

Extract DynamicQRCodeResolver service from GenerateQRHandler to follow SRP:
- DynamicQRCodeResolver: short code generation, collision resolution, redirect URL building
- DynamicQRSetup: immutable DTO for dynamic QR preparation result

Refactor GenerateQRHandler into 4-phase architecture:
1. _prepare_content() — build content + optional dynamic setup
2. _generate_image() — QR image I/O (outside transaction)
3. _persist_with_retry() — DB writes with collision retry
4. Event publishing with BaseEvent.with_updated()

Key improvements:
- I/O (image generation) now happens OUTSIDE database transactions
- Collision handling simplified: single check per tx, retry externally
- BaseEvent.with_updated() replaces fragile manual event reconstruction
- DI container wired with new singleton services

Tests: 1667 passed (18 new tests for DynamicQRCodeResolver + BaseEvent.with_updated)
@bumbaRasch
bumbaRasch merged commit 331f7f5 into main Feb 7, 2026
1 check passed
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