feat: migrate to pull-based Worker + EventHandler pattern#42
Merged
Conversation
Replace push-based EventListener with unified pull-based architecture: - Add EventHandler base class with config via classvars (__routing_key__, __batch_size__, __poll_interval__, __max_retries__, __claim_timeout__) - Simplify Worker to accept handler_type directly, read config from classvars - Add WorkerPool.register() for handler-based registration - Rename listener/ to handler/ across all domains (source, validation, curation, record, index) - Add VectorIndexHandler and KeywordIndexHandler with routing key support - Add database migration for worker columns (routing_key, retry_count, claimed_at, updated_at) and partial indexes for efficient claiming Workers now claim events using FOR UPDATE SKIP LOCKED, enabling concurrent processing without coordination. Each handler declares its own batch size and polling configuration. Test coverage: 108 unit tests, 15 integration tests for event claiming and concurrent worker behavior.
Use Pydantic Field constraints (ge, gt) for numeric validation instead of __post_init__. This provides consistent validation behavior with other domain models and better error messages.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replaces push-based
EventListenerpattern with unified pull-basedWorker+EventHandlerarchitecture:__routing_key__,__batch_size__,__poll_interval__,__max_retries__,__claim_timeout__)handler_typedirectly and reads config from classvarslistener/→handler/across all domains (source, validation, curation, record, index)routing_key,retry_count,claimed_at,updated_at) and partial indexesWorkers claim events using
FOR UPDATE SKIP LOCKED, enabling concurrent processing without coordination.Changes
EventHandlerbase class, rename listeners to handlersWorker,WorkerPool.register()Test plan