65
65
IPROTO_FEATURE_TRANSACTIONS ,
66
66
IPROTO_FEATURE_ERROR_EXTENSION ,
67
67
IPROTO_FEATURE_WATCHERS ,
68
+ IPROTO_FEATURE_PAGINATION ,
69
+ IPROTO_FEATURE_SPACE_AND_INDEX_NAMES ,
70
+ IPROTO_FEATURE_WATCH_ONCE ,
68
71
IPROTO_CHUNK ,
69
72
AUTH_TYPE_CHAP_SHA1 ,
70
73
AUTH_TYPE_PAP_SHA256 ,
@@ -607,7 +610,9 @@ def __init__(self, host, port,
607
610
packer_factory = default_packer_factory ,
608
611
unpacker_factory = default_unpacker_factory ,
609
612
auth_type = None ,
610
- fetch_schema = True ):
613
+ fetch_schema = True ,
614
+ required_protocol_version = None ,
615
+ required_protocol_features = None ):
611
616
"""
612
617
:param host: Server hostname or IP address. Use ``None`` for
613
618
Unix sockets.
@@ -776,6 +781,14 @@ def __init__(self, host, port,
776
781
:meth:`~tarantool.Connection.space`.
777
782
:type fetch_schema: :obj:`bool`, optional
778
783
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
+
779
792
:raise: :exc:`~tarantool.error.ConfigurationError`,
780
793
:meth:`~tarantool.Connection.connect` exceptions
781
794
@@ -830,6 +843,9 @@ def __init__(self, host, port,
830
843
IPROTO_FEATURE_TRANSACTIONS : False ,
831
844
IPROTO_FEATURE_ERROR_EXTENSION : False ,
832
845
IPROTO_FEATURE_WATCHERS : False ,
846
+ IPROTO_FEATURE_PAGINATION : False ,
847
+ IPROTO_FEATURE_SPACE_AND_INDEX_NAMES : False ,
848
+ IPROTO_FEATURE_WATCH_ONCE : False ,
833
849
}
834
850
self ._packer_factory_impl = packer_factory
835
851
self ._unpacker_factory_impl = unpacker_factory
@@ -838,6 +854,8 @@ def __init__(self, host, port,
838
854
self .version_id = None
839
855
self .uuid = None
840
856
self ._salt = None
857
+ self .required_protocol_version = required_protocol_version
858
+ self .required_protocol_features = copy (required_protocol_features )
841
859
842
860
if connect_now :
843
861
self .connect ()
@@ -2080,6 +2098,20 @@ def _check_features(self):
2080
2098
self .server_protocol_version = server_protocol_version
2081
2099
self .server_features = copy (server_features )
2082
2100
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
+
2083
2115
if server_protocol_version is not None :
2084
2116
self ._protocol_version = min (server_protocol_version ,
2085
2117
CONNECTOR_IPROTO_VERSION )
0 commit comments