Adding explicit parameters for AIOHttpConnection and AsyncTransport (#276)

Signed-off-by: saimedhi <[email protected]>

Signed-off-by: saimedhi <[email protected]>
This commit is contained in:
Sai Medhini Reddy Maryada
2023-01-19 15:15:35 -08:00
committed by GitHub
parent 5c1c890f69
commit 7d83a69494
4 changed files with 45 additions and 3 deletions
+1
View File
@@ -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))
+4
View File
@@ -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,
+2
View File
@@ -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 = ...,
+38 -3
View File
@@ -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