Skip to content

Commit 8d2b11b

Browse files
conn: store client and server protocol info
Store client and server protocol version and features in connection object, similar to go-tarantool [1]. Before the patch, we stored only products: minimal protocol version of server and client and the list of features supported both by client and server. 1. tarantool/go-tarantool#226 Part of #267
1 parent 80c12dc commit 8d2b11b

File tree

1 file changed

+24
-17
lines changed

1 file changed

+24
-17
lines changed

tarantool/connection.py

+24-17
Original file line numberDiff line numberDiff line change
@@ -1044,10 +1044,11 @@ def handshake(self):
10441044
if greeting.protocol != "Binary":
10451045
raise NetworkError("Unsupported protocol: " + greeting.protocol)
10461046
self.version_id = greeting.version_id
1047-
if self.version_id >= version_id(2, 10, 0):
1048-
self._check_features()
10491047
self.uuid = greeting.uuid
10501048
self._salt = greeting.salt
1049+
1050+
self._check_features()
1051+
10511052
if self.user:
10521053
self.authenticate(self.user, self.password)
10531054

@@ -2057,21 +2058,27 @@ def _check_features(self):
20572058
:exc:`~tarantool.error.SslError`
20582059
"""
20592060

2060-
try:
2061-
request = RequestProtocolVersion(self,
2062-
CONNECTOR_IPROTO_VERSION,
2063-
CONNECTOR_FEATURES)
2064-
response = self._send_request(request)
2065-
server_protocol_version = response.protocol_version
2066-
server_features = response.features
2067-
server_auth_type = response.auth_type
2068-
except DatabaseError as exc:
2069-
if exc.code == ER_UNKNOWN_REQUEST_TYPE:
2070-
server_protocol_version = None
2071-
server_features = []
2072-
server_auth_type = None
2073-
else:
2074-
raise exc
2061+
server_protocol_version = None
2062+
server_features = []
2063+
server_auth_type = None
2064+
2065+
if self.version_id >= version_id(2, 10, 0):
2066+
try:
2067+
request = RequestProtocolVersion(self,
2068+
CONNECTOR_IPROTO_VERSION,
2069+
CONNECTOR_FEATURES)
2070+
response = self._send_request(request)
2071+
server_protocol_version = response.protocol_version
2072+
server_features = response.features
2073+
server_auth_type = response.auth_type
2074+
except DatabaseError as exc:
2075+
if exc.code != ER_UNKNOWN_REQUEST_TYPE:
2076+
raise exc
2077+
2078+
self.client_protocol_version = CONNECTOR_IPROTO_VERSION
2079+
self.client_features = copy(CONNECTOR_FEATURES)
2080+
self.server_protocol_version = server_protocol_version
2081+
self.server_features = copy(server_features)
20752082

20762083
if server_protocol_version is not None:
20772084
self._protocol_version = min(server_protocol_version,

0 commit comments

Comments
 (0)