Skip to content
This repository has been archived by the owner on Nov 7, 2021. It is now read-only.

Allow inject connector from ElasticSearch till Connection #138

Merged
merged 3 commits into from
Apr 19, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions aioes/transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@ class Transport:

def __init__(self, endpoints, *,
sniffer_interval=None, sniffer_timeout=0.1, max_retries=3,
loop, verify_ssl=True):
loop, verify_ssl=True, connector=None):
self._loop = loop
self._connector = connector
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think here in Transport it should be connector_factory,
otherwise a single connector will be shared between different Connections (ClientSessions)
and when some connection will get dropped underlying ClientSession will close the shared connector
making other connections broken as well.
I think it could look like this:

connector_factory=lambda: None

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, going to change it and covering it with test.

self._endpoints = self._convert_endpoints(endpoints)
self._pool = ConnectionPool([], loop=loop)
self._verify_ssl = verify_ssl
Expand Down Expand Up @@ -148,7 +149,8 @@ def _reinitialize_endpoints(self):
connections.append(Connection(
endpoint,
loop=self._loop,
verify_ssl=self._verify_ssl))
verify_ssl=self._verify_ssl,
connector=self._connector))
self._pool.close()
random.shuffle(connections)
self._pool = ConnectionPool(connections, loop=self._loop)
Expand Down