diff --git a/osman/config.py b/osman/config.py index 74a5a13..54961e9 100644 --- a/osman/config.py +++ b/osman/config.py @@ -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. @@ -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: @@ -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): """ diff --git a/osman/osman.py b/osman/osman.py index d71431f..0c9665e 100644 --- a/osman/osman.py +++ b/osman/osman.py @@ -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