Transport#
- class elastic_transport.Transport(node_configs, node_class=<class 'elastic_transport.Urllib3HttpNode'>, node_pool_class=<class 'elastic_transport.NodePool'>, randomize_nodes_in_pool=True, node_selector_class=None, dead_node_backoff_factor=None, max_dead_node_backoff=None, serializers=None, default_mimetype='application/json', max_retries=3, retry_on_status=(429, 502, 503, 504), retry_on_timeout=False, sniff_on_start=False, sniff_before_requests=False, sniff_on_node_failure=False, sniff_timeout=0.5, min_delay_between_sniffing=10.0, sniff_callback=None, meta_header=True, client_meta_service=('et', '8.5.0p'))#
Encapsulation of transport-related to logic. Handles instantiation of the individual nodes as well as creating a node pool to hold them.
Main interface is the
elastic_transport.Transport.perform_request()
method.- perform_request(method, target, *, body=None, headers=DefaultType.value, max_retries=DefaultType.value, retry_on_status=DefaultType.value, retry_on_timeout=DefaultType.value, request_timeout=DefaultType.value, client_meta=DefaultType.value)#
Perform the actual request. Retrieve a node from the node pool, pass all the information to it’s perform_request method and return the data.
If an exception was raised, mark the node as failed and retry (up to
max_retries
times).If the operation was successful and the node used was previously marked as dead, mark it as live, resetting it’s failure count.
- Parameters:
method (
str
) – HTTP method to usetarget (
str
) – HTTP request targetbody (
Optional
[Any
]) – body of the request, will be serialized using serializer and passed to the nodeheaders (
Union
[Mapping
[str
,Any
],DefaultType
]) – Additional headers to send with the request.max_retries (
Union
[int
,DefaultType
]) – Maximum number of retries before giving up on a request. Set to0
to disable retries.retry_on_status (
Union
[Collection
[int
],DefaultType
]) – Collection of HTTP status codes to retry.retry_on_timeout (
Union
[bool
,DefaultType
]) – Set to true to retry after timeout errors.request_timeout (
Union
[float
,None
,DefaultType
]) – Amount of time to wait for a response to fail with a timeout error.client_meta (
Union
[Tuple
[Tuple
[str
,str
],...
],DefaultType
]) – Extra client metadata key-value pairs to send in the client meta header.
- Return type:
TransportApiResponse
- Returns:
Tuple of the
elastic_transport.ApiResponseMeta
with the deserialized response.
- class elastic_transport.AsyncTransport(node_configs, node_class=<class 'elastic_transport.AiohttpHttpNode'>, node_pool_class=<class 'elastic_transport.NodePool'>, randomize_nodes_in_pool=True, node_selector_class=None, dead_node_backoff_factor=None, max_dead_node_backoff=None, serializers=None, default_mimetype='application/json', max_retries=3, retry_on_status=(429, 502, 503, 504), retry_on_timeout=False, sniff_on_start=False, sniff_before_requests=False, sniff_on_node_failure=False, sniff_timeout=0.5, min_delay_between_sniffing=10.0, sniff_callback=None, meta_header=True, client_meta_service=('et', '8.5.0p'))#
Encapsulation of transport-related to logic. Handles instantiation of the individual nodes as well as creating a node pool to hold them.
Main interface is the
elastic_transport.Transport.perform_request()
method.- async perform_request(method, target, *, body=None, headers=DefaultType.value, max_retries=DefaultType.value, retry_on_status=DefaultType.value, retry_on_timeout=DefaultType.value, request_timeout=DefaultType.value, client_meta=DefaultType.value)#
Perform the actual request. Retrieve a node from the node pool, pass all the information to it’s perform_request method and return the data.
If an exception was raised, mark the node as failed and retry (up to
max_retries
times).If the operation was successful and the node used was previously marked as dead, mark it as live, resetting it’s failure count.
- Parameters:
method (
str
) – HTTP method to usetarget (
str
) – HTTP request targetbody (
Optional
[Any
]) – body of the request, will be serialized using serializer and passed to the nodeheaders (
Union
[Mapping
[str
,Any
],DefaultType
]) – Additional headers to send with the request.max_retries (
Union
[int
,DefaultType
]) – Maximum number of retries before giving up on a request. Set to0
to disable retries.retry_on_status (
Union
[Collection
[int
],DefaultType
]) – Collection of HTTP status codes to retry.retry_on_timeout (
Union
[bool
,DefaultType
]) – Set to true to retry after timeout errors.request_timeout (
Union
[float
,None
,DefaultType
]) – Amount of time to wait for a response to fail with a timeout error.client_meta (
Union
[Tuple
[Tuple
[str
,str
],...
],DefaultType
]) – Extra client metadata key-value pairs to send in the client meta header.
- Return type:
TransportApiResponse
- Returns:
Tuple of the
elastic_transport.ApiResponseMeta
with the deserialized response.