20
20
import sys
21
21
from itertools import chain
22
22
23
+ from ..connection_pool import ConnectionPool
23
24
from ..exceptions import (
24
25
ConnectionError ,
25
26
ConnectionTimeout ,
26
27
SerializationError ,
27
28
TransportError ,
28
29
UnsupportedProductError ,
29
30
)
30
- from ..transport import Transport
31
+ from ..serializer import JSONSerializer
32
+ from ..transport import Transport , get_host_info
31
33
from .compat import get_running_loop
32
34
from .http_aiohttp import AIOHttpConnection
33
35
@@ -44,7 +46,26 @@ class AsyncTransport(Transport):
44
46
45
47
DEFAULT_CONNECTION_CLASS = AIOHttpConnection
46
48
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
+ ):
48
69
"""
49
70
:arg hosts: list of dictionaries, each containing keyword arguments to
50
71
create a `connection_class` instance
@@ -77,6 +98,8 @@ def __init__(self, hosts, *args, sniff_on_start=False, **kwargs):
77
98
don't support passing bodies with GET requests. If you set this to
78
99
'POST' a POST method will be used instead, if to 'source' then the body
79
100
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.
80
103
81
104
Any extra keyword arguments will be passed to the `connection_class`
82
105
when creating and instance unless overridden by that connection's
@@ -88,7 +111,23 @@ def __init__(self, hosts, *args, sniff_on_start=False, **kwargs):
88
111
self ._sniff_on_start_event = None # type: asyncio.Event
89
112
90
113
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 ,
92
131
)
93
132
94
133
# Don't enable sniffing on Cloud instances.
0 commit comments