repid 2.1.3__tar.gz → 2.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {repid-2.1.3 → repid-2.2.0}/.devcontainer/devcontainer.json +1 -1
- {repid-2.1.3 → repid-2.2.0}/.github/dependabot.yml +16 -0
- {repid-2.1.3 → repid-2.2.0}/.github/workflows/codeql.yml +3 -3
- {repid-2.1.3 → repid-2.2.0}/.github/workflows/mypy.yml +2 -2
- {repid-2.1.3 → repid-2.2.0}/.github/workflows/tests.yaml +1 -1
- {repid-2.1.3 → repid-2.2.0}/.pre-commit-config.yaml +2 -2
- {repid-2.1.3 → repid-2.2.0}/Makefile +1 -1
- {repid-2.1.3 → repid-2.2.0}/PKG-INFO +4 -5
- {repid-2.1.3 → repid-2.2.0}/docs/advanced_user_guide/your_own_brokers.md +8 -1
- {repid-2.1.3 → repid-2.2.0}/docs/advanced_user_guide/your_own_converter.md +3 -1
- {repid-2.1.3 → repid-2.2.0}/docs/advanced_user_guide/your_own_serializer.md +3 -0
- {repid-2.1.3 → repid-2.2.0}/docs/contributing.md +1 -1
- {repid-2.1.3 → repid-2.2.0}/docs/cookbook/chaining_jobs.md +7 -4
- {repid-2.1.3 → repid-2.2.0}/docs/cookbook/large_payloads.md +3 -5
- {repid-2.1.3 → repid-2.2.0}/docs/cookbook/middlewares.md +8 -3
- {repid-2.1.3 → repid-2.2.0}/docs/cookbook/rabbitmq_retries.md +4 -2
- {repid-2.1.3 → repid-2.2.0}/docs/cookbook/sentry_middleware.md +2 -0
- {repid-2.1.3 → repid-2.2.0}/docs/cookbook/testing.md +12 -7
- {repid-2.1.3 → repid-2.2.0}/docs/getting_started/quickstart.md +7 -1
- {repid-2.1.3 → repid-2.2.0}/docs/index.md +6 -4
- {repid-2.1.3 → repid-2.2.0}/docs/integrations/asyncapi.md +3 -5
- {repid-2.1.3 → repid-2.2.0}/docs/integrations/fastapi_and_pydantic.md +6 -4
- {repid-2.1.3 → repid-2.2.0}/docs/user_guide/actors/confirmation_and_errors.md +4 -5
- {repid-2.1.3 → repid-2.2.0}/docs/user_guide/actors/execution.md +4 -0
- {repid-2.1.3 → repid-2.2.0}/docs/user_guide/actors/index.md +1 -0
- {repid-2.1.3 → repid-2.2.0}/docs/user_guide/actors/parsing.md +7 -3
- {repid-2.1.3 → repid-2.2.0}/docs/user_guide/actors/routers.md +4 -0
- {repid-2.1.3 → repid-2.2.0}/docs/user_guide/actors/routing.md +4 -3
- {repid-2.1.3 → repid-2.2.0}/docs/user_guide/dependency_injection.md +18 -14
- {repid-2.1.3 → repid-2.2.0}/docs/user_guide/message_registry.md +3 -3
- {repid-2.1.3 → repid-2.2.0}/docs/user_guide/messages.md +7 -11
- {repid-2.1.3 → repid-2.2.0}/docs/user_guide/raw_message_and_eager_response.md +5 -3
- {repid-2.1.3 → repid-2.2.0}/docs/user_guide/server_registry.md +1 -5
- {repid-2.1.3 → repid-2.2.0}/docs/user_guide/server_specific_parameters.md +5 -5
- {repid-2.1.3 → repid-2.2.0}/docs/user_guide/workers/built_in_servers.md +1 -1
- {repid-2.1.3 → repid-2.2.0}/docs/user_guide/workers/index.md +4 -0
- {repid-2.1.3 → repid-2.2.0}/docs/user_guide/workers/lifecycle.md +4 -4
- {repid-2.1.3 → repid-2.2.0}/mkdocs.yml +1 -1
- {repid-2.1.3 → repid-2.2.0}/pyproject.toml +18 -19
- {repid-2.1.3 → repid-2.2.0}/repid/_runner.py +10 -7
- repid-2.2.0/repid/_worker.py +198 -0
- {repid-2.1.3 → repid-2.2.0}/repid/asyncapi/generator.py +14 -7
- {repid-2.1.3 → repid-2.2.0}/repid/asyncapi/models/asyncapi.py +1 -7
- repid-2.2.0/repid/asyncapi/models/common/correlation_id.py +6 -0
- repid-2.2.0/repid/asyncapi/models/common/external_docs.py +8 -0
- {repid-2.1.3 → repid-2.2.0}/repid/asyncapi/models/common/message.py +1 -7
- {repid-2.1.3 → repid-2.2.0}/repid/asyncapi/models/common/tag.py +1 -7
- {repid-2.1.3 → repid-2.2.0}/repid/asyncapi/models/info.py +1 -7
- {repid-2.1.3 → repid-2.2.0}/repid/asyncapi/models/operations.py +1 -7
- {repid-2.1.3 → repid-2.2.0}/repid/asyncapi/models/servers.py +1 -7
- {repid-2.1.3 → repid-2.2.0}/repid/asyncapi_server.py +2 -2
- {repid-2.1.3 → repid-2.2.0}/repid/connections/abc.py +2 -2
- {repid-2.1.3 → repid-2.2.0}/repid/connections/amqp/_uamqp/_encode.py +1 -1
- {repid-2.1.3 → repid-2.2.0}/repid/connections/amqp/helpers.py +41 -24
- {repid-2.1.3 → repid-2.2.0}/repid/connections/amqp/message_broker.py +16 -2
- {repid-2.1.3 → repid-2.2.0}/repid/connections/amqp/protocol/connection.py +2 -4
- {repid-2.1.3 → repid-2.2.0}/repid/connections/amqp/protocol/links.py +5 -5
- {repid-2.1.3 → repid-2.2.0}/repid/connections/amqp/protocol/session.py +2 -2
- {repid-2.1.3 → repid-2.2.0}/repid/connections/amqp/protocol/transport.py +2 -4
- {repid-2.1.3 → repid-2.2.0}/repid/connections/amqp/subscriber.py +1 -1
- {repid-2.1.3 → repid-2.2.0}/repid/connections/in_memory/message_broker.py +10 -0
- repid-2.2.0/repid/connections/in_memory/utils.py +22 -0
- {repid-2.1.3 → repid-2.2.0}/repid/connections/kafka/message.py +0 -3
- {repid-2.1.3 → repid-2.2.0}/repid/connections/kafka/message_broker.py +15 -4
- {repid-2.1.3 → repid-2.2.0}/repid/connections/kafka/protocols.py +1 -1
- {repid-2.1.3 → repid-2.2.0}/repid/connections/nats/message_broker.py +70 -45
- {repid-2.1.3 → repid-2.2.0}/repid/connections/pubsub/message_broker.py +21 -5
- repid-2.2.0/repid/connections/pubsub/protocol/control_batcher.py +301 -0
- {repid-2.1.3 → repid-2.2.0}/repid/connections/pubsub/protocol/proto.py +1 -1
- {repid-2.1.3 → repid-2.2.0}/repid/connections/pubsub/protocol/received_message.py +25 -5
- {repid-2.1.3 → repid-2.2.0}/repid/connections/redis/message_broker.py +318 -57
- {repid-2.1.3 → repid-2.2.0}/repid/connections/sqs/message.py +95 -73
- {repid-2.1.3 → repid-2.2.0}/repid/converter.py +1 -1
- {repid-2.1.3 → repid-2.2.0}/repid/main.py +2 -2
- {repid-2.1.3 → repid-2.2.0}/repid/router.py +263 -185
- {repid-2.1.3 → repid-2.2.0}/repid/test_client.py +4 -5
- {repid-2.1.3 → repid-2.2.0}/tests/integration/conftest.py +8 -5
- {repid-2.1.3 → repid-2.2.0}/tests/integration/test_kafka_specific.py +10 -2
- {repid-2.1.3 → repid-2.2.0}/tests/integration/test_nats_specific.py +8 -7
- repid-2.2.0/tests/integration/test_redis_specific.py +304 -0
- {repid-2.1.3 → repid-2.2.0}/tests/integration/test_sqs_specific.py +68 -107
- {repid-2.1.3 → repid-2.2.0}/tests/unit/amqp/test_amqp_transport.py +8 -2
- {repid-2.1.3 → repid-2.2.0}/tests/unit/amqp/test_encoding_decoding.py +5 -5
- {repid-2.1.3 → repid-2.2.0}/tests/unit/amqp/test_message_broker.py +155 -0
- {repid-2.1.3 → repid-2.2.0}/tests/unit/amqp/test_session.py +1 -1
- {repid-2.1.3 → repid-2.2.0}/tests/unit/amqp/test_uamqp_types.py +2 -2
- {repid-2.1.3 → repid-2.2.0}/tests/unit/in_memory/test_message_broker.py +63 -0
- repid-2.2.0/tests/unit/in_memory/test_utils.py +14 -0
- {repid-2.1.3 → repid-2.2.0}/tests/unit/pubsub/protocol/test_control_batcher.py +132 -4
- {repid-2.1.3 → repid-2.2.0}/tests/unit/pubsub/protocol/test_received_message.py +143 -0
- {repid-2.1.3 → repid-2.2.0}/tests/unit/pubsub/test_message_broker.py +95 -0
- repid-2.2.0/tests/unit/redis/test_connection.py +65 -0
- {repid-2.1.3 → repid-2.2.0}/tests/unit/redis/test_message_broker.py +939 -8
- repid-2.2.0/tests/unit/sqs/test_message.py +164 -0
- {repid-2.1.3 → repid-2.2.0}/tests/unit/test_asyncapi_generator.py +19 -0
- repid-2.2.0/tests/unit/test_kafka_connection.py +67 -0
- repid-2.2.0/tests/unit/test_nats_connection.py +96 -0
- repid-2.2.0/tests/unit/test_router.py +444 -0
- {repid-2.1.3 → repid-2.2.0}/tests/unit/test_runner.py +94 -15
- {repid-2.1.3 → repid-2.2.0}/tests/unit/test_test_client.py +22 -0
- {repid-2.1.3 → repid-2.2.0}/tests/unit/test_worker.py +160 -8
- repid-2.2.0/uv.lock +3109 -0
- repid-2.1.3/repid/_worker.py +0 -143
- repid-2.1.3/repid/asyncapi/models/common/correlation_id.py +0 -12
- repid-2.1.3/repid/asyncapi/models/common/external_docs.py +0 -14
- repid-2.1.3/repid/connections/in_memory/utils.py +0 -44
- repid-2.1.3/repid/connections/pubsub/protocol/control_batcher.py +0 -225
- repid-2.1.3/tests/unit/in_memory/test_utils.py +0 -19
- repid-2.1.3/tests/unit/test_router.py +0 -218
- repid-2.1.3/uv.lock +0 -2920
- {repid-2.1.3 → repid-2.2.0}/.github/CODE_OF_CONDUCT.md +0 -0
- {repid-2.1.3 → repid-2.2.0}/.github/FUNDING.yml +0 -0
- {repid-2.1.3 → repid-2.2.0}/.github/ISSUE_TEMPLATE/bug_report.md +0 -0
- {repid-2.1.3 → repid-2.2.0}/.github/ISSUE_TEMPLATE/feature_request.md +0 -0
- {repid-2.1.3 → repid-2.2.0}/.github/ISSUE_TEMPLATE/other.md +0 -0
- {repid-2.1.3 → repid-2.2.0}/.github/PULL_REQUEST_TEMPLATE.md +0 -0
- {repid-2.1.3 → repid-2.2.0}/.github/workflows/dependency-review.yml +0 -0
- {repid-2.1.3 → repid-2.2.0}/.github/workflows/docs.yml +0 -0
- {repid-2.1.3 → repid-2.2.0}/.github/workflows/release.yaml +0 -0
- {repid-2.1.3 → repid-2.2.0}/.gitignore +0 -0
- {repid-2.1.3 → repid-2.2.0}/LICENSE +0 -0
- {repid-2.1.3 → repid-2.2.0}/README.md +0 -0
- {repid-2.1.3 → repid-2.2.0}/SECURITY.md +0 -0
- {repid-2.1.3 → repid-2.2.0}/docs/benchmarks.md +0 -0
- {repid-2.1.3 → repid-2.2.0}/docs/benchmarks_img/.gitignore +0 -0
- {repid-2.1.3 → repid-2.2.0}/docs/benchmarks_img/chart.svg +0 -0
- {repid-2.1.3 → repid-2.2.0}/docs/cookbook/opentelemetry_middleware.md +0 -0
- {repid-2.1.3 → repid-2.2.0}/docs/features.md +0 -0
- {repid-2.1.3 → repid-2.2.0}/docs/getting_started/glossary.md +0 -0
- {repid-2.1.3 → repid-2.2.0}/docs/getting_started/supported_brokers.md +0 -0
- {repid-2.1.3 → repid-2.2.0}/docs/overrides/partials/integrations/analytics/custom.html +0 -0
- {repid-2.1.3 → repid-2.2.0}/docs/playground.md +0 -0
- {repid-2.1.3 → repid-2.2.0}/docs/user_guide/workers/concurrency.md +0 -0
- {repid-2.1.3 → repid-2.2.0}/repid/__init__.py +0 -0
- {repid-2.1.3 → repid-2.2.0}/repid/_utils/__init__.py +0 -0
- {repid-2.1.3 → repid-2.2.0}/repid/_utils/asyncify_.py +0 -0
- {repid-2.1.3 → repid-2.2.0}/repid/_utils/is_installed.py +0 -0
- {repid-2.1.3 → repid-2.2.0}/repid/_utils/json_encoder.py +0 -0
- {repid-2.1.3 → repid-2.2.0}/repid/_utils/not_set.py +0 -0
- {repid-2.1.3 → repid-2.2.0}/repid/asyncapi/__init__.py +0 -0
- {repid-2.1.3 → repid-2.2.0}/repid/asyncapi/models/__init__.py +0 -0
- {repid-2.1.3 → repid-2.2.0}/repid/asyncapi/models/channels.py +0 -0
- {repid-2.1.3 → repid-2.2.0}/repid/asyncapi/models/common/__init__.py +0 -0
- {repid-2.1.3 → repid-2.2.0}/repid/asyncapi/models/common/bindings.py +0 -0
- {repid-2.1.3 → repid-2.2.0}/repid/asyncapi/models/common/reference.py +0 -0
- {repid-2.1.3 → repid-2.2.0}/repid/asyncapi/models/components.py +0 -0
- {repid-2.1.3 → repid-2.2.0}/repid/connections/__init__.py +0 -0
- {repid-2.1.3 → repid-2.2.0}/repid/connections/amqp/__init__.py +0 -0
- {repid-2.1.3 → repid-2.2.0}/repid/connections/amqp/_uamqp/LICENSE.txt +0 -0
- {repid-2.1.3 → repid-2.2.0}/repid/connections/amqp/_uamqp/_decode.py +0 -0
- {repid-2.1.3 → repid-2.2.0}/repid/connections/amqp/_uamqp/amqptypes.py +0 -0
- {repid-2.1.3 → repid-2.2.0}/repid/connections/amqp/_uamqp/constants.py +0 -0
- {repid-2.1.3 → repid-2.2.0}/repid/connections/amqp/_uamqp/endpoints.py +0 -0
- {repid-2.1.3 → repid-2.2.0}/repid/connections/amqp/_uamqp/message.py +0 -0
- {repid-2.1.3 → repid-2.2.0}/repid/connections/amqp/_uamqp/outcomes.py +0 -0
- {repid-2.1.3 → repid-2.2.0}/repid/connections/amqp/_uamqp/performatives.py +0 -0
- {repid-2.1.3 → repid-2.2.0}/repid/connections/amqp/protocol/__init__.py +0 -0
- {repid-2.1.3 → repid-2.2.0}/repid/connections/amqp/protocol/events.py +0 -0
- {repid-2.1.3 → repid-2.2.0}/repid/connections/amqp/protocol/managed.py +0 -0
- {repid-2.1.3 → repid-2.2.0}/repid/connections/amqp/protocol/reconnect.py +0 -0
- {repid-2.1.3 → repid-2.2.0}/repid/connections/amqp/protocol/states.py +0 -0
- {repid-2.1.3 → repid-2.2.0}/repid/connections/in_memory/__init__.py +0 -0
- {repid-2.1.3 → repid-2.2.0}/repid/connections/kafka/__init__.py +0 -0
- {repid-2.1.3 → repid-2.2.0}/repid/connections/kafka/subscriber.py +0 -0
- {repid-2.1.3 → repid-2.2.0}/repid/connections/nats/__init__.py +0 -0
- {repid-2.1.3 → repid-2.2.0}/repid/connections/pubsub/__init__.py +0 -0
- {repid-2.1.3 → repid-2.2.0}/repid/connections/pubsub/helpers.py +0 -0
- {repid-2.1.3 → repid-2.2.0}/repid/connections/pubsub/protocol/__init__.py +0 -0
- {repid-2.1.3 → repid-2.2.0}/repid/connections/pubsub/protocol/_helpers.py +0 -0
- {repid-2.1.3 → repid-2.2.0}/repid/connections/pubsub/protocol/channel.py +0 -0
- {repid-2.1.3 → repid-2.2.0}/repid/connections/pubsub/protocol/client.py +0 -0
- {repid-2.1.3 → repid-2.2.0}/repid/connections/pubsub/protocol/credentials.py +0 -0
- {repid-2.1.3 → repid-2.2.0}/repid/connections/pubsub/protocol/resilience.py +0 -0
- {repid-2.1.3 → repid-2.2.0}/repid/connections/pubsub/protocol/subscriber.py +0 -0
- {repid-2.1.3 → repid-2.2.0}/repid/connections/redis/__init__.py +0 -0
- {repid-2.1.3 → repid-2.2.0}/repid/connections/sqs/__init__.py +0 -0
- {repid-2.1.3 → repid-2.2.0}/repid/connections/sqs/constants.py +0 -0
- {repid-2.1.3 → repid-2.2.0}/repid/connections/sqs/message_broker.py +0 -0
- {repid-2.1.3 → repid-2.2.0}/repid/connections/sqs/subscriber.py +0 -0
- {repid-2.1.3 → repid-2.2.0}/repid/data/__init__.py +0 -0
- {repid-2.1.3 → repid-2.2.0}/repid/data/actor.py +0 -0
- {repid-2.1.3 → repid-2.2.0}/repid/data/channel.py +0 -0
- {repid-2.1.3 → repid-2.2.0}/repid/data/contact.py +0 -0
- {repid-2.1.3 → repid-2.2.0}/repid/data/converter_input_schema.py +0 -0
- {repid-2.1.3 → repid-2.2.0}/repid/data/external_docs.py +0 -0
- {repid-2.1.3 → repid-2.2.0}/repid/data/license.py +0 -0
- {repid-2.1.3 → repid-2.2.0}/repid/data/message.py +0 -0
- {repid-2.1.3 → repid-2.2.0}/repid/data/message_schema.py +0 -0
- {repid-2.1.3 → repid-2.2.0}/repid/data/operation.py +0 -0
- {repid-2.1.3 → repid-2.2.0}/repid/data/runner_info.py +0 -0
- {repid-2.1.3 → repid-2.2.0}/repid/data/tag.py +0 -0
- {repid-2.1.3 → repid-2.2.0}/repid/dependencies/__init__.py +0 -0
- {repid-2.1.3 → repid-2.2.0}/repid/dependencies/_utils.py +0 -0
- {repid-2.1.3 → repid-2.2.0}/repid/dependencies/depends.py +0 -0
- {repid-2.1.3 → repid-2.2.0}/repid/dependencies/full_payload.py +0 -0
- {repid-2.1.3 → repid-2.2.0}/repid/dependencies/header_dependency.py +0 -0
- {repid-2.1.3 → repid-2.2.0}/repid/dependencies/message_dependency.py +0 -0
- {repid-2.1.3 → repid-2.2.0}/repid/health_check_server.py +0 -0
- {repid-2.1.3 → repid-2.2.0}/repid/logger.py +0 -0
- {repid-2.1.3 → repid-2.2.0}/repid/message_registry.py +0 -0
- {repid-2.1.3 → repid-2.2.0}/repid/middlewares.py +0 -0
- {repid-2.1.3 → repid-2.2.0}/repid/py.typed +0 -0
- {repid-2.1.3 → repid-2.2.0}/repid/serializer.py +0 -0
- {repid-2.1.3 → repid-2.2.0}/repid/server_registry.py +0 -0
- {repid-2.1.3 → repid-2.2.0}/tests/__init__.py +0 -0
- {repid-2.1.3 → repid-2.2.0}/tests/integration/__init__.py +0 -0
- {repid-2.1.3 → repid-2.2.0}/tests/integration/pubsub_proto_helpers.py +0 -0
- {repid-2.1.3 → repid-2.2.0}/tests/integration/rabbitmq_definitions.json +0 -0
- {repid-2.1.3 → repid-2.2.0}/tests/integration/test_asyncapi_compatibility.py +0 -0
- {repid-2.1.3 → repid-2.2.0}/tests/integration/test_default_flow.py +0 -0
- {repid-2.1.3 → repid-2.2.0}/tests/integration/test_rabbitmq_specific.py +0 -0
- {repid-2.1.3 → repid-2.2.0}/tests/integration/test_worker.py +0 -0
- {repid-2.1.3 → repid-2.2.0}/tests/unit/__init__.py +0 -0
- {repid-2.1.3 → repid-2.2.0}/tests/unit/amqp/__init__.py +0 -0
- {repid-2.1.3 → repid-2.2.0}/tests/unit/amqp/conftest.py +0 -0
- {repid-2.1.3 → repid-2.2.0}/tests/unit/amqp/test_connection.py +0 -0
- {repid-2.1.3 → repid-2.2.0}/tests/unit/amqp/test_event_emitter.py +0 -0
- {repid-2.1.3 → repid-2.2.0}/tests/unit/amqp/test_frame_buffer.py +0 -0
- {repid-2.1.3 → repid-2.2.0}/tests/unit/amqp/test_links.py +0 -0
- {repid-2.1.3 → repid-2.2.0}/tests/unit/amqp/test_logging.py +0 -0
- {repid-2.1.3 → repid-2.2.0}/tests/unit/amqp/test_managed.py +0 -0
- {repid-2.1.3 → repid-2.2.0}/tests/unit/amqp/test_managed_pools.py +0 -0
- {repid-2.1.3 → repid-2.2.0}/tests/unit/amqp/test_message.py +0 -0
- {repid-2.1.3 → repid-2.2.0}/tests/unit/amqp/test_metrics.py +0 -0
- {repid-2.1.3 → repid-2.2.0}/tests/unit/amqp/test_reconnect.py +0 -0
- {repid-2.1.3 → repid-2.2.0}/tests/unit/amqp/test_state_machine.py +0 -0
- {repid-2.1.3 → repid-2.2.0}/tests/unit/amqp/utils.py +0 -0
- {repid-2.1.3 → repid-2.2.0}/tests/unit/conftest.py +0 -0
- {repid-2.1.3 → repid-2.2.0}/tests/unit/in_memory/__init__.py +0 -0
- {repid-2.1.3 → repid-2.2.0}/tests/unit/pubsub/__init__.py +0 -0
- {repid-2.1.3 → repid-2.2.0}/tests/unit/pubsub/protocol/test_channel.py +0 -0
- {repid-2.1.3 → repid-2.2.0}/tests/unit/pubsub/protocol/test_client.py +0 -0
- {repid-2.1.3 → repid-2.2.0}/tests/unit/pubsub/protocol/test_credentials.py +0 -0
- {repid-2.1.3 → repid-2.2.0}/tests/unit/pubsub/protocol/test_helpers_internal.py +0 -0
- {repid-2.1.3 → repid-2.2.0}/tests/unit/pubsub/protocol/test_proto.py +0 -0
- {repid-2.1.3 → repid-2.2.0}/tests/unit/pubsub/protocol/test_resilience.py +0 -0
- {repid-2.1.3 → repid-2.2.0}/tests/unit/pubsub/protocol/test_subscriber.py +0 -0
- {repid-2.1.3 → repid-2.2.0}/tests/unit/pubsub/protocol/test_subscriber_execution.py +0 -0
- {repid-2.1.3 → repid-2.2.0}/tests/unit/pubsub/test_helpers.py +0 -0
- {repid-2.1.3 → repid-2.2.0}/tests/unit/redis/__init__.py +0 -0
- {repid-2.1.3 → repid-2.2.0}/tests/unit/redis/test_redis_keep_alive.py +0 -0
- {repid-2.1.3 → repid-2.2.0}/tests/unit/test_channel.py +0 -0
- {repid-2.1.3 → repid-2.2.0}/tests/unit/test_converter.py +0 -0
- {repid-2.1.3 → repid-2.2.0}/tests/unit/test_dependencies.py +0 -0
- {repid-2.1.3 → repid-2.2.0}/tests/unit/test_health_check_server.py +0 -0
- {repid-2.1.3 → repid-2.2.0}/tests/unit/test_main.py +0 -0
- {repid-2.1.3 → repid-2.2.0}/tests/unit/test_middleware.py +0 -0
- {repid-2.1.3 → repid-2.2.0}/tests/unit/test_runner_manual_explicit.py +0 -0
- {repid-2.1.3 → repid-2.2.0}/tests/unit/test_serializer.py +0 -0
- {repid-2.1.3 → repid-2.2.0}/tests/unit/test_server_registry.py +0 -0
- {repid-2.1.3 → repid-2.2.0}/tests/unit/test_utils.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "Repid Devcontainer",
|
|
3
|
-
"image": "mcr.microsoft.com/devcontainers/python:1-3.
|
|
3
|
+
"image": "mcr.microsoft.com/devcontainers/python:1-3.11-bookworm",
|
|
4
4
|
"features": {
|
|
5
5
|
"ghcr.io/va-h/devcontainers-features/uv:1": {},
|
|
6
6
|
"ghcr.io/jungaretti/features/make:1": {},
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
version: 2
|
|
2
|
+
multi-ecosystem-groups:
|
|
3
|
+
codeql:
|
|
4
|
+
schedule:
|
|
5
|
+
interval: monthly
|
|
2
6
|
updates:
|
|
3
7
|
- package-ecosystem: uv
|
|
4
8
|
directory: /
|
|
@@ -18,3 +22,15 @@ updates:
|
|
|
18
22
|
interval: daily
|
|
19
23
|
commit-message:
|
|
20
24
|
prefix: ⬆
|
|
25
|
+
ignore:
|
|
26
|
+
- dependency-name: github/codeql-action
|
|
27
|
+
|
|
28
|
+
- package-ecosystem: github-actions
|
|
29
|
+
directory: /
|
|
30
|
+
schedule:
|
|
31
|
+
interval: monthly
|
|
32
|
+
patterns:
|
|
33
|
+
- github/codeql-action
|
|
34
|
+
multi-ecosystem-group: codeql
|
|
35
|
+
commit-message:
|
|
36
|
+
prefix: ⬆
|
|
@@ -42,7 +42,7 @@ jobs:
|
|
|
42
42
|
|
|
43
43
|
# Initializes the CodeQL tools for scanning.
|
|
44
44
|
- name: Initialize CodeQL
|
|
45
|
-
uses: github/codeql-action/init@v4
|
|
45
|
+
uses: github/codeql-action/init@v4.39.1
|
|
46
46
|
with:
|
|
47
47
|
languages: ${{ matrix.language }}
|
|
48
48
|
# If you wish to specify custom queries, you can do so here or in a config file.
|
|
@@ -55,7 +55,7 @@ jobs:
|
|
|
55
55
|
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
|
56
56
|
# If this step fails, then you should remove it and run the build manually (see below)
|
|
57
57
|
- name: Autobuild
|
|
58
|
-
uses: github/codeql-action/autobuild@v4
|
|
58
|
+
uses: github/codeql-action/autobuild@v4.39.1
|
|
59
59
|
|
|
60
60
|
# ℹ️ Command-line programs to run using the OS shell.
|
|
61
61
|
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
|
|
@@ -68,4 +68,4 @@ jobs:
|
|
|
68
68
|
# ./location_of_script_within_repo/buildscript.sh
|
|
69
69
|
|
|
70
70
|
- name: Perform CodeQL Analysis
|
|
71
|
-
uses: github/codeql-action/analyze@v4
|
|
71
|
+
uses: github/codeql-action/analyze@v4.39.1
|
|
@@ -7,7 +7,7 @@ on:
|
|
|
7
7
|
|
|
8
8
|
jobs:
|
|
9
9
|
mypy:
|
|
10
|
-
name: MyPy (Python 3.
|
|
10
|
+
name: MyPy (Python 3.11)
|
|
11
11
|
runs-on: ubuntu-latest
|
|
12
12
|
|
|
13
13
|
steps:
|
|
@@ -18,7 +18,7 @@ jobs:
|
|
|
18
18
|
uses: astral-sh/setup-uv@v7
|
|
19
19
|
|
|
20
20
|
- name: Install or update dependencies
|
|
21
|
-
run: uv sync --frozen --all-extras --all-groups --python 3.
|
|
21
|
+
run: uv sync --frozen --all-extras --all-groups --python 3.11
|
|
22
22
|
|
|
23
23
|
- name: Add mypy annotator
|
|
24
24
|
uses: pr-annotators/mypy-pr-annotator@v1.0.0
|
|
@@ -19,14 +19,14 @@ repos:
|
|
|
19
19
|
- id: end-of-file-fixer
|
|
20
20
|
|
|
21
21
|
- repo: https://github.com/astral-sh/ruff-pre-commit
|
|
22
|
-
rev: v0.
|
|
22
|
+
rev: v0.17.3
|
|
23
23
|
hooks:
|
|
24
24
|
- id: ruff-check
|
|
25
25
|
args: [--fix, --exit-non-zero-on-fix]
|
|
26
26
|
- id: ruff-format
|
|
27
27
|
|
|
28
28
|
- repo: https://github.com/igorshubovych/markdownlint-cli
|
|
29
|
-
rev: v0.
|
|
29
|
+
rev: v0.50.0
|
|
30
30
|
hooks:
|
|
31
31
|
- id: markdownlint-fix
|
|
32
32
|
args: [--config=pyproject.toml, --configPointer=/tool/markdownlint]
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
uv -V || echo 'Please install uv: https://docs.astral.sh/uv/getting-started/installation/'
|
|
6
6
|
|
|
7
7
|
install: .uv
|
|
8
|
-
uv sync --frozen --all-extras --all-groups --python 3.
|
|
8
|
+
uv sync --frozen --all-extras --all-groups --python 3.11
|
|
9
9
|
uv run pre-commit install --install-hooks
|
|
10
10
|
|
|
11
11
|
rebuild-lockfiles: .uv
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
2
|
Name: repid
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.2.0
|
|
4
4
|
Summary: Repid is a simple, fast, and extensible async task queue framework, with built-in AsyncAPI 3.0 schema generation.
|
|
5
5
|
Project-URL: documentation, https://repid.aleksul.space
|
|
6
6
|
Project-URL: funding, https://github.com/sponsors/aleksul
|
|
@@ -12,16 +12,15 @@ License-File: LICENSE
|
|
|
12
12
|
Classifier: Development Status :: 5 - Production/Stable
|
|
13
13
|
Classifier: License :: OSI Approved :: MIT License
|
|
14
14
|
Classifier: Programming Language :: Python :: 3
|
|
15
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
16
15
|
Classifier: Programming Language :: Python :: 3.11
|
|
17
16
|
Classifier: Programming Language :: Python :: 3.12
|
|
18
17
|
Classifier: Programming Language :: Python :: 3.13
|
|
19
18
|
Classifier: Programming Language :: Python :: 3.14
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.15
|
|
20
20
|
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
21
21
|
Classifier: Typing :: Typed
|
|
22
|
-
Requires-Python: >=3.
|
|
22
|
+
Requires-Python: >=3.11
|
|
23
23
|
Requires-Dist: packaging>=22.0
|
|
24
|
-
Requires-Dist: typing-extensions<5.0.0,>=4.3.0; python_version < '3.11'
|
|
25
24
|
Provides-Extra: amqp
|
|
26
25
|
Provides-Extra: kafka
|
|
27
26
|
Requires-Dist: aiokafka<0.15.0,>=0.14.0; extra == 'kafka'
|
|
@@ -15,7 +15,14 @@ Here is a simplified overview of what you need to implement:
|
|
|
15
15
|
import asyncio
|
|
16
16
|
from typing import Mapping, Sequence, Callable, Coroutine, Any
|
|
17
17
|
from collections.abc import AbstractAsyncContextManager
|
|
18
|
-
from repid.connections.abc import
|
|
18
|
+
from repid.connections.abc import (
|
|
19
|
+
ServerT,
|
|
20
|
+
SubscriberT,
|
|
21
|
+
SentMessageT,
|
|
22
|
+
ReceivedMessageT,
|
|
23
|
+
CapabilitiesT,
|
|
24
|
+
)
|
|
25
|
+
|
|
19
26
|
|
|
20
27
|
class MyCustomServer:
|
|
21
28
|
# 1. Server Metadata Properties for AsyncAPI
|
|
@@ -19,6 +19,7 @@ from repid.connections.abc import ReceivedMessageT, ServerT
|
|
|
19
19
|
from repid.data import ActorData, CorrelationId, ConverterInputSchema
|
|
20
20
|
from repid.serializer import SerializerT
|
|
21
21
|
|
|
22
|
+
|
|
22
23
|
class MyCustomConverter:
|
|
23
24
|
def __init__(
|
|
24
25
|
self,
|
|
@@ -59,7 +60,7 @@ class MyCustomConverter:
|
|
|
59
60
|
"$id": "https://example.com/product.schema.json",
|
|
60
61
|
"title": "Product",
|
|
61
62
|
"description": "A product in the catalog",
|
|
62
|
-
"type": "object"
|
|
63
|
+
"type": "object",
|
|
63
64
|
},
|
|
64
65
|
content_type="application/json",
|
|
65
66
|
headers_schema=None, # or a JSON schema
|
|
@@ -77,6 +78,7 @@ from repid import Router
|
|
|
77
78
|
|
|
78
79
|
router = Router()
|
|
79
80
|
|
|
81
|
+
|
|
80
82
|
@router.actor(converter=MyCustomConverter)
|
|
81
83
|
async def my_actor(data: dict) -> None:
|
|
82
84
|
pass
|
|
@@ -12,11 +12,13 @@ It's a callable that takes `Any` data and returns `bytes`.
|
|
|
12
12
|
from typing import Any
|
|
13
13
|
import msgpack
|
|
14
14
|
|
|
15
|
+
|
|
15
16
|
def my_custom_serializer(data: Any) -> bytes:
|
|
16
17
|
# 1. Convert `data` into a storable string or binary format
|
|
17
18
|
# 2. Return the encoded bytes
|
|
18
19
|
return msgpack.packb(data)
|
|
19
20
|
|
|
21
|
+
|
|
20
22
|
# You can also use a class with a `__call__` method:
|
|
21
23
|
class MsgPackSerializer:
|
|
22
24
|
def __call__(self, data: Any) -> bytes:
|
|
@@ -45,6 +47,7 @@ from repid import Repid
|
|
|
45
47
|
|
|
46
48
|
app = Repid()
|
|
47
49
|
|
|
50
|
+
|
|
48
51
|
async def main() -> None:
|
|
49
52
|
await app.send_message_json(
|
|
50
53
|
channel="default",
|
|
@@ -41,7 +41,7 @@ It will create virtual environment and install inside of it all dependencies, in
|
|
|
41
41
|
which are needed for development.
|
|
42
42
|
|
|
43
43
|
!!! example "Python version"
|
|
44
|
-
Use lowest supported by `repid` version of Python (== 3.
|
|
44
|
+
Use lowest supported by `repid` version of Python (== 3.11 for now) for your venv.
|
|
45
45
|
|
|
46
46
|
To activate a venv run:
|
|
47
47
|
|
|
@@ -21,6 +21,7 @@ app.servers.register_server("default", InMemoryServer(), is_default=True)
|
|
|
21
21
|
|
|
22
22
|
router = Router()
|
|
23
23
|
|
|
24
|
+
|
|
24
25
|
@router.actor(channel="registration")
|
|
25
26
|
async def create_user(username: str, message: Message) -> None:
|
|
26
27
|
# 1. Pretend we save to the database and generate an ID
|
|
@@ -32,24 +33,25 @@ async def create_user(username: str, message: Message) -> None:
|
|
|
32
33
|
await message.send_message_json(
|
|
33
34
|
channel="email",
|
|
34
35
|
payload={"user_id": user_id, "username": username},
|
|
35
|
-
headers={"topic": "send_welcome_email"}
|
|
36
|
+
headers={"topic": "send_welcome_email"},
|
|
36
37
|
)
|
|
37
38
|
|
|
38
39
|
# The current message is automatically acknowledged when this actor finishes successfully.
|
|
39
40
|
|
|
41
|
+
|
|
40
42
|
@router.actor(channel="email")
|
|
41
43
|
async def send_welcome_email(user_id: int, username: str) -> None:
|
|
42
44
|
print(f"Sending welcome email to User #{user_id} ({username})!")
|
|
43
45
|
|
|
46
|
+
|
|
44
47
|
app.include_router(router)
|
|
45
48
|
|
|
49
|
+
|
|
46
50
|
async def main() -> None:
|
|
47
51
|
async with app.servers.default.connection():
|
|
48
52
|
# Kick off the chain by sending the first message
|
|
49
53
|
await app.send_message_json(
|
|
50
|
-
channel="registration",
|
|
51
|
-
payload={"username": "Alex"},
|
|
52
|
-
headers={"topic": "create_user"}
|
|
54
|
+
channel="registration", payload={"username": "Alex"}, headers={"topic": "create_user"}
|
|
53
55
|
)
|
|
54
56
|
|
|
55
57
|
# Process the queue.
|
|
@@ -58,6 +60,7 @@ async def main() -> None:
|
|
|
58
60
|
# which will then be processed in the next iteration!
|
|
59
61
|
await app.run_worker(messages_limit=2)
|
|
60
62
|
|
|
63
|
+
|
|
61
64
|
if __name__ == "__main__":
|
|
62
65
|
asyncio.run(main())
|
|
63
66
|
```
|
|
@@ -46,6 +46,7 @@ from repid import Repid
|
|
|
46
46
|
|
|
47
47
|
# Assuming `app` is your initialized and configured Repid instance
|
|
48
48
|
|
|
49
|
+
|
|
49
50
|
async def enqueue_audience_processing(job_id: int, s3_key: str) -> None:
|
|
50
51
|
await app.send_message_json(
|
|
51
52
|
channel="process_audience",
|
|
@@ -72,15 +73,12 @@ from repid import Router
|
|
|
72
73
|
|
|
73
74
|
router = Router()
|
|
74
75
|
|
|
76
|
+
|
|
75
77
|
def _heavy_computation(file_data: bytes) -> bytes: # (1)!
|
|
76
78
|
df = pl.read_csv(io.BytesIO(file_data))
|
|
77
79
|
|
|
78
80
|
# Perform heavy lifting: e.g., aggregations and deduplication
|
|
79
|
-
summary_df = (
|
|
80
|
-
df.unique(subset=["email"])
|
|
81
|
-
.group_by("country")
|
|
82
|
-
.agg(pl.len().alias("user_count"))
|
|
83
|
-
)
|
|
81
|
+
summary_df = df.unique(subset=["email"]).group_by("country").agg(pl.len().alias("user_count"))
|
|
84
82
|
|
|
85
83
|
buffer = io.BytesIO()
|
|
86
84
|
summary_df.write_csv(buffer)
|
|
@@ -19,6 +19,7 @@ To create an actor middleware, you implement the `ActorMiddlewareT` protocol.
|
|
|
19
19
|
from typing import Any, Coroutine, Callable
|
|
20
20
|
from repid import ReceivedMessageT, ActorData
|
|
21
21
|
|
|
22
|
+
|
|
22
23
|
async def logging_middleware[T](
|
|
23
24
|
call_next: Callable[[ReceivedMessageT, ActorData], Coroutine[None, None, T]],
|
|
24
25
|
message: ReceivedMessageT,
|
|
@@ -36,7 +37,7 @@ To create an actor middleware, you implement the `ActorMiddlewareT` protocol.
|
|
|
36
37
|
raise e
|
|
37
38
|
```
|
|
38
39
|
|
|
39
|
-
=== "Python 3.
|
|
40
|
+
=== "Python 3.11+"
|
|
40
41
|
|
|
41
42
|
```python
|
|
42
43
|
from typing import Any, Coroutine, Callable, TypeVar
|
|
@@ -44,6 +45,7 @@ To create an actor middleware, you implement the `ActorMiddlewareT` protocol.
|
|
|
44
45
|
|
|
45
46
|
T = TypeVar("T")
|
|
46
47
|
|
|
48
|
+
|
|
47
49
|
async def logging_middleware(
|
|
48
50
|
call_next: Callable[[ReceivedMessageT, ActorData], Coroutine[None, None, T]],
|
|
49
51
|
message: ReceivedMessageT,
|
|
@@ -76,6 +78,7 @@ To create a producer middleware, you implement the `ProducerMiddlewareT` protoco
|
|
|
76
78
|
from typing import Any, Coroutine, Callable
|
|
77
79
|
from repid import MessageData
|
|
78
80
|
|
|
81
|
+
|
|
79
82
|
async def producer_tracing_middleware[T](
|
|
80
83
|
call_next: Callable[
|
|
81
84
|
[str, MessageData, dict[str, object] | None],
|
|
@@ -104,7 +107,7 @@ To create a producer middleware, you implement the `ProducerMiddlewareT` protoco
|
|
|
104
107
|
return await call_next(channel, message, server_specific_parameters)
|
|
105
108
|
```
|
|
106
109
|
|
|
107
|
-
=== "Python 3.
|
|
110
|
+
=== "Python 3.11+"
|
|
108
111
|
|
|
109
112
|
```python
|
|
110
113
|
import uuid
|
|
@@ -113,6 +116,7 @@ To create a producer middleware, you implement the `ProducerMiddlewareT` protoco
|
|
|
113
116
|
|
|
114
117
|
T = TypeVar("T")
|
|
115
118
|
|
|
119
|
+
|
|
116
120
|
async def producer_tracing_middleware(
|
|
117
121
|
call_next: Callable[
|
|
118
122
|
[str, MessageData, dict[str, object] | None],
|
|
@@ -156,12 +160,13 @@ from repid import Repid, Router
|
|
|
156
160
|
# Register on the main app
|
|
157
161
|
app = Repid(
|
|
158
162
|
actor_middlewares=[MetricsMiddleware(), LoggingActorMiddleware()],
|
|
159
|
-
producer_middlewares=[TraceIdProducerMiddleware(), ValidationMiddleware()]
|
|
163
|
+
producer_middlewares=[TraceIdProducerMiddleware(), ValidationMiddleware()],
|
|
160
164
|
)
|
|
161
165
|
|
|
162
166
|
# Or register specifically on a router
|
|
163
167
|
router = Router(middlewares=[SpecificRouterMiddleware()])
|
|
164
168
|
|
|
169
|
+
|
|
165
170
|
# Or even a single actor!
|
|
166
171
|
@router.actor(middlewares=[SingleActorMiddleware()])
|
|
167
172
|
async def my_job() -> None:
|
|
@@ -166,6 +166,7 @@ from repid import Message, Router
|
|
|
166
166
|
P = ParamSpec("P")
|
|
167
167
|
R = TypeVar("R")
|
|
168
168
|
|
|
169
|
+
|
|
169
170
|
def with_rabbitmq_retries(
|
|
170
171
|
max_retries: int = 5,
|
|
171
172
|
backoff_delays: list[int] | None = None,
|
|
@@ -188,7 +189,7 @@ def with_rabbitmq_retries(
|
|
|
188
189
|
if "message" not in sig.parameters:
|
|
189
190
|
new_params = [
|
|
190
191
|
*list(sig.parameters.values()),
|
|
191
|
-
inspect.Parameter("message", inspect.Parameter.KEYWORD_ONLY, annotation=Message)
|
|
192
|
+
inspect.Parameter("message", inspect.Parameter.KEYWORD_ONLY, annotation=Message),
|
|
192
193
|
]
|
|
193
194
|
new_sig = sig.replace(parameters=new_params)
|
|
194
195
|
else:
|
|
@@ -221,7 +222,7 @@ def with_rabbitmq_retries(
|
|
|
221
222
|
new_headers["x-retry-count"] = str(retry_count + 1)
|
|
222
223
|
|
|
223
224
|
amqp_to_address = (
|
|
224
|
-
|
|
225
|
+
f"/exchanges/{retry_exchange}/delay.{delay_ms}.{message.channel}" # (5)!
|
|
225
226
|
)
|
|
226
227
|
|
|
227
228
|
await message.send_message(
|
|
@@ -264,6 +265,7 @@ your business logic, and the decorator handles the rest:
|
|
|
264
265
|
```python
|
|
265
266
|
router = Router()
|
|
266
267
|
|
|
268
|
+
|
|
267
269
|
@router.actor(channel="my_work_queue")
|
|
268
270
|
@with_rabbitmq_retries(max_retries=5, retry_exceptions=(ConnectionError, TimeoutError))
|
|
269
271
|
async def process_task(data: dict) -> None:
|
|
@@ -23,6 +23,7 @@ from repid.data import ActorData
|
|
|
23
23
|
|
|
24
24
|
T = TypeVar("T")
|
|
25
25
|
|
|
26
|
+
|
|
26
27
|
async def sentry_actor_middleware(
|
|
27
28
|
call_next: Callable[[ReceivedMessageT, ActorData], Coroutine[None, None, T]],
|
|
28
29
|
message: ReceivedMessageT,
|
|
@@ -63,6 +64,7 @@ app = Repid(actor_middlewares=[sentry_actor_middleware]) # (2)!
|
|
|
63
64
|
|
|
64
65
|
router = Router()
|
|
65
66
|
|
|
67
|
+
|
|
66
68
|
@router.actor(channel="my_queue") # (3)!
|
|
67
69
|
async def process_task(data: dict) -> None:
|
|
68
70
|
print("Processing task...")
|
|
@@ -24,12 +24,14 @@ from repid import Repid, Router
|
|
|
24
24
|
app = Repid(title="My App")
|
|
25
25
|
router = Router()
|
|
26
26
|
|
|
27
|
+
|
|
27
28
|
@router.actor(channel="user_messages")
|
|
28
29
|
async def actor_with_args(user_id: int, user_name: str, user_messages: list[str]) -> list[str]:
|
|
29
30
|
user_message = f"Hi {user_name}! Your id is: {user_id}."
|
|
30
31
|
user_messages.append(user_message)
|
|
31
32
|
return user_messages
|
|
32
33
|
|
|
34
|
+
|
|
33
35
|
app.include_router(router)
|
|
34
36
|
```
|
|
35
37
|
|
|
@@ -44,6 +46,7 @@ import pytest
|
|
|
44
46
|
from repid import TestClient
|
|
45
47
|
from myapp.app import app
|
|
46
48
|
|
|
49
|
+
|
|
47
50
|
async def test_actor_processing() -> None:
|
|
48
51
|
# 1. Initialize the TestClient using your app as the parameter
|
|
49
52
|
async with TestClient(app) as client:
|
|
@@ -51,7 +54,7 @@ async def test_actor_processing() -> None:
|
|
|
51
54
|
await client.send_message_json(
|
|
52
55
|
channel="user_messages",
|
|
53
56
|
payload=dict(user_id=123, user_name="Alex", user_messages=[]),
|
|
54
|
-
headers={"topic": "actor_with_args"}
|
|
57
|
+
headers={"topic": "actor_with_args"},
|
|
55
58
|
)
|
|
56
59
|
|
|
57
60
|
# 3. By default (auto_process=True), the client instantly processes messages.
|
|
@@ -73,12 +76,13 @@ import pytest
|
|
|
73
76
|
from repid import TestClient
|
|
74
77
|
from myapp.app import app
|
|
75
78
|
|
|
79
|
+
|
|
76
80
|
async def test_manual_processing() -> None:
|
|
77
81
|
async with TestClient(app, auto_process=False) as client:
|
|
78
82
|
await client.send_message_json(
|
|
79
83
|
channel="user_messages",
|
|
80
84
|
payload=dict(user_id=123, user_name="Alex", user_messages=[]),
|
|
81
|
-
headers={"topic": "actor_with_args"}
|
|
85
|
+
headers={"topic": "actor_with_args"},
|
|
82
86
|
)
|
|
83
87
|
|
|
84
88
|
# The message is in the queue, but hasn't been processed yet
|
|
@@ -100,11 +104,11 @@ can assert against various properties to make sure your actors behave correctly:
|
|
|
100
104
|
```python
|
|
101
105
|
msg = await client.process_next()
|
|
102
106
|
|
|
103
|
-
assert msg.acked is True
|
|
104
|
-
assert msg.nacked is False
|
|
105
|
-
assert msg.rejected is False
|
|
106
|
-
assert msg.exception is None
|
|
107
|
-
assert msg.result == ["..."]
|
|
107
|
+
assert msg.acked is True # Was it acknowledged?
|
|
108
|
+
assert msg.nacked is False # Was it NACKed?
|
|
109
|
+
assert msg.rejected is False # Was it rejected?
|
|
110
|
+
assert msg.exception is None # Did it raise an exception?
|
|
111
|
+
assert msg.result == ["..."] # The return value of the actor
|
|
108
112
|
```
|
|
109
113
|
|
|
110
114
|
You can retrieve all sent or processed messages using:
|
|
@@ -123,6 +127,7 @@ isolated unit tests by importing your function and calling it directly:
|
|
|
123
127
|
```python title="tests/test_app.py"
|
|
124
128
|
from myapp.app import actor_with_args
|
|
125
129
|
|
|
130
|
+
|
|
126
131
|
async def test_actor_with_args() -> None:
|
|
127
132
|
expected = ["Hi Alex! Your id is: 123."]
|
|
128
133
|
actual = await actor_with_args(user_id=123, user_name="Alex", user_messages=[])
|
|
@@ -89,6 +89,7 @@ app = Repid()
|
|
|
89
89
|
server = AmqpServer("amqp://localhost")
|
|
90
90
|
app.servers.register_server("my_rabbitmq", server, is_default=True)
|
|
91
91
|
|
|
92
|
+
|
|
92
93
|
async def main():
|
|
93
94
|
# Retrieve the default server and open a connection
|
|
94
95
|
async with app.servers.default.connection():
|
|
@@ -96,9 +97,10 @@ async def main():
|
|
|
96
97
|
await app.send_message_json(
|
|
97
98
|
channel="default_queue",
|
|
98
99
|
payload={"message": "Hello, Repid!"},
|
|
99
|
-
headers={"topic": "my_actor"}
|
|
100
|
+
headers={"topic": "my_actor"}, # Don't forget the topic if using topic routing!
|
|
100
101
|
)
|
|
101
102
|
|
|
103
|
+
|
|
102
104
|
if __name__ == "__main__":
|
|
103
105
|
asyncio.run(main())
|
|
104
106
|
```
|
|
@@ -132,12 +134,15 @@ app.servers.register_server("my_rabbitmq", server, is_default=True)
|
|
|
132
134
|
# 2. Create a router and an actor
|
|
133
135
|
router = Router()
|
|
134
136
|
|
|
137
|
+
|
|
135
138
|
@router.actor(channel="default_queue")
|
|
136
139
|
async def my_action(message: str):
|
|
137
140
|
print(f"Executing with payload: {message}")
|
|
138
141
|
|
|
142
|
+
|
|
139
143
|
app.include_router(router)
|
|
140
144
|
|
|
145
|
+
|
|
141
146
|
# 3. Start the worker loop!
|
|
142
147
|
async def run_worker():
|
|
143
148
|
# Like the producer, the connection must be opened first
|
|
@@ -145,6 +150,7 @@ async def run_worker():
|
|
|
145
150
|
# Blocks forever, constantly pulling new messages and running actors
|
|
146
151
|
await app.run_worker()
|
|
147
152
|
|
|
153
|
+
|
|
148
154
|
if __name__ == "__main__":
|
|
149
155
|
asyncio.run(run_worker())
|
|
150
156
|
```
|
|
@@ -39,33 +39,35 @@ app.servers.register_server("default", InMemoryServer(), is_default=True)
|
|
|
39
39
|
# 2. Create a router and an actor
|
|
40
40
|
router = Router()
|
|
41
41
|
|
|
42
|
+
|
|
42
43
|
@router.actor(channel="tasks")
|
|
43
44
|
async def my_awesome_actor(user_id: int) -> None:
|
|
44
45
|
print(f"Processing for {user_id}")
|
|
45
46
|
await asyncio.sleep(1.0)
|
|
46
47
|
|
|
48
|
+
|
|
47
49
|
app.include_router(router)
|
|
48
50
|
|
|
51
|
+
|
|
49
52
|
async def main() -> None:
|
|
50
53
|
# 3. Open connection to interact with the queue
|
|
51
54
|
async with app.servers.default.connection():
|
|
52
55
|
# Producer: Send a message
|
|
53
56
|
await app.send_message_json(
|
|
54
|
-
channel="tasks",
|
|
55
|
-
payload={"user_id": 123},
|
|
56
|
-
headers={"topic": "my_awesome_actor"}
|
|
57
|
+
channel="tasks", payload={"user_id": 123}, headers={"topic": "my_awesome_actor"}
|
|
57
58
|
)
|
|
58
59
|
|
|
59
60
|
# Consumer: Run the worker loop (in a real app, this would be a separate process)
|
|
60
61
|
await app.run_worker(messages_limit=1)
|
|
61
62
|
|
|
63
|
+
|
|
62
64
|
if __name__ == "__main__":
|
|
63
65
|
asyncio.run(main())
|
|
64
66
|
```
|
|
65
67
|
|
|
66
68
|
## Install
|
|
67
69
|
|
|
68
|
-
**Repid** supports Python 3.
|
|
70
|
+
**Repid** supports Python 3.11 and later. Install it with `pip`:
|
|
69
71
|
|
|
70
72
|
```bash
|
|
71
73
|
pip install repid
|
|
@@ -62,16 +62,14 @@ app = Repid()
|
|
|
62
62
|
broker = AmqpServer("amqp://localhost")
|
|
63
63
|
app.servers.register_server("rabbitmq_default", broker, is_default=True)
|
|
64
64
|
|
|
65
|
+
|
|
65
66
|
async def main():
|
|
66
67
|
async with app.servers.default.connection():
|
|
67
68
|
await app.run_worker(
|
|
68
|
-
asyncapi_server=AsyncAPIServerSettings(
|
|
69
|
-
address="0.0.0.0",
|
|
70
|
-
port=8081,
|
|
71
|
-
endpoint_name="/"
|
|
72
|
-
)
|
|
69
|
+
asyncapi_server=AsyncAPIServerSettings(address="0.0.0.0", port=8081, endpoint_name="/")
|
|
73
70
|
)
|
|
74
71
|
|
|
72
|
+
|
|
75
73
|
asyncio.run(main())
|
|
76
74
|
```
|
|
77
75
|
|
|
@@ -29,10 +29,12 @@ from pydantic import BaseModel
|
|
|
29
29
|
|
|
30
30
|
app = Repid()
|
|
31
31
|
|
|
32
|
+
|
|
32
33
|
class MyPydanticModel(BaseModel):
|
|
33
34
|
user_id: int
|
|
34
35
|
actions: list[str]
|
|
35
36
|
|
|
37
|
+
|
|
36
38
|
# Inside an async function:
|
|
37
39
|
await app.send_message_json(
|
|
38
40
|
channel="some_channel",
|
|
@@ -70,6 +72,7 @@ from repid import Repid, AmqpServer
|
|
|
70
72
|
app = Repid()
|
|
71
73
|
app.servers.register_server("default", AmqpServer("amqp://localhost"), is_default=True)
|
|
72
74
|
|
|
75
|
+
|
|
73
76
|
@asynccontextmanager
|
|
74
77
|
async def lifespan(fastapi_app: FastAPI):
|
|
75
78
|
# Open the Repid connection on startup
|
|
@@ -77,15 +80,14 @@ async def lifespan(fastapi_app: FastAPI):
|
|
|
77
80
|
yield
|
|
78
81
|
# The connection automatically closes when the app shuts down
|
|
79
82
|
|
|
83
|
+
|
|
80
84
|
fastapi_app = FastAPI(lifespan=lifespan)
|
|
81
85
|
|
|
86
|
+
|
|
82
87
|
@fastapi_app.post("/create-job")
|
|
83
88
|
async def create_repid_job(data: dict) -> dict:
|
|
84
89
|
# We can safely send messages here because
|
|
85
90
|
# the connection is kept alive by the lifespan
|
|
86
|
-
await app.send_message_json(
|
|
87
|
-
channel="my_background_task",
|
|
88
|
-
payload=data
|
|
89
|
-
)
|
|
91
|
+
await app.send_message_json(channel="my_background_task", payload=data)
|
|
90
92
|
return {"status": "ok"}
|
|
91
93
|
```
|
|
@@ -29,7 +29,7 @@ acknowledge it even on failure:
|
|
|
29
29
|
@router.actor(
|
|
30
30
|
channel="tasks",
|
|
31
31
|
confirmation_mode="auto",
|
|
32
|
-
on_error="reject" # Can be "nack", "reject", or "ack"
|
|
32
|
+
on_error="reject", # Can be "nack", "reject", or "ack"
|
|
33
33
|
)
|
|
34
34
|
async def my_actor():
|
|
35
35
|
pass
|
|
@@ -45,6 +45,7 @@ def handle_error(exc: Exception) -> Literal["reject", "nack", "ack"]:
|
|
|
45
45
|
return "reject"
|
|
46
46
|
return "nack"
|
|
47
47
|
|
|
48
|
+
|
|
48
49
|
@router.actor(channel="tasks", on_error=handle_error)
|
|
49
50
|
async def my_smart_actor():
|
|
50
51
|
pass
|
|
@@ -64,6 +65,7 @@ helps to prevent accidentally leaving a message without a confirmation.
|
|
|
64
65
|
```python
|
|
65
66
|
from typing import Literal
|
|
66
67
|
|
|
68
|
+
|
|
67
69
|
@router.actor(channel="tasks", confirmation_mode="manual_explicit")
|
|
68
70
|
async def my_explicit_actor() -> Literal["ack", "nack", "reject", "no_action"]:
|
|
69
71
|
try:
|
|
@@ -98,10 +100,7 @@ By default, in `manual` and `manual_explicit` modes `on_error` is set to
|
|
|
98
100
|
directly:
|
|
99
101
|
|
|
100
102
|
```python
|
|
101
|
-
@router.actor(
|
|
102
|
-
confirmation_mode="manual_explicit",
|
|
103
|
-
on_error="nack"
|
|
104
|
-
)
|
|
103
|
+
@router.actor(confirmation_mode="manual_explicit", on_error="nack")
|
|
105
104
|
async def my_actor(payload: MyPydanticModel) -> Literal["ack", "nack", "reject", "no_action"]:
|
|
106
105
|
# the actor body won't run if MyPydanticModel fails validation
|
|
107
106
|
return "ack"
|