diff --git a/CHANGELOG.md b/CHANGELOG.md index cf2250df..aedd7699 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - Add release workflows ([#240](https://github.com/opensearch-project/opensearch-py/pull/240)) - Added SigV4 support for Async Opensearch Client ([#254](https://github.com/opensearch-project/opensearch-py/pull/254)) - Compatibility with OpenSearch 2.1.0 - 2.4.1 ([#257](https://github.com/opensearch-project/opensearch-py/pull/257)) +- Adding explicit parameters for AIOHttpConnection and AsyncTransport ([#276](https://github.com/opensearch-project/opensearch-py/pull/276)) ### Changed - Updated getting started to user guide ([#233](https://github.com/opensearch-project/opensearch-py/pull/233)) - Updated CA certificate handling to check OpenSSL environment variables before defaulting to certifi ([#196](https://github.com/opensearch-project/opensearch-py/pull/196)) diff --git a/opensearchpy/_async/http_aiohttp.py b/opensearchpy/_async/http_aiohttp.py index 20e89ea0..6f96997e 100644 --- a/opensearchpy/_async/http_aiohttp.py +++ b/opensearchpy/_async/http_aiohttp.py @@ -74,6 +74,8 @@ class AIOHttpConnection(AsyncConnection): self, host="localhost", port=None, + url_prefix="", + timeout=10, http_auth=None, use_ssl=False, verify_certs=VERIFY_CERTS_DEFAULT, @@ -130,6 +132,8 @@ class AIOHttpConnection(AsyncConnection): super().__init__( host=host, port=port, + url_prefix=url_prefix, + timeout=timeout, use_ssl=use_ssl, headers=headers, http_compress=http_compress, diff --git a/opensearchpy/_async/http_aiohttp.pyi b/opensearchpy/_async/http_aiohttp.pyi index c82a7ee8..f148830c 100644 --- a/opensearchpy/_async/http_aiohttp.pyi +++ b/opensearchpy/_async/http_aiohttp.pyi @@ -49,6 +49,8 @@ class AIOHttpConnection(AsyncConnection): self, host: str = ..., port: Optional[int] = ..., + url_prefix: str = ..., + timeout: int = ..., http_auth: Optional[Any] = ..., use_ssl: bool = ..., verify_certs: bool = ..., diff --git a/opensearchpy/_async/transport.py b/opensearchpy/_async/transport.py index 5c7b8d8b..65b2bdec 100644 --- a/opensearchpy/_async/transport.py +++ b/opensearchpy/_async/transport.py @@ -30,13 +30,15 @@ import logging import sys from itertools import chain +from ..connection_pool import ConnectionPool from ..exceptions import ( ConnectionError, ConnectionTimeout, SerializationError, TransportError, ) -from ..transport import Transport +from ..serializer import JSONSerializer +from ..transport import Transport, get_host_info from .compat import get_running_loop from .http_aiohttp import AIOHttpConnection @@ -53,7 +55,25 @@ class AsyncTransport(Transport): DEFAULT_CONNECTION_CLASS = AIOHttpConnection - def __init__(self, hosts, *args, sniff_on_start=False, **kwargs): + def __init__( + self, + hosts, + connection_class=None, + connection_pool_class=ConnectionPool, + host_info_callback=get_host_info, + sniff_on_start=False, + sniffer_timeout=None, + sniff_timeout=0.1, + sniff_on_connection_fail=False, + serializer=JSONSerializer(), + serializers=None, + default_mimetype="application/json", + max_retries=3, + retry_on_status=(502, 503, 504), + retry_on_timeout=False, + send_get_body_as="GET", + **kwargs + ): """ :arg hosts: list of dictionaries, each containing keyword arguments to create a `connection_class` instance @@ -97,7 +117,22 @@ class AsyncTransport(Transport): self._sniff_on_start_event = None # type: asyncio.Event super(AsyncTransport, self).__init__( - *args, hosts=[], sniff_on_start=False, **kwargs + hosts=[], + connection_class=connection_class, + connection_pool_class=connection_pool_class, + host_info_callback=host_info_callback, + sniff_on_start=False, + sniffer_timeout=sniffer_timeout, + sniff_timeout=sniff_timeout, + sniff_on_connection_fail=sniff_on_connection_fail, + serializer=serializer, + serializers=serializers, + default_mimetype=default_mimetype, + max_retries=max_retries, + retry_on_status=retry_on_status, + retry_on_timeout=retry_on_timeout, + send_get_body_as=send_get_body_as, + **kwargs ) # Since we defer connections / sniffing to not occur