diff --git a/docs/settings.rst b/docs/settings.rst index e690da0..04b146b 100644 --- a/docs/settings.rst +++ b/docs/settings.rst @@ -74,6 +74,12 @@ however it may be overridden if Pub/Sub resources live in a different project. optional; string; Google only +**GOOGLE_PUBSUB_MAX_LEASE_DURATION_S** + +The maximum amount of time in seconds to hold a lease on a message before dropping it from the lease management. Defaults to 3600s (1 hour). + +optional: int; default: 3600; Google only + **GOOGLE_PUBSUB_READ_TIMEOUT_S** Read from PubSub subscription timeout in seconds diff --git a/hedwig/backends/gcp.py b/hedwig/backends/gcp.py index 7b0a62a..dc36ff3 100644 --- a/hedwig/backends/gcp.py +++ b/hedwig/backends/gcp.py @@ -263,6 +263,7 @@ def pull_messages( # type: ignore[return] flow_control: FlowControl = FlowControl( max_messages=num_messages, max_duration_per_lease_extension=visibility_timeout or DEFAULT_VISIBILITY_TIMEOUT_S, + max_lease_duration=settings.GOOGLE_PUBSUB_MAX_LEASE_DURATION_S, ) for subscription_path in self._subscription_paths: diff --git a/hedwig/conf/__init__.py b/hedwig/conf/__init__.py index bc63b46..3d87b6a 100644 --- a/hedwig/conf/__init__.py +++ b/hedwig/conf/__init__.py @@ -36,6 +36,7 @@ 'GOOGLE_APPLICATION_CREDENTIALS': None, 'GOOGLE_CLOUD_PROJECT': None, 'GOOGLE_PUBSUB_READ_TIMEOUT_S': 5, + 'GOOGLE_PUBSUB_MAX_LEASE_DURATION_S': 3600, 'REDIS_URL': None, 'HEDWIG_CALLBACKS': {}, 'HEDWIG_CONSUMER_BACKEND': None,