Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rabbitmq heartbeat env #1285

Merged
merged 2 commits into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/ocrd/cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
\b
{config.describe('OCRD_NETWORK_RABBITMQ_CLIENT_CONNECT_ATTEMPTS')}
\b
{config.describe('OCRD_NETWORK_RABBITMQ_HEARTBEAT')}
\b
{config.describe('OCRD_PROFILE_FILE')}
\b
{config.describe('OCRD_PROFILE', wrap_text=False)}
Expand Down
4 changes: 2 additions & 2 deletions src/ocrd_network/rabbitmq_utils/connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from typing import Any, Optional, Union
from pika import BasicProperties, BlockingConnection, ConnectionParameters, PlainCredentials
from pika.adapters.blocking_connection import BlockingChannel
from ocrd_utils import config
from .constants import (
DEFAULT_EXCHANGER_NAME,
DEFAULT_EXCHANGER_TYPE,
Expand Down Expand Up @@ -69,8 +70,7 @@ def open_blocking_connection(
port=port,
virtual_host=vhost,
credentials=credentials,
# TODO: The heartbeat should not be disabled (0)!
heartbeat=0
heartbeat=config.OCRD_NETWORK_RABBITMQ_HEARTBEAT
),
)
return blocking_connection
Expand Down
14 changes: 12 additions & 2 deletions src/ocrd_utils/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,19 @@ def _ocrd_download_timeout_parser(val):
default=(True, ''))

config.add("OCRD_NETWORK_RABBITMQ_CLIENT_CONNECT_ATTEMPTS",
description="Number of attempts for a RabbitMQ client to connect before failing.",
description="Number of attempts for a RabbitMQ client to connect before failing.",
parser=int,
default=(True, 3))

config.add(
name="OCRD_NETWORK_RABBITMQ_HEARTBEAT",
description="""
Controls AMQP heartbeat timeout (in seconds) negotiation during connection tuning. An integer value always overrides the value
proposed by broker. Use 0 to deactivate heartbeat.
""",
parser=int,
default=(True, 3))
default=(True, 0)
)

config.add(name="OCRD_NETWORK_SOCKETS_ROOT_DIR",
description="The root directory where all mets server related socket files are created",
Expand Down
12 changes: 10 additions & 2 deletions tests/network/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,19 @@

test_config.add(
name="OCRD_NETWORK_RABBITMQ_CLIENT_CONNECT_ATTEMPTS",
description="Number of attempts for a RabbitMQ client to connect before failing",
parser=int,
default=(True, 3)
)

test_config.add(
name="OCRD_NETWORK_RABBITMQ_HEARTBEAT",
description="""
Number of attempts for a RabbitMQ client to connect before failing
Controls AMQP heartbeat timeout (in seconds) negotiation during connection tuning. An integer value always overrides the value
proposed by broker. Use 0 to deactivate heartbeat.
""",
parser=int,
default=(True, 3)
default=(True, 0)
)

test_config.add(
Expand Down