repid 2.2.1__tar.gz → 2.2.2__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.2.1 → repid-2.2.2}/.github/workflows/actions.lock +0 -6
- {repid-2.2.1 → repid-2.2.2}/.github/workflows/tests.yaml +0 -43
- {repid-2.2.1 → repid-2.2.2}/PKG-INFO +2 -2
- {repid-2.2.1 → repid-2.2.2}/README.md +1 -1
- repid-2.2.2/repid/_utils/_typing.py +8 -0
- {repid-2.2.1 → repid-2.2.2}/repid/connections/amqp/protocol/links.py +29 -7
- {repid-2.2.1 → repid-2.2.2}/repid/connections/amqp/protocol/session.py +18 -2
- {repid-2.2.1 → repid-2.2.2}/repid/connections/amqp/protocol/states.py +2 -0
- {repid-2.2.1 → repid-2.2.2}/repid/connections/amqp/protocol/transport.py +4 -3
- {repid-2.2.1 → repid-2.2.2}/repid/connections/pubsub/__init__.py +1 -0
- {repid-2.2.1 → repid-2.2.2}/repid/connections/pubsub/message_broker.py +26 -2
- {repid-2.2.1 → repid-2.2.2}/repid/connections/pubsub/protocol/__init__.py +1 -0
- {repid-2.2.1 → repid-2.2.2}/repid/connections/pubsub/protocol/client.py +6 -1
- {repid-2.2.1 → repid-2.2.2}/repid/connections/pubsub/protocol/control_batcher.py +38 -41
- {repid-2.2.1 → repid-2.2.2}/repid/connections/pubsub/protocol/resilience.py +102 -39
- {repid-2.2.1 → repid-2.2.2}/repid/connections/pubsub/protocol/subscriber.py +3 -1
- {repid-2.2.1 → repid-2.2.2}/repid/converter.py +16 -20
- {repid-2.2.1 → repid-2.2.2}/repid/data/actor.py +10 -8
- {repid-2.2.1 → repid-2.2.2}/repid/dependencies/_utils.py +45 -0
- {repid-2.2.1 → repid-2.2.2}/repid/dependencies/depends.py +2 -13
- {repid-2.2.1 → repid-2.2.2}/repid/middlewares.py +5 -9
- {repid-2.2.1 → repid-2.2.2}/repid/router.py +5 -7
- {repid-2.2.1 → repid-2.2.2}/tests/integration/brokers.py +73 -2
- {repid-2.2.1 → repid-2.2.2}/tests/integration/conftest.py +14 -5
- {repid-2.2.1 → repid-2.2.2}/tests/integration/test_asyncapi_compatibility.py +0 -4
- {repid-2.2.1 → repid-2.2.2}/tests/unit/amqp/test_amqp_transport.py +109 -104
- {repid-2.2.1 → repid-2.2.2}/tests/unit/amqp/test_connection.py +2 -60
- {repid-2.2.1 → repid-2.2.2}/tests/unit/amqp/test_encoding_decoding.py +12 -20
- {repid-2.2.1 → repid-2.2.2}/tests/unit/amqp/test_event_emitter.py +1 -8
- {repid-2.2.1 → repid-2.2.2}/tests/unit/amqp/test_frame_buffer.py +3 -11
- {repid-2.2.1 → repid-2.2.2}/tests/unit/amqp/test_links.py +32 -47
- {repid-2.2.1 → repid-2.2.2}/tests/unit/amqp/test_managed.py +0 -11
- {repid-2.2.1 → repid-2.2.2}/tests/unit/amqp/test_managed_pools.py +0 -23
- {repid-2.2.1 → repid-2.2.2}/tests/unit/amqp/test_message.py +0 -6
- {repid-2.2.1 → repid-2.2.2}/tests/unit/amqp/test_message_broker.py +0 -12
- {repid-2.2.1 → repid-2.2.2}/tests/unit/amqp/test_metrics.py +0 -2
- {repid-2.2.1 → repid-2.2.2}/tests/unit/amqp/test_reconnect.py +0 -2
- {repid-2.2.1 → repid-2.2.2}/tests/unit/amqp/test_session.py +87 -42
- {repid-2.2.1 → repid-2.2.2}/tests/unit/amqp/test_state_machine.py +7 -24
- {repid-2.2.1 → repid-2.2.2}/tests/unit/amqp/test_uamqp_types.py +0 -24
- {repid-2.2.1 → repid-2.2.2}/tests/unit/conftest.py +2 -2
- {repid-2.2.1 → repid-2.2.2}/tests/unit/in_memory/test_message_broker.py +0 -19
- {repid-2.2.1 → repid-2.2.2}/tests/unit/pubsub/protocol/test_channel.py +0 -2
- {repid-2.2.1 → repid-2.2.2}/tests/unit/pubsub/protocol/test_client.py +54 -5
- {repid-2.2.1 → repid-2.2.2}/tests/unit/pubsub/protocol/test_control_batcher.py +58 -10
- repid-2.2.2/tests/unit/pubsub/protocol/test_resilience.py +464 -0
- {repid-2.2.1 → repid-2.2.2}/tests/unit/pubsub/protocol/test_subscriber.py +0 -25
- {repid-2.2.1 → repid-2.2.2}/tests/unit/pubsub/test_helpers.py +0 -18
- {repid-2.2.1 → repid-2.2.2}/tests/unit/pubsub/test_message_broker.py +37 -0
- {repid-2.2.1 → repid-2.2.2}/tests/unit/test_asyncapi_generator.py +113 -12
- {repid-2.2.1 → repid-2.2.2}/tests/unit/test_converter.py +22 -2
- {repid-2.2.1 → repid-2.2.2}/tests/unit/test_dependencies.py +173 -23
- {repid-2.2.1 → repid-2.2.2}/tests/unit/test_router.py +0 -12
- {repid-2.2.1 → repid-2.2.2}/tests/unit/test_runner.py +0 -1
- {repid-2.2.1 → repid-2.2.2}/tests/unit/test_runner_manual_explicit.py +0 -5
- {repid-2.2.1 → repid-2.2.2}/tests/unit/test_worker.py +2 -3
- repid-2.2.1/repid/_utils/_typing.py +0 -8
- repid-2.2.1/tests/unit/pubsub/protocol/test_helpers_internal.py +0 -31
- repid-2.2.1/tests/unit/pubsub/protocol/test_resilience.py +0 -325
- {repid-2.2.1 → repid-2.2.2}/.devcontainer/devcontainer.json +0 -0
- {repid-2.2.1 → repid-2.2.2}/.github/CODE_OF_CONDUCT.md +0 -0
- {repid-2.2.1 → repid-2.2.2}/.github/FUNDING.yml +0 -0
- {repid-2.2.1 → repid-2.2.2}/.github/ISSUE_TEMPLATE/bug_report.md +0 -0
- {repid-2.2.1 → repid-2.2.2}/.github/ISSUE_TEMPLATE/feature_request.md +0 -0
- {repid-2.2.1 → repid-2.2.2}/.github/ISSUE_TEMPLATE/other.md +0 -0
- {repid-2.2.1 → repid-2.2.2}/.github/PULL_REQUEST_TEMPLATE.md +0 -0
- {repid-2.2.1 → repid-2.2.2}/.github/dependabot.yml +0 -0
- {repid-2.2.1 → repid-2.2.2}/.github/workflows/codeql.yml +0 -0
- {repid-2.2.1 → repid-2.2.2}/.github/workflows/dependency-review.yml +0 -0
- {repid-2.2.1 → repid-2.2.2}/.github/workflows/docs.yml +0 -0
- {repid-2.2.1 → repid-2.2.2}/.github/workflows/prek.yml +0 -0
- {repid-2.2.1 → repid-2.2.2}/.github/workflows/release.yaml +0 -0
- {repid-2.2.1 → repid-2.2.2}/.github/workflows/typecheck.yml +0 -0
- {repid-2.2.1 → repid-2.2.2}/.github/workflows/workflow-lint.yml +0 -0
- {repid-2.2.1 → repid-2.2.2}/.gitignore +0 -0
- {repid-2.2.1 → repid-2.2.2}/.pre-commit-config.yaml +0 -0
- {repid-2.2.1 → repid-2.2.2}/LICENSE +0 -0
- {repid-2.2.1 → repid-2.2.2}/Makefile +0 -0
- {repid-2.2.1 → repid-2.2.2}/SECURITY.md +0 -0
- {repid-2.2.1 → repid-2.2.2}/docs/advanced_user_guide/your_own_brokers.md +0 -0
- {repid-2.2.1 → repid-2.2.2}/docs/advanced_user_guide/your_own_converter.md +0 -0
- {repid-2.2.1 → repid-2.2.2}/docs/advanced_user_guide/your_own_serializer.md +0 -0
- {repid-2.2.1 → repid-2.2.2}/docs/benchmarks.md +0 -0
- {repid-2.2.1 → repid-2.2.2}/docs/benchmarks_img/.gitignore +0 -0
- {repid-2.2.1 → repid-2.2.2}/docs/benchmarks_img/chart.svg +0 -0
- {repid-2.2.1 → repid-2.2.2}/docs/contributing.md +0 -0
- {repid-2.2.1 → repid-2.2.2}/docs/cookbook/chaining_jobs.md +0 -0
- {repid-2.2.1 → repid-2.2.2}/docs/cookbook/large_payloads.md +0 -0
- {repid-2.2.1 → repid-2.2.2}/docs/cookbook/middlewares.md +0 -0
- {repid-2.2.1 → repid-2.2.2}/docs/cookbook/opentelemetry_middleware.md +0 -0
- {repid-2.2.1 → repid-2.2.2}/docs/cookbook/rabbitmq_retries.md +0 -0
- {repid-2.2.1 → repid-2.2.2}/docs/cookbook/sentry_middleware.md +0 -0
- {repid-2.2.1 → repid-2.2.2}/docs/cookbook/testing.md +0 -0
- {repid-2.2.1 → repid-2.2.2}/docs/features.md +0 -0
- {repid-2.2.1 → repid-2.2.2}/docs/getting_started/glossary.md +0 -0
- {repid-2.2.1 → repid-2.2.2}/docs/getting_started/quickstart.md +0 -0
- {repid-2.2.1 → repid-2.2.2}/docs/getting_started/supported_brokers.md +0 -0
- {repid-2.2.1 → repid-2.2.2}/docs/index.md +0 -0
- {repid-2.2.1 → repid-2.2.2}/docs/integrations/asyncapi.md +0 -0
- {repid-2.2.1 → repid-2.2.2}/docs/integrations/fastapi_and_pydantic.md +0 -0
- {repid-2.2.1 → repid-2.2.2}/docs/overrides/partials/integrations/analytics/custom.html +0 -0
- {repid-2.2.1 → repid-2.2.2}/docs/playground.md +0 -0
- {repid-2.2.1 → repid-2.2.2}/docs/user_guide/actors/confirmation_and_errors.md +0 -0
- {repid-2.2.1 → repid-2.2.2}/docs/user_guide/actors/execution.md +0 -0
- {repid-2.2.1 → repid-2.2.2}/docs/user_guide/actors/index.md +0 -0
- {repid-2.2.1 → repid-2.2.2}/docs/user_guide/actors/parsing.md +0 -0
- {repid-2.2.1 → repid-2.2.2}/docs/user_guide/actors/routers.md +0 -0
- {repid-2.2.1 → repid-2.2.2}/docs/user_guide/actors/routing.md +0 -0
- {repid-2.2.1 → repid-2.2.2}/docs/user_guide/dependency_injection.md +0 -0
- {repid-2.2.1 → repid-2.2.2}/docs/user_guide/message_registry.md +0 -0
- {repid-2.2.1 → repid-2.2.2}/docs/user_guide/messages.md +0 -0
- {repid-2.2.1 → repid-2.2.2}/docs/user_guide/raw_message_and_eager_response.md +0 -0
- {repid-2.2.1 → repid-2.2.2}/docs/user_guide/server_registry.md +0 -0
- {repid-2.2.1 → repid-2.2.2}/docs/user_guide/server_specific_parameters.md +0 -0
- {repid-2.2.1 → repid-2.2.2}/docs/user_guide/workers/built_in_servers.md +0 -0
- {repid-2.2.1 → repid-2.2.2}/docs/user_guide/workers/concurrency.md +0 -0
- {repid-2.2.1 → repid-2.2.2}/docs/user_guide/workers/index.md +0 -0
- {repid-2.2.1 → repid-2.2.2}/docs/user_guide/workers/lifecycle.md +0 -0
- {repid-2.2.1 → repid-2.2.2}/pyproject.toml +0 -0
- {repid-2.2.1 → repid-2.2.2}/repid/__init__.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/repid/_runner.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/repid/_utils/__init__.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/repid/_utils/asyncify_.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/repid/_utils/is_installed.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/repid/_utils/json_encoder.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/repid/_utils/not_set.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/repid/_worker.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/repid/asyncapi/__init__.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/repid/asyncapi/generator.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/repid/asyncapi/models/__init__.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/repid/asyncapi/models/asyncapi.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/repid/asyncapi/models/channels.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/repid/asyncapi/models/common/__init__.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/repid/asyncapi/models/common/bindings.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/repid/asyncapi/models/common/correlation_id.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/repid/asyncapi/models/common/external_docs.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/repid/asyncapi/models/common/message.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/repid/asyncapi/models/common/reference.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/repid/asyncapi/models/common/tag.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/repid/asyncapi/models/components.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/repid/asyncapi/models/info.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/repid/asyncapi/models/operations.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/repid/asyncapi/models/servers.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/repid/asyncapi_server.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/repid/connections/__init__.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/repid/connections/abc.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/repid/connections/amqp/__init__.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/repid/connections/amqp/_uamqp/LICENSE.txt +0 -0
- {repid-2.2.1 → repid-2.2.2}/repid/connections/amqp/_uamqp/_decode.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/repid/connections/amqp/_uamqp/_encode.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/repid/connections/amqp/_uamqp/amqptypes.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/repid/connections/amqp/_uamqp/constants.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/repid/connections/amqp/_uamqp/endpoints.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/repid/connections/amqp/_uamqp/message.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/repid/connections/amqp/_uamqp/outcomes.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/repid/connections/amqp/_uamqp/performatives.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/repid/connections/amqp/helpers.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/repid/connections/amqp/message_broker.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/repid/connections/amqp/protocol/__init__.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/repid/connections/amqp/protocol/connection.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/repid/connections/amqp/protocol/events.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/repid/connections/amqp/protocol/managed.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/repid/connections/amqp/protocol/reconnect.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/repid/connections/amqp/subscriber.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/repid/connections/in_memory/__init__.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/repid/connections/in_memory/message_broker.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/repid/connections/in_memory/utils.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/repid/connections/kafka/__init__.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/repid/connections/kafka/message.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/repid/connections/kafka/message_broker.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/repid/connections/kafka/protocols.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/repid/connections/kafka/subscriber.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/repid/connections/nats/__init__.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/repid/connections/nats/message_broker.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/repid/connections/pubsub/helpers.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/repid/connections/pubsub/protocol/_helpers.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/repid/connections/pubsub/protocol/channel.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/repid/connections/pubsub/protocol/credentials.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/repid/connections/pubsub/protocol/proto.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/repid/connections/pubsub/protocol/received_message.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/repid/connections/redis/__init__.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/repid/connections/redis/message_broker.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/repid/connections/sqs/__init__.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/repid/connections/sqs/constants.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/repid/connections/sqs/message.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/repid/connections/sqs/message_broker.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/repid/connections/sqs/subscriber.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/repid/data/__init__.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/repid/data/channel.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/repid/data/contact.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/repid/data/converter_input_schema.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/repid/data/external_docs.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/repid/data/license.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/repid/data/message.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/repid/data/message_schema.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/repid/data/operation.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/repid/data/runner_info.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/repid/data/tag.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/repid/dependencies/__init__.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/repid/dependencies/full_payload.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/repid/dependencies/header_dependency.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/repid/dependencies/message_dependency.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/repid/health_check_server.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/repid/logger.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/repid/main.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/repid/message_registry.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/repid/py.typed +0 -0
- {repid-2.2.1 → repid-2.2.2}/repid/serializer.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/repid/server_registry.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/repid/test_client.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/tests/__init__.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/tests/integration/__init__.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/tests/integration/asyncapi/package-lock.json +0 -0
- {repid-2.2.1 → repid-2.2.2}/tests/integration/asyncapi/package.json +0 -0
- {repid-2.2.1 → repid-2.2.2}/tests/integration/pubsub_proto_helpers.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/tests/integration/rabbitmq_definitions.json +0 -0
- {repid-2.2.1 → repid-2.2.2}/tests/integration/test_default_flow.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/tests/integration/test_kafka_specific.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/tests/integration/test_nats_specific.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/tests/integration/test_rabbitmq_specific.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/tests/integration/test_redis_specific.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/tests/integration/test_sqs_specific.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/tests/integration/test_worker.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/tests/unit/__init__.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/tests/unit/amqp/__init__.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/tests/unit/amqp/conftest.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/tests/unit/amqp/test_logging.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/tests/unit/amqp/utils.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/tests/unit/in_memory/__init__.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/tests/unit/in_memory/test_utils.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/tests/unit/pubsub/__init__.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/tests/unit/pubsub/protocol/test_credentials.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/tests/unit/pubsub/protocol/test_proto.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/tests/unit/pubsub/protocol/test_received_message.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/tests/unit/pubsub/protocol/test_subscriber_execution.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/tests/unit/redis/__init__.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/tests/unit/redis/test_connection.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/tests/unit/redis/test_message_broker.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/tests/unit/redis/test_redis_keep_alive.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/tests/unit/sqs/test_message.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/tests/unit/test_channel.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/tests/unit/test_health_check_server.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/tests/unit/test_kafka_connection.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/tests/unit/test_main.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/tests/unit/test_middleware.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/tests/unit/test_nats_connection.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/tests/unit/test_serializer.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/tests/unit/test_server_registry.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/tests/unit/test_test_client.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/tests/unit/test_utils.py +0 -0
- {repid-2.2.1 → repid-2.2.2}/uv.lock +0 -0
- {repid-2.2.1 → repid-2.2.2}/zensical.toml +0 -0
|
@@ -28,7 +28,6 @@ workflows:
|
|
|
28
28
|
- 'actions/setup-node@v7.1.0'
|
|
29
29
|
- 'actions/upload-artifact@v7.0.2'
|
|
30
30
|
- 'astral-sh/setup-uv@v10.3.3'
|
|
31
|
-
- 'peaceiris/actions-gh-pages@v4.1.0'
|
|
32
31
|
'.github/workflows/typecheck.yml':
|
|
33
32
|
- 'actions/checkout@v7.0.1'
|
|
34
33
|
- 'astral-sh/setup-uv@v10.3.3'
|
|
@@ -81,11 +80,6 @@ dependencies:
|
|
|
81
80
|
commit: 'sha1-33d7b85da1a04171e211befe2c739303b9a4c066'
|
|
82
81
|
owner_id: 9919
|
|
83
82
|
repo_id: 259445878
|
|
84
|
-
'peaceiris/actions-gh-pages@v4.1.0':
|
|
85
|
-
ref: 'v4.1.0'
|
|
86
|
-
commit: 'sha1-84c30a85c19949d7eee79c4ff27748b70285e453'
|
|
87
|
-
owner_id: 30958501
|
|
88
|
-
repo_id: 187915200
|
|
89
83
|
'pypa/gh-action-pypi-publish@v1.14.3':
|
|
90
84
|
ref: 'v1.14.3'
|
|
91
85
|
commit: 'sha1-7245906fb61fa33a13554f9d5fb856fe61758086'
|
|
@@ -157,8 +157,6 @@ jobs:
|
|
|
157
157
|
needs: [unit-tests, integration-tests]
|
|
158
158
|
runs-on: ubuntu-latest
|
|
159
159
|
timeout-minutes: 10
|
|
160
|
-
outputs:
|
|
161
|
-
percentage: ${{ steps.coverage.outputs.percentage }}
|
|
162
160
|
|
|
163
161
|
steps:
|
|
164
162
|
- uses: actions/checkout@v7.0.1
|
|
@@ -183,44 +181,3 @@ jobs:
|
|
|
183
181
|
uv run --no-sync coverage combine coverage
|
|
184
182
|
uv run --no-sync coverage report --format=markdown --skip-covered --show-missing \
|
|
185
183
|
>> "$GITHUB_STEP_SUMMARY"
|
|
186
|
-
|
|
187
|
-
- name: Get coverage percentage for badge
|
|
188
|
-
id: coverage
|
|
189
|
-
if: github.ref == format('refs/heads/{0}', github.event.repository.default_branch)
|
|
190
|
-
run: |
|
|
191
|
-
uv run --no-sync coverage json
|
|
192
|
-
percentage=$(uv run --no-sync python -c \
|
|
193
|
-
'import json; print(json.load(open("coverage.json"))["totals"]["percent_covered_display"])')
|
|
194
|
-
echo "percentage=$percentage" >> "$GITHUB_OUTPUT"
|
|
195
|
-
|
|
196
|
-
coverage-badge:
|
|
197
|
-
needs: coverage-combine
|
|
198
|
-
if: github.ref == format('refs/heads/{0}', github.event.repository.default_branch)
|
|
199
|
-
runs-on: ubuntu-latest
|
|
200
|
-
timeout-minutes: 5
|
|
201
|
-
permissions:
|
|
202
|
-
contents: write
|
|
203
|
-
steps:
|
|
204
|
-
- name: Generate Coverage Badge
|
|
205
|
-
env:
|
|
206
|
-
COVERAGE: ${{ needs.coverage-combine.outputs.percentage }}
|
|
207
|
-
run: |
|
|
208
|
-
if [ "$COVERAGE" -ge 95 ]; then
|
|
209
|
-
color=brightgreen
|
|
210
|
-
elif [ "$COVERAGE" -ge 80 ]; then
|
|
211
|
-
color=yellowgreen
|
|
212
|
-
else
|
|
213
|
-
color=red
|
|
214
|
-
fi
|
|
215
|
-
mkdir -p badges
|
|
216
|
-
curl --fail --silent --show-error --retry 3 \
|
|
217
|
-
"https://img.shields.io/badge/coverage-${COVERAGE}%25-${color}" -o badges/coverage.svg
|
|
218
|
-
|
|
219
|
-
- name: Publish Coverage Badge
|
|
220
|
-
uses: peaceiris/actions-gh-pages@v4.1.0
|
|
221
|
-
with:
|
|
222
|
-
github_token: ${{ secrets.GITHUB_TOKEN }}
|
|
223
|
-
publish_dir: ./badges
|
|
224
|
-
publish_branch: gh-pages
|
|
225
|
-
destination_dir: badges
|
|
226
|
-
keep_files: true
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: repid
|
|
3
|
-
Version: 2.2.
|
|
3
|
+
Version: 2.2.2
|
|
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
|
|
@@ -47,7 +47,7 @@ Description-Content-Type: text/markdown
|
|
|
47
47
|
</a>
|
|
48
48
|
|
|
49
49
|
[](https://pypi.org/project/repid/)
|
|
50
|
-
[](https://github.com/aleksul/repid/actions/workflows/tests.yaml)
|
|
51
51
|
[](https://github.com/aleksul/repid/actions/workflows/tests.yaml)
|
|
52
52
|
[](https://pypi.python.org/pypi/repid/)
|
|
53
53
|
[](https://repid.aleksul.space)
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
</a>
|
|
8
8
|
|
|
9
9
|
[](https://pypi.org/project/repid/)
|
|
10
|
-
[](https://github.com/aleksul/repid/actions/workflows/tests.yaml)
|
|
11
11
|
[](https://github.com/aleksul/repid/actions/workflows/tests.yaml)
|
|
12
12
|
[](https://pypi.python.org/pypi/repid/)
|
|
13
13
|
[](https://repid.aleksul.space)
|
|
@@ -174,14 +174,14 @@ class Link(ABC):
|
|
|
174
174
|
return
|
|
175
175
|
|
|
176
176
|
# Send DETACH if possible
|
|
177
|
-
if self._state_machine.is_usable():
|
|
177
|
+
if self._state_machine.is_usable() or self.state is LinkState.ATTACH_SENT:
|
|
178
178
|
try:
|
|
179
179
|
detach_frame = DetachFrame(handle=self._handle, closed=True)
|
|
180
|
+
await self._state_machine.transition("send_detach")
|
|
180
181
|
await self._session.connection.send_performative(
|
|
181
182
|
self._session.channel,
|
|
182
183
|
detach_frame,
|
|
183
184
|
)
|
|
184
|
-
await self._state_machine.transition("send_detach")
|
|
185
185
|
except (TimeoutError, OSError):
|
|
186
186
|
logger.warning("link.detach_frame.error", exc_info=True)
|
|
187
187
|
|
|
@@ -237,11 +237,11 @@ class Link(ABC):
|
|
|
237
237
|
# Send DETACH response if we haven't already
|
|
238
238
|
if self._state_machine.state == LinkState.DETACH_RCVD:
|
|
239
239
|
with contextlib.suppress(OSError, asyncio.TimeoutError, ValueError):
|
|
240
|
+
await self._state_machine.transition("send_detach")
|
|
240
241
|
await self._session.connection.send_performative(
|
|
241
242
|
self._session.channel,
|
|
242
243
|
DetachFrame(handle=self._handle, closed=True),
|
|
243
244
|
)
|
|
244
|
-
await self._state_machine.transition("send_detach")
|
|
245
245
|
|
|
246
246
|
self._session._remove_link(self) # pyrefly: ignore[bad-argument-type]
|
|
247
247
|
|
|
@@ -535,6 +535,7 @@ class ReceiverLink(Link):
|
|
|
535
535
|
self._delivery_count = 0
|
|
536
536
|
self._link_credit = prefetch
|
|
537
537
|
self._prefetch = prefetch
|
|
538
|
+
self._closing = False
|
|
538
539
|
|
|
539
540
|
# Multi-frame transfer handling
|
|
540
541
|
self._incoming_transfers: list[TransferFrame] = []
|
|
@@ -582,14 +583,30 @@ class ReceiverLink(Link):
|
|
|
582
583
|
self._delivery_count = _attach.initial_delivery_count
|
|
583
584
|
|
|
584
585
|
# Send initial FLOW to grant credit
|
|
585
|
-
|
|
586
|
+
if not self._closing:
|
|
587
|
+
await self._send_flow()
|
|
586
588
|
|
|
587
589
|
async def _handle_flow(self, flow: FlowFrame) -> None:
|
|
588
590
|
"""Handle FLOW frame (echo request)."""
|
|
589
591
|
# Receivers typically only respond to drain/echo requests
|
|
590
|
-
if flow.echo:
|
|
592
|
+
if flow.echo and not self._closing:
|
|
591
593
|
await self._send_flow()
|
|
592
594
|
|
|
595
|
+
@override
|
|
596
|
+
async def detach(self, _error: Exception | None = None) -> None:
|
|
597
|
+
self._closing = True
|
|
598
|
+
await super().detach(_error)
|
|
599
|
+
|
|
600
|
+
@override
|
|
601
|
+
async def _handle_detach(self, _detach: DetachFrame) -> None:
|
|
602
|
+
self._closing = True
|
|
603
|
+
await super()._handle_detach(_detach)
|
|
604
|
+
|
|
605
|
+
@override
|
|
606
|
+
def invalidate(self) -> None:
|
|
607
|
+
self._closing = True
|
|
608
|
+
super().invalidate()
|
|
609
|
+
|
|
593
610
|
async def _send_flow(self) -> None:
|
|
594
611
|
"""Send FLOW frame to grant credit."""
|
|
595
612
|
flow_frame = FlowFrame(
|
|
@@ -684,8 +701,13 @@ class ReceiverLink(Link):
|
|
|
684
701
|
await self._session.connection.send_performative(self._session.channel, disp)
|
|
685
702
|
self._delivery_settled_by_callback = True
|
|
686
703
|
|
|
704
|
+
@property
|
|
705
|
+
def can_settle(self) -> bool:
|
|
706
|
+
"""Whether deliveries received on this link can still be settled."""
|
|
707
|
+
return not self._closing and self.is_attached
|
|
708
|
+
|
|
687
709
|
async def settle_delivery(self, delivery_id: int, state: ReceiverSettlementState) -> None:
|
|
688
|
-
if not self.is_delivery_settled(delivery_id):
|
|
710
|
+
if self.can_settle and not self.is_delivery_settled(delivery_id):
|
|
689
711
|
await self._send_disposition(delivery_id, state)
|
|
690
712
|
await self.release_delivery_credit(delivery_id)
|
|
691
713
|
|
|
@@ -740,7 +762,7 @@ class ReceiverLink(Link):
|
|
|
740
762
|
|
|
741
763
|
if self._link_credit < self._prefetch:
|
|
742
764
|
self._link_credit += 1
|
|
743
|
-
if self.
|
|
765
|
+
if self.is_attached and not self._closing:
|
|
744
766
|
await self._send_flow()
|
|
745
767
|
|
|
746
768
|
async def set_credit(self, credit: int) -> None:
|
|
@@ -213,6 +213,8 @@ class Session:
|
|
|
213
213
|
return delivery_id
|
|
214
214
|
|
|
215
215
|
async def _ensure_incoming_window(self, minimum: int) -> None:
|
|
216
|
+
# A session may combine credits from many links. FLOW encodes this as uint.
|
|
217
|
+
minimum = min(minimum, 0xFFFFFFFF)
|
|
216
218
|
if minimum <= self._incoming_window:
|
|
217
219
|
return
|
|
218
220
|
|
|
@@ -555,8 +557,22 @@ class Session:
|
|
|
555
557
|
self._links[name] = link
|
|
556
558
|
self._links_by_handle[handle] = link
|
|
557
559
|
|
|
558
|
-
|
|
559
|
-
|
|
560
|
+
attachment = asyncio.create_task(link.attach())
|
|
561
|
+
try:
|
|
562
|
+
# Cancellation during write can arrive after ATTACH was sent.
|
|
563
|
+
# Let attach record its state before deciding whether to detach.
|
|
564
|
+
await asyncio.wait({attachment})
|
|
565
|
+
attachment.result()
|
|
566
|
+
await link.wait_ready() # Wait for ATTACH response
|
|
567
|
+
except BaseException:
|
|
568
|
+
await asyncio.gather(attachment, return_exceptions=True)
|
|
569
|
+
try:
|
|
570
|
+
await link.detach()
|
|
571
|
+
except Exception:
|
|
572
|
+
logger.exception("session.receiver.detach_error", extra={"link": name})
|
|
573
|
+
finally:
|
|
574
|
+
self._remove_link(link)
|
|
575
|
+
raise
|
|
560
576
|
return link
|
|
561
577
|
|
|
562
578
|
# Backward-compatible aliases
|
|
@@ -437,12 +437,14 @@ class LinkStateMachine(StateMachine[LinkState]):
|
|
|
437
437
|
(LinkState.DETACHED, "recv_attach"): LinkState.ATTACH_RCVD,
|
|
438
438
|
# From ATTACH_SENT
|
|
439
439
|
(LinkState.ATTACH_SENT, "recv_attach"): LinkState.ATTACHED,
|
|
440
|
+
(LinkState.ATTACH_SENT, "send_detach"): LinkState.DETACH_SENT,
|
|
440
441
|
# From ATTACH_RCVD
|
|
441
442
|
(LinkState.ATTACH_RCVD, "send_attach"): LinkState.ATTACHED,
|
|
442
443
|
# From ATTACHED
|
|
443
444
|
(LinkState.ATTACHED, "send_detach"): LinkState.DETACH_SENT,
|
|
444
445
|
(LinkState.ATTACHED, "recv_detach"): LinkState.DETACH_RCVD,
|
|
445
446
|
# From DETACH_SENT
|
|
447
|
+
(LinkState.DETACH_SENT, "recv_attach"): LinkState.DETACH_SENT,
|
|
446
448
|
(LinkState.DETACH_SENT, "recv_detach"): LinkState.DETACHED,
|
|
447
449
|
# From DETACH_RCVD
|
|
448
450
|
(LinkState.DETACH_RCVD, "send_detach"): LinkState.DETACHED,
|
|
@@ -506,12 +506,13 @@ class AmqpTransport:
|
|
|
506
506
|
f"Frame too large: {len(frame_bytes)} > {self._outbound_max_frame_size}",
|
|
507
507
|
)
|
|
508
508
|
|
|
509
|
+
writer = self._writer
|
|
509
510
|
async with self._write_lock:
|
|
510
|
-
if
|
|
511
|
+
if writer is None or writer is not self._writer:
|
|
511
512
|
raise ConnectionClosedError("Not connected")
|
|
512
513
|
|
|
513
|
-
|
|
514
|
-
await
|
|
514
|
+
writer.write(frame_bytes)
|
|
515
|
+
await writer.drain()
|
|
515
516
|
|
|
516
517
|
self._metrics.bytes_sent += len(frame_bytes)
|
|
517
518
|
self._metrics.frames_sent += 1
|
|
@@ -10,6 +10,7 @@ This module provides a Pub/Sub server implementation with:
|
|
|
10
10
|
|
|
11
11
|
from .helpers import ChannelOverride as ChannelOverride
|
|
12
12
|
from .message_broker import PubsubServer as PubsubServer
|
|
13
|
+
from .protocol import CircuitOpenError as CircuitOpenError
|
|
13
14
|
from .protocol import CredentialsProvider as CredentialsProvider
|
|
14
15
|
from .protocol import GoogleDefaultCredentials as GoogleDefaultCredentials
|
|
15
16
|
from .protocol import InsecureCredentials as InsecureCredentials
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
3
|
import logging
|
|
4
|
+
import math
|
|
4
5
|
import uuid
|
|
5
6
|
from collections.abc import AsyncGenerator, Callable, Coroutine, Mapping, Sequence
|
|
6
7
|
from contextlib import asynccontextmanager, suppress
|
|
@@ -71,6 +72,9 @@ class PubsubServer:
|
|
|
71
72
|
reconnect_max_delay: float = 32.0,
|
|
72
73
|
reconnect_jitter_factor: float = 0.25,
|
|
73
74
|
stability_threshold: float = 60.0,
|
|
75
|
+
circuit_breaker_threshold: int = 10,
|
|
76
|
+
circuit_breaker_cooldown: float = 30.0,
|
|
77
|
+
control_rpc_timeout: float = 10.0,
|
|
74
78
|
# Subscriber configuration
|
|
75
79
|
stream_ack_deadline_seconds: int = 300,
|
|
76
80
|
# Dependency injection for testability
|
|
@@ -97,11 +101,20 @@ class PubsubServer:
|
|
|
97
101
|
external_docs: AsyncAPI external documentation link.
|
|
98
102
|
bindings: AsyncAPI server bindings.
|
|
99
103
|
channel_overrides: Per-channel configuration overrides.
|
|
100
|
-
max_reconnect_attempts: Maximum
|
|
104
|
+
max_reconnect_attempts: Maximum attempts per publish, acknowledge or
|
|
105
|
+
deadline call.
|
|
101
106
|
reconnect_base_delay: Initial retry delay in seconds.
|
|
102
107
|
reconnect_max_delay: Maximum retry delay in seconds.
|
|
103
108
|
reconnect_jitter_factor: Jitter factor (0.0-1.0) for retry delays.
|
|
104
|
-
stability_threshold: Seconds
|
|
109
|
+
stability_threshold: Seconds a streaming pull must stay connected before
|
|
110
|
+
its responses reset the failure count.
|
|
111
|
+
circuit_breaker_threshold: Consecutive failed attempts, across all calls
|
|
112
|
+
and streams, after which calls fail without contacting Pub/Sub and
|
|
113
|
+
streams stop reconnecting.
|
|
114
|
+
circuit_breaker_cooldown: Seconds the circuit breaker stays open before
|
|
115
|
+
one call may probe Pub/Sub again.
|
|
116
|
+
control_rpc_timeout: Timeout in seconds for each acknowledge and deadline
|
|
117
|
+
extension attempt. Keep it well below the acknowledgment deadline.
|
|
105
118
|
stream_ack_deadline_seconds: Ack deadline for StreamingPull.
|
|
106
119
|
max_outstanding_messages: Flow control for outstanding messages.
|
|
107
120
|
max_outstanding_bytes: Flow control for outstanding bytes (0=unlimited).
|
|
@@ -124,6 +137,13 @@ class PubsubServer:
|
|
|
124
137
|
self._external_docs = external_docs
|
|
125
138
|
self._bindings = bindings
|
|
126
139
|
|
|
140
|
+
if circuit_breaker_threshold < 1:
|
|
141
|
+
raise ValueError("circuit_breaker_threshold must be at least 1")
|
|
142
|
+
if not 0 <= circuit_breaker_cooldown < math.inf:
|
|
143
|
+
raise ValueError("circuit_breaker_cooldown must be non-negative and finite")
|
|
144
|
+
if not 0 < control_rpc_timeout < math.inf:
|
|
145
|
+
raise ValueError("control_rpc_timeout must be positive and finite")
|
|
146
|
+
|
|
127
147
|
# Resilience configuration
|
|
128
148
|
self._resilience_config = ResilienceConfig(
|
|
129
149
|
max_attempts=max_reconnect_attempts,
|
|
@@ -131,8 +151,11 @@ class PubsubServer:
|
|
|
131
151
|
max_delay=reconnect_max_delay,
|
|
132
152
|
jitter_factor=reconnect_jitter_factor,
|
|
133
153
|
stability_threshold=stability_threshold,
|
|
154
|
+
failure_threshold=circuit_breaker_threshold,
|
|
155
|
+
open_duration=circuit_breaker_cooldown,
|
|
134
156
|
)
|
|
135
157
|
self._resilience_state = ResilienceState(self._resilience_config)
|
|
158
|
+
self._control_rpc_timeout = control_rpc_timeout
|
|
136
159
|
|
|
137
160
|
# Subscriber configuration
|
|
138
161
|
self._stream_ack_deadline_seconds = stream_ack_deadline_seconds
|
|
@@ -267,6 +290,7 @@ class PubsubServer:
|
|
|
267
290
|
channel=channel,
|
|
268
291
|
credentials_provider=self._credentials_provider,
|
|
269
292
|
resilience_state=self._resilience_state,
|
|
293
|
+
control_rpc_timeout=self._control_rpc_timeout,
|
|
270
294
|
)
|
|
271
295
|
control_batcher = PubsubControlBatcher(protocol_client)
|
|
272
296
|
try:
|
|
@@ -27,6 +27,7 @@ from .proto import ReceivedMessage as ReceivedMessage
|
|
|
27
27
|
from .proto import StreamingPullRequest as StreamingPullRequest
|
|
28
28
|
from .proto import StreamingPullResponse as StreamingPullResponse
|
|
29
29
|
from .received_message import PubsubReceivedMessage as PubsubReceivedMessage
|
|
30
|
+
from .resilience import CircuitOpenError as CircuitOpenError
|
|
30
31
|
from .resilience import ReconnectionExhaustedError as ReconnectionExhaustedError
|
|
31
32
|
from .resilience import ResilienceConfig as ResilienceConfig
|
|
32
33
|
from .resilience import ResilienceState as ResilienceState
|
|
@@ -31,10 +31,13 @@ class PubsubProtocolClient:
|
|
|
31
31
|
channel: grpc.aio.Channel,
|
|
32
32
|
credentials_provider: CredentialsProvider,
|
|
33
33
|
resilience_state: ResilienceState,
|
|
34
|
+
control_rpc_timeout: float = 10.0,
|
|
34
35
|
) -> None:
|
|
35
36
|
self._channel = channel
|
|
36
37
|
self._credentials_provider = credentials_provider
|
|
37
38
|
self._resilience_state = resilience_state
|
|
39
|
+
# Acknowledge and deadline calls must give up before a lease lapses.
|
|
40
|
+
self._control_rpc_timeout = control_rpc_timeout
|
|
38
41
|
|
|
39
42
|
@staticmethod
|
|
40
43
|
def _serialize_request(request: SerializableRequest) -> bytes:
|
|
@@ -50,7 +53,7 @@ class PubsubProtocolClient:
|
|
|
50
53
|
method: str,
|
|
51
54
|
request: SerializableRequest,
|
|
52
55
|
response_deserializer: Callable[[bytes], ResponseT],
|
|
53
|
-
timeout:
|
|
56
|
+
timeout: float | None = None,
|
|
54
57
|
) -> ResponseT:
|
|
55
58
|
await self._credentials_provider.ensure_valid()
|
|
56
59
|
unary_call = self._channel.unary_unary(
|
|
@@ -91,6 +94,7 @@ class PubsubProtocolClient:
|
|
|
91
94
|
method=ACKNOWLEDGE_METHOD,
|
|
92
95
|
request=request,
|
|
93
96
|
response_deserializer=self._deserialize_empty_response,
|
|
97
|
+
timeout=self._control_rpc_timeout,
|
|
94
98
|
),
|
|
95
99
|
operation_name="acknowledge",
|
|
96
100
|
)
|
|
@@ -118,6 +122,7 @@ class PubsubProtocolClient:
|
|
|
118
122
|
method=MODIFY_ACK_DEADLINE_METHOD,
|
|
119
123
|
request=request,
|
|
120
124
|
response_deserializer=self._deserialize_empty_response,
|
|
125
|
+
timeout=self._control_rpc_timeout,
|
|
121
126
|
),
|
|
122
127
|
operation_name="modify_ack_deadline",
|
|
123
128
|
)
|
|
@@ -11,7 +11,6 @@ from __future__ import annotations
|
|
|
11
11
|
import asyncio
|
|
12
12
|
import logging
|
|
13
13
|
from collections.abc import Sequence
|
|
14
|
-
from contextlib import suppress
|
|
15
14
|
from typing import Protocol
|
|
16
15
|
|
|
17
16
|
logger = logging.getLogger("repid.connections.pubsub.protocol")
|
|
@@ -32,9 +31,14 @@ class OperationInProgressOnCancellation(asyncio.CancelledError):
|
|
|
32
31
|
"""The caller was cancelled after its control operation left the pending batch.
|
|
33
32
|
|
|
34
33
|
The RPC may already have reached Pub/Sub, so a message must not attempt a
|
|
35
|
-
different disposition after receiving this exception.
|
|
34
|
+
different disposition after receiving this exception. The completion future
|
|
35
|
+
allows the caller to order subsequent operations after the detached RPC.
|
|
36
36
|
"""
|
|
37
37
|
|
|
38
|
+
def __init__(self, completion: asyncio.Future[None]) -> None:
|
|
39
|
+
super().__init__()
|
|
40
|
+
self.completion = completion
|
|
41
|
+
|
|
38
42
|
|
|
39
43
|
class _Operation:
|
|
40
44
|
__slots__ = ("ack_id", "future")
|
|
@@ -91,36 +95,29 @@ class PubsubControlBatcher:
|
|
|
91
95
|
self._lock = asyncio.Lock()
|
|
92
96
|
self._ack_batches: dict[str, _AckBatch] = {}
|
|
93
97
|
self._modify_batches: dict[tuple[str, int], _ModifyBatch] = {}
|
|
94
|
-
self.
|
|
95
|
-
self.
|
|
98
|
+
self._flush_task: asyncio.Task[None] | None = None
|
|
99
|
+
self._batch_tasks: set[asyncio.Task[None]] = set()
|
|
96
100
|
self._shutdown_event = asyncio.Event()
|
|
97
101
|
|
|
98
102
|
async def start(self) -> None:
|
|
99
|
-
self.
|
|
103
|
+
self._flush_task = asyncio.create_task(self._flush_loop())
|
|
100
104
|
|
|
101
105
|
async def stop(self) -> None:
|
|
102
106
|
self._shutdown_event.set()
|
|
103
|
-
if self.
|
|
104
|
-
self.
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
await self._drain_immediate_tasks()
|
|
110
|
-
|
|
111
|
-
async def _drain_immediate_tasks(self) -> None:
|
|
112
|
-
"""Wait for detached full batches, including tasks added while draining."""
|
|
113
|
-
while tasks := tuple(self._immediate_tasks):
|
|
114
|
-
await asyncio.gather(*tasks, return_exceptions=True)
|
|
115
|
-
self._immediate_tasks.difference_update(tasks)
|
|
107
|
+
if self._flush_task is not None:
|
|
108
|
+
await asyncio.shield(self._flush_task)
|
|
109
|
+
self._flush_task = None
|
|
110
|
+
await self._flush()
|
|
111
|
+
if self._batch_tasks:
|
|
112
|
+
await asyncio.wait(self._batch_tasks)
|
|
116
113
|
|
|
117
114
|
async def _flush_loop(self) -> None:
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
115
|
+
while not self._shutdown_event.is_set():
|
|
116
|
+
try:
|
|
117
|
+
async with asyncio.timeout(self._flush_interval):
|
|
118
|
+
await self._shutdown_event.wait()
|
|
119
|
+
except TimeoutError:
|
|
120
|
+
await self._flush()
|
|
124
121
|
|
|
125
122
|
async def add_ack(self, subscription_path: str, ack_id: str) -> None:
|
|
126
123
|
future = asyncio.get_running_loop().create_future()
|
|
@@ -128,6 +125,8 @@ class PubsubControlBatcher:
|
|
|
128
125
|
immediate: _AckBatch | None = None
|
|
129
126
|
|
|
130
127
|
async with self._lock:
|
|
128
|
+
if self._shutdown_event.is_set():
|
|
129
|
+
raise ConnectionError("Pub/Sub control batcher is stopped.")
|
|
131
130
|
batch = self._ack_batches.get(subscription_path)
|
|
132
131
|
if batch is None:
|
|
133
132
|
batch = _AckBatch()
|
|
@@ -139,7 +138,7 @@ class PubsubControlBatcher:
|
|
|
139
138
|
immediate = batch
|
|
140
139
|
|
|
141
140
|
if immediate is not None:
|
|
142
|
-
self.
|
|
141
|
+
self._track_batch_task(
|
|
143
142
|
asyncio.create_task(self._execute_ack_batch(subscription_path, immediate)),
|
|
144
143
|
)
|
|
145
144
|
|
|
@@ -157,6 +156,8 @@ class PubsubControlBatcher:
|
|
|
157
156
|
immediate: _ModifyBatch | None = None
|
|
158
157
|
|
|
159
158
|
async with self._lock:
|
|
159
|
+
if self._shutdown_event.is_set():
|
|
160
|
+
raise ConnectionError("Pub/Sub control batcher is stopped.")
|
|
160
161
|
batch = self._modify_batches.get(key)
|
|
161
162
|
if batch is None:
|
|
162
163
|
batch = _ModifyBatch(seconds)
|
|
@@ -168,15 +169,15 @@ class PubsubControlBatcher:
|
|
|
168
169
|
immediate = batch
|
|
169
170
|
|
|
170
171
|
if immediate is not None:
|
|
171
|
-
self.
|
|
172
|
+
self._track_batch_task(
|
|
172
173
|
asyncio.create_task(self._execute_modify_batch(subscription_path, immediate)),
|
|
173
174
|
)
|
|
174
175
|
|
|
175
176
|
await self._await_operation(operation)
|
|
176
177
|
|
|
177
|
-
def
|
|
178
|
-
self.
|
|
179
|
-
task.add_done_callback(self.
|
|
178
|
+
def _track_batch_task(self, task: asyncio.Task[None]) -> None:
|
|
179
|
+
self._batch_tasks.add(task)
|
|
180
|
+
task.add_done_callback(self._batch_tasks.discard)
|
|
180
181
|
|
|
181
182
|
async def _await_operation(self, operation: _Operation) -> None:
|
|
182
183
|
future = operation.future
|
|
@@ -217,7 +218,7 @@ class PubsubControlBatcher:
|
|
|
217
218
|
# No caller remains to await this detached operation. Consume a
|
|
218
219
|
# later RPC failure so its future cannot become an unhandled error.
|
|
219
220
|
future.add_done_callback(self._consume_abandoned_future)
|
|
220
|
-
raise OperationInProgressOnCancellation from None
|
|
221
|
+
raise OperationInProgressOnCancellation(future) from None
|
|
221
222
|
|
|
222
223
|
@staticmethod
|
|
223
224
|
def _consume_abandoned_future(future: asyncio.Future[None]) -> None:
|
|
@@ -241,24 +242,20 @@ class PubsubControlBatcher:
|
|
|
241
242
|
return True
|
|
242
243
|
return False
|
|
243
244
|
|
|
244
|
-
async def
|
|
245
|
+
async def _flush(self) -> None:
|
|
245
246
|
async with self._lock:
|
|
246
247
|
ack_batches = self._ack_batches
|
|
247
248
|
modify_batches = self._modify_batches
|
|
248
249
|
self._ack_batches = {}
|
|
249
250
|
self._modify_batches = {}
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
asyncio.create_task(self._execute_modify_batch(subscription_path, modify_batch)),
|
|
251
|
+
# A slow RPC for one batch must not delay the next delivery's renewal.
|
|
252
|
+
for path, ack_batch in ack_batches.items():
|
|
253
|
+
self._track_batch_task(asyncio.create_task(self._execute_ack_batch(path, ack_batch)))
|
|
254
|
+
for (path, _), modify_batch in modify_batches.items():
|
|
255
|
+
self._track_batch_task(
|
|
256
|
+
asyncio.create_task(self._execute_modify_batch(path, modify_batch)),
|
|
257
257
|
)
|
|
258
258
|
|
|
259
|
-
if tasks:
|
|
260
|
-
await asyncio.gather(*tasks, return_exceptions=True)
|
|
261
|
-
|
|
262
259
|
async def _execute_ack_batch(self, subscription_path: str, batch: _AckBatch) -> None:
|
|
263
260
|
try:
|
|
264
261
|
await self._client.acknowledge(subscription_path, batch.ids)
|