2020import sys
2121from itertools import chain
2222
23+ from ..connection_pool import ConnectionPool
2324from ..exceptions import (
2425 ConnectionError ,
2526 ConnectionTimeout ,
2627 SerializationError ,
2728 TransportError ,
2829 UnsupportedProductError ,
2930)
30- from ..transport import Transport
31+ from ..serializer import JSONSerializer
32+ from ..transport import Transport , get_host_info
3133from .compat import get_running_loop
3234from .http_aiohttp import AIOHttpConnection
3335
@@ -44,7 +46,26 @@ class AsyncTransport(Transport):
4446
4547 DEFAULT_CONNECTION_CLASS = AIOHttpConnection
4648
47- def __init__ (self , hosts , * args , sniff_on_start = False , ** kwargs ):
49+ def __init__ (
50+ self ,
51+ hosts ,
52+ connection_class = None ,
53+ connection_pool_class = ConnectionPool ,
54+ host_info_callback = get_host_info ,
55+ sniff_on_start = False ,
56+ sniffer_timeout = None ,
57+ sniff_timeout = 0.1 ,
58+ sniff_on_connection_fail = False ,
59+ serializer = JSONSerializer (),
60+ serializers = None ,
61+ default_mimetype = "application/json" ,
62+ max_retries = 3 ,
63+ retry_on_status = (502 , 503 , 504 ),
64+ retry_on_timeout = False ,
65+ send_get_body_as = "GET" ,
66+ meta_header = True ,
67+ ** kwargs
68+ ):
4869 """
4970 :arg hosts: list of dictionaries, each containing keyword arguments to
5071 create a `connection_class` instance
@@ -77,6 +98,8 @@ def __init__(self, hosts, *args, sniff_on_start=False, **kwargs):
7798 don't support passing bodies with GET requests. If you set this to
7899 'POST' a POST method will be used instead, if to 'source' then the body
79100 will be serialized and passed as a query parameter `source`.
101+ :arg meta_header: If True will send the 'X-Elastic-Client-Meta' HTTP header containing
102+ simple client metadata. Setting to False will disable the header. Defaults to True.
80103
81104 Any extra keyword arguments will be passed to the `connection_class`
82105 when creating and instance unless overridden by that connection's
@@ -88,7 +111,23 @@ def __init__(self, hosts, *args, sniff_on_start=False, **kwargs):
88111 self ._sniff_on_start_event = None # type: asyncio.Event
89112
90113 super (AsyncTransport , self ).__init__ (
91- * args , hosts = [], sniff_on_start = False , ** kwargs
114+ hosts = [],
115+ connection_class = connection_class ,
116+ connection_pool_class = connection_pool_class ,
117+ host_info_callback = host_info_callback ,
118+ sniff_on_start = False ,
119+ sniffer_timeout = sniffer_timeout ,
120+ sniff_timeout = sniff_timeout ,
121+ sniff_on_connection_fail = sniff_on_connection_fail ,
122+ serializer = serializer ,
123+ serializers = serializers ,
124+ default_mimetype = default_mimetype ,
125+ max_retries = max_retries ,
126+ retry_on_status = retry_on_status ,
127+ retry_on_timeout = retry_on_timeout ,
128+ send_get_body_as = send_get_body_as ,
129+ meta_header = meta_header ,
130+ ** kwargs ,
92131 )
93132
94133 # Don't enable sniffing on Cloud instances.
0 commit comments