Skip to content

feat: migrate to pull-based Worker + EventHandler pattern#42

Merged
rorybyrne merged 3 commits into
035-feat-redesign-eventfrom
041-feat-refactor-pull
Feb 2, 2026
Merged

feat: migrate to pull-based Worker + EventHandler pattern#42
rorybyrne merged 3 commits into
035-feat-redesign-eventfrom
041-feat-refactor-pull

Conversation

@rorybyrne

Copy link
Copy Markdown
Contributor

Summary

Replaces push-based EventListener pattern with unified pull-based Worker + EventHandler architecture:

  • EventHandler base class with configuration via classvars (__routing_key__, __batch_size__, __poll_interval__, __max_retries__, __claim_timeout__)
  • Simplified Worker that accepts handler_type directly and reads config from classvars
  • WorkerPool.register() for handler-based registration
  • Renamed listener/handler/ across all domains (source, validation, curation, record, index)
  • VectorIndexHandler and KeywordIndexHandler with routing key support for per-backend processing
  • Database migration for worker columns (routing_key, retry_count, claimed_at, updated_at) and partial indexes

Workers claim events using FOR UPDATE SKIP LOCKED, enabling concurrent processing without coordination.

Changes

Area Change
Domain EventHandler base class, rename listeners to handlers
Infrastructure Simplified Worker, WorkerPool.register()
Database Migration for worker columns and indexes
Tests 108 unit tests, 15 integration tests

Test plan

  • Unit tests pass (108 tests)
  • Integration tests pass (15 tests for claiming and concurrency)
  • Lint and type checks pass
  • Manual test: start server, trigger source ingestion, verify records indexed

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.
@github-actions

github-actions Bot commented Feb 2, 2026

Copy link
Copy Markdown

Code Coverage

Package Line Rate Complexity Health
. 70% 0
application 0% 0
application.api 100% 0
application.api.rest 0% 0
application.api.v1 0% 0
application.api.v1.routes 0% 0
application.event 100% 0
cli 40% 0
cli.commands 18% 0
cli.util 53% 0
domain 100% 0
domain.auth 100% 0
domain.auth.adapter 100% 0
domain.auth.command 100% 0
domain.auth.event 100% 0
domain.auth.model 100% 0
domain.auth.port 100% 0
domain.auth.query 100% 0
domain.auth.service 100% 0
domain.curation 100% 0
domain.curation.adapter 100% 0
domain.curation.command 100% 0
domain.curation.event 0% 0
domain.curation.handler 0% 0
domain.curation.model 100% 0
domain.curation.port 100% 0
domain.curation.query 100% 0
domain.curation.service 100% 0
domain.deposition 100% 0
domain.deposition.adapter 100% 0
domain.deposition.command 0% 0
domain.deposition.event 100% 0
domain.deposition.model 0% 0
domain.deposition.port 0% 0
domain.deposition.query 100% 0
domain.deposition.service 0% 0
domain.export 100% 0
domain.export.adapter 100% 0
domain.export.command 100% 0
domain.export.event 100% 0
domain.export.model 100% 0
domain.export.port 100% 0
domain.export.query 100% 0
domain.export.service 100% 0
domain.index 100% 0
domain.index.event 100% 0
domain.index.handler 73% 0
domain.index.model 84% 0
domain.index.service 100% 0
domain.record 100% 0
domain.record.adapter 100% 0
domain.record.command 100% 0
domain.record.event 100% 0
domain.record.handler 0% 0
domain.record.model 100% 0
domain.record.port 100% 0
domain.record.query 100% 0
domain.record.service 100% 0
domain.schema 100% 0
domain.schema.adapter 100% 0
domain.schema.command 100% 0
domain.schema.event 100% 0
domain.schema.model 100% 0
domain.schema.port 100% 0
domain.schema.query 100% 0
domain.schema.service 100% 0
domain.search 100% 0
domain.search.adapter 100% 0
domain.search.command 100% 0
domain.search.event 100% 0
domain.search.model 100% 0
domain.search.port 100% 0
domain.search.query 100% 0
domain.search.service 100% 0
domain.shared 74% 0
domain.shared.model 90% 0
domain.shared.port 100% 0
domain.source 100% 0
domain.source.event 100% 0
domain.source.handler 0% 0
domain.source.model 76% 0
domain.source.schedule 0% 0
domain.source.service 92% 0
domain.validation 100% 0
domain.validation.adapter 100% 0
domain.validation.command 0% 0
domain.validation.event 0% 0
domain.validation.handler 0% 0
domain.validation.model 0% 0
domain.validation.port 0% 0
domain.validation.query 100% 0
domain.validation.service 0% 0
infrastructure 100% 0
infrastructure.event 66% 0
infrastructure.index 0% 0
infrastructure.index.vector 76% 0
infrastructure.messaging 100% 0
infrastructure.oci 0% 0
infrastructure.persistence 0% 0
infrastructure.persistence.adapter 0% 0
infrastructure.source 0% 0
sdk 100% 0
sdk.index 100% 0
sdk.source 100% 0
util 100% 0
util.di 8% 0
Summary 39% (1227 / 3138) 0

@rorybyrne rorybyrne merged commit 2ca97e9 into 035-feat-redesign-event Feb 2, 2026
6 checks passed
@rorybyrne rorybyrne deleted the 041-feat-refactor-pull branch February 2, 2026 20:28
@rorybyrne rorybyrne restored the 041-feat-refactor-pull branch February 2, 2026 21: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