Skip to content

Add actor registry#855

Open
ZacharyZhang-NY wants to merge 1 commit into
Bogdanp:masterfrom
ZacharyZhang-NY:add-actor-registry
Open

Add actor registry#855
ZacharyZhang-NY wants to merge 1 commit into
Bogdanp:masterfrom
ZacharyZhang-NY:add-actor-registry

Conversation

@ZacharyZhang-NY
Copy link
Copy Markdown

Refs #324

This adds a small dramatiq.Registry API for declaring actors before a final broker is available, then binding them once broker configuration is ready.

What changed:

  • add Registry.actor(...) as a broker-delayed counterpart to dramatiq.actor(...)
  • add Registry.bind(broker=None) to validate actor options against the target broker and declare collected actors
  • keep direct synchronous calls available before binding while failing message sending with a clear error until binding
  • export Registry from dramatiq
  • document the import-before-broker-config use case in the user guide

Validation:

  • python -c "import sys, types, pytest; m=types.ModuleType('pylibmc'); m.SomeErrors=Exception; sys.modules['pylibmc']=m; raise SystemExit(pytest.main(['tests/test_registry.py','tests/test_actors.py','tests/test_broker.py','-q','-x']))" -> 43 passed, 3 skipped
  • python -m mypy dramatiq/registry.py tests/test_types.py -> success
  • python -m black --check dramatiq/registry.py dramatiq/__init__.py tests/test_registry.py tests/test_types.py -> success
  • python -m flake8 dramatiq/registry.py tests/test_registry.py -> success
  • git diff --check -> success

Local note: Windows cannot build pylibmc here because libmemcached/memcached.h is missing, so the focused pytest run injects a temporary pylibmc module to satisfy tests/conftest.py import. No test stub is committed.

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