Skip to content

Commit e8d7151

Browse files
Add parsing TABLETS_ROUTING_V1 extension to ProtocolFeatures
In order for Scylla to send the tablet info, the driver must tell the database during connection handshake that it is able to interpret it. This negotation is added as a part of ProtocolFeatures class.
1 parent bc5cf17 commit e8d7151

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

cassandra/protocol_features.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,26 @@
66

77

88
RATE_LIMIT_ERROR_EXTENSION = "SCYLLA_RATE_LIMIT_ERROR"
9+
TABLETS_ROUTING_V1 = "TABLETS_ROUTING_V1"
910

1011
class ProtocolFeatures(object):
1112
rate_limit_error = None
1213
shard_id = 0
1314
sharding_info = None
15+
tablets_routing_v1 = False
1416

15-
def __init__(self, rate_limit_error=None, shard_id=0, sharding_info=None):
17+
def __init__(self, rate_limit_error=None, shard_id=0, sharding_info=None, tablets_routing_v1=False):
1618
self.rate_limit_error = rate_limit_error
1719
self.shard_id = shard_id
1820
self.sharding_info = sharding_info
21+
self.tablets_routing_v1 = tablets_routing_v1
1922

2023
@staticmethod
2124
def parse_from_supported(supported):
2225
rate_limit_error = ProtocolFeatures.maybe_parse_rate_limit_error(supported)
2326
shard_id, sharding_info = ProtocolFeatures.parse_sharding_info(supported)
24-
return ProtocolFeatures(rate_limit_error, shard_id, sharding_info)
27+
tablets_routing_v1 = ProtocolFeatures.parse_tablets_info(supported)
28+
return ProtocolFeatures(rate_limit_error, shard_id, sharding_info, tablets_routing_v1)
2529

2630
@staticmethod
2731
def maybe_parse_rate_limit_error(supported):
@@ -43,6 +47,8 @@ def get_cql_extension_field(vals, key):
4347
def add_startup_options(self, options):
4448
if self.rate_limit_error is not None:
4549
options[RATE_LIMIT_ERROR_EXTENSION] = ""
50+
if self.tablets_routing_v1:
51+
options[TABLETS_ROUTING_V1] = ""
4652

4753
@staticmethod
4854
def parse_sharding_info(options):
@@ -63,3 +69,6 @@ def parse_sharding_info(options):
6369
shard_aware_port, shard_aware_port_ssl)
6470

6571

72+
@staticmethod
73+
def parse_tablets_info(options):
74+
return TABLETS_ROUTING_V1 in options

0 commit comments

Comments
 (0)