6565 IPROTO_FEATURE_TRANSACTIONS ,
6666 IPROTO_FEATURE_ERROR_EXTENSION ,
6767 IPROTO_FEATURE_WATCHERS ,
68+ IPROTO_FEATURE_PAGINATION ,
69+ IPROTO_FEATURE_SPACE_AND_INDEX_NAMES ,
70+ IPROTO_FEATURE_WATCH_ONCE ,
6871 IPROTO_CHUNK ,
6972 AUTH_TYPE_CHAP_SHA1 ,
7073 AUTH_TYPE_PAP_SHA256 ,
@@ -607,7 +610,9 @@ def __init__(self, host, port,
607610 packer_factory = default_packer_factory ,
608611 unpacker_factory = default_unpacker_factory ,
609612 auth_type = None ,
610- fetch_schema = True ):
613+ fetch_schema = True ,
614+ required_protocol_version = None ,
615+ required_protocol_features = None ):
611616 """
612617 :param host: Server hostname or IP address. Use ``None`` for
613618 Unix sockets.
@@ -776,6 +781,14 @@ def __init__(self, host, port,
776781 :meth:`~tarantool.Connection.space`.
777782 :type fetch_schema: :obj:`bool`, optional
778783
784+ :param required_protocol_version: Minimal protocol version that
785+ should be supported by Tarantool server.
786+ :type required_protocol_version: :obj:`int` or :obj:`None`, optional
787+
788+ :param required_protocol_features: List of protocol features that
789+ should be supported by Tarantool server.
790+ :type required_protocol_version: :obj:`list` or :obj:`None`, optional
791+
779792 :raise: :exc:`~tarantool.error.ConfigurationError`,
780793 :meth:`~tarantool.Connection.connect` exceptions
781794
@@ -830,6 +843,9 @@ def __init__(self, host, port,
830843 IPROTO_FEATURE_TRANSACTIONS : False ,
831844 IPROTO_FEATURE_ERROR_EXTENSION : False ,
832845 IPROTO_FEATURE_WATCHERS : False ,
846+ IPROTO_FEATURE_PAGINATION : False ,
847+ IPROTO_FEATURE_SPACE_AND_INDEX_NAMES : False ,
848+ IPROTO_FEATURE_WATCH_ONCE : False ,
833849 }
834850 self ._packer_factory_impl = packer_factory
835851 self ._unpacker_factory_impl = unpacker_factory
@@ -838,6 +854,8 @@ def __init__(self, host, port,
838854 self .version_id = None
839855 self .uuid = None
840856 self ._salt = None
857+ self .required_protocol_version = required_protocol_version
858+ self .required_protocol_features = copy (required_protocol_features )
841859
842860 if connect_now :
843861 self .connect ()
@@ -2080,6 +2098,20 @@ def _check_features(self):
20802098 self .server_protocol_version = server_protocol_version
20812099 self .server_features = copy (server_features )
20822100
2101+ if self .required_protocol_version is not None :
2102+ if server_protocol_version is None or \
2103+ server_protocol_version < self .required_protocol_version :
2104+ raise ConfigurationError (f'Server protocol version is { server_protocol_version } , '
2105+ f'protocol version { self .required_protocol_version } '
2106+ 'is required' )
2107+
2108+ if self .required_protocol_features is not None :
2109+ failed_features = [val for val in self .required_protocol_features
2110+ if val not in server_features ]
2111+ if len (failed_features ) > 0 :
2112+ str_features = ', ' .join ([str (v ) for v in failed_features ])
2113+ raise ConfigurationError (f'Server missing protocol features with id { str_features } ' )
2114+
20832115 if server_protocol_version is not None :
20842116 self ._protocol_version = min (server_protocol_version ,
20852117 CONNECTOR_IPROTO_VERSION )
0 commit comments