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

feat: add timeout config #73

Merged
merged 2 commits into from
Jan 30, 2025
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
12 changes: 12 additions & 0 deletions osman/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ def __init__(
aws_secret_access_key: str = AWS_SECRET_ACCESS_KEY,
aws_region: str = AWS_REGION,
aws_service: str = AWS_SERVICE,
timeout: int = 10,
max_retries: int = 1,
retry_on_timeout: bool = False,
):
"""
Init OsmanConfig.
Expand Down Expand Up @@ -146,6 +149,12 @@ def __init__(
init
aws_service: str
init
timeout: int
init
max_retries: int
init
retry_on_timeout: bool
init
"""
# non empty host_url takes precedence over auth_method
if host_url:
Expand Down Expand Up @@ -232,6 +241,9 @@ def __init__(
self.aws_secret_access_key = aws_secret_access_key
self.aws_region = aws_region
self.aws_service = aws_service
self.timeout = timeout
self.max_retries = max_retries
self.retry_on_timeout = retry_on_timeout

def _reload_defaults_from_env(self):
"""
Expand Down
3 changes: 3 additions & 0 deletions osman/osman.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@ def __init__(self, config: OsmanConfig = None):
os_params["use_ssl"] = config.opensearch_ssl_enabled
os_params["http_compress"] = True
os_params["connection_class"] = RequestsHttpConnection
os_params["timeout"] = config.timeout
os_params["max_retries"] = config.max_retries
os_params["retry_on_timeout"] = config.retry_on_timeout
self.client = OpenSearch(**os_params)

# Test the connection
Expand Down
Loading