6666 IPROTO_FEATURE_TRANSACTIONS ,
6767 IPROTO_FEATURE_ERROR_EXTENSION ,
6868 IPROTO_FEATURE_WATCHERS ,
69+ IPROTO_FEATURE_PAGINATION ,
70+ IPROTO_FEATURE_SPACE_AND_INDEX_NAMES ,
71+ IPROTO_FEATURE_WATCH_ONCE ,
6972 IPROTO_CHUNK ,
7073 AUTH_TYPE_CHAP_SHA1 ,
7174 AUTH_TYPE_PAP_SHA256 ,
@@ -608,7 +611,9 @@ def __init__(self, host, port,
608611 packer_factory = default_packer_factory ,
609612 unpacker_factory = default_unpacker_factory ,
610613 auth_type = None ,
611- fetch_schema = True ):
614+ fetch_schema = True ,
615+ required_protocol_version = None ,
616+ required_features = None ):
612617 """
613618 :param host: Server hostname or IP address. Use ``None`` for
614619 Unix sockets.
@@ -777,6 +782,14 @@ def __init__(self, host, port,
777782 :meth:`~tarantool.Connection.space`.
778783 :type fetch_schema: :obj:`bool`, optional
779784
785+ :param required_protocol_version: Minimal protocol version that
786+ should be supported by Tarantool server.
787+ :type required_protocol_version: :obj:`int` or :obj:`None`, optional
788+
789+ :param required_features: List of protocol features that
790+ should be supported by Tarantool server.
791+ :type required_features: :obj:`list` or :obj:`None`, optional
792+
780793 :raise: :exc:`~tarantool.error.ConfigurationError`,
781794 :meth:`~tarantool.Connection.connect` exceptions
782795
@@ -785,7 +798,7 @@ def __init__(self, host, port,
785798 .. _mp_bin: https://github.com/msgpack/msgpack/blob/master/spec.md#bin-format-family
786799 .. _mp_array: https://github.com/msgpack/msgpack/blob/master/spec.md#array-format-family
787800 """
788- # pylint: disable=too-many-arguments,too-many-locals
801+ # pylint: disable=too-many-arguments,too-many-locals,too-many-statements
789802
790803 if msgpack .version >= (1 , 0 , 0 ) and encoding not in (None , 'utf-8' ):
791804 raise ConfigurationError ("msgpack>=1.0.0 only supports None and "
@@ -831,6 +844,9 @@ def __init__(self, host, port,
831844 IPROTO_FEATURE_TRANSACTIONS : False ,
832845 IPROTO_FEATURE_ERROR_EXTENSION : False ,
833846 IPROTO_FEATURE_WATCHERS : False ,
847+ IPROTO_FEATURE_PAGINATION : False ,
848+ IPROTO_FEATURE_SPACE_AND_INDEX_NAMES : False ,
849+ IPROTO_FEATURE_WATCH_ONCE : False ,
834850 }
835851 self ._packer_factory_impl = packer_factory
836852 self ._unpacker_factory_impl = unpacker_factory
@@ -843,6 +859,8 @@ def __init__(self, host, port,
843859 self ._client_features = copy (CONNECTOR_FEATURES )
844860 self ._server_protocol_version = None
845861 self ._server_features = None
862+ self .required_protocol_version = required_protocol_version
863+ self .required_features = copy (required_features )
846864
847865 if connect_now :
848866 self .connect ()
@@ -2076,6 +2094,21 @@ def _check_features(self):
20762094 if exc .code != ER_UNKNOWN_REQUEST_TYPE :
20772095 raise exc
20782096
2097+ if self .required_protocol_version is not None :
2098+ if self ._server_protocol_version is None or \
2099+ self ._server_protocol_version < self .required_protocol_version :
2100+ raise ConfigurationError ('Server protocol version is '
2101+ f'{ self ._server_protocol_version } , '
2102+ f'protocol version { self .required_protocol_version } '
2103+ 'is required' )
2104+
2105+ if self .required_features is not None :
2106+ failed_features = [val for val in self .required_features
2107+ if val not in self ._server_features ]
2108+ if len (failed_features ) > 0 :
2109+ str_features = ', ' .join ([str (v ) for v in failed_features ])
2110+ raise ConfigurationError (f'Server missing protocol features with id { str_features } ' )
2111+
20792112 if self ._server_protocol_version is not None :
20802113 self ._protocol_version = min (self ._server_protocol_version ,
20812114 self ._client_protocol_version )
0 commit comments