Skip to content

Commit ec34860

Browse files
authored
Use Struct aliases for backwards compatibility (#2741)
* kafka.protocol.struct ALIASES * old proto ApiVersionsResponse ALIASES * old proto SaslHandshakeResponse ALIASES * old proto Fetch ALIASES * old proto ListOffsets internal field renames * old proto FindCoordinator ALIASES * old proto JoinGroup/SyncGroup ALIASES * old proto OffsetCommit/OffsetFetch ALIASES * old proto Admin api ALIASES * old proto producer message ALIASES * Fixup AddPartitionsToTxnRequest topics alias
1 parent b6c9f84 commit ec34860

12 files changed

Lines changed: 628 additions & 428 deletions

kafka/protocol/add_partitions_to_txn.py

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,47 +7,60 @@ class AddPartitionsToTxnResponse_v0(Response):
77
API_VERSION = 0
88
SCHEMA = Schema(
99
('throttle_time_ms', Int32),
10-
('results', Array(
11-
('topic', String('utf-8')),
12-
('partitions', Array(
13-
('partition', Int32),
14-
('error_code', Int16))))))
10+
('results_by_topic_v3_and_below', Array(
11+
('name', String('utf-8')),
12+
('results_by_partition', Array(
13+
('partition_index', Int32),
14+
('partition_error_code', Int16))))))
15+
ALIASES = {
16+
'results': 'results_by_topic_v3_and_below',
17+
}
1518

1619

1720
class AddPartitionsToTxnResponse_v1(Response):
1821
API_KEY = 24
1922
API_VERSION = 1
2023
SCHEMA = AddPartitionsToTxnResponse_v0.SCHEMA
24+
ALIASES = AddPartitionsToTxnResponse_v0.ALIASES
2125

2226

2327
class AddPartitionsToTxnResponse_v2(Response):
2428
API_KEY = 24
2529
API_VERSION = 2
2630
SCHEMA = AddPartitionsToTxnResponse_v1.SCHEMA
31+
ALIASES = AddPartitionsToTxnResponse_v1.ALIASES
2732

2833

2934
class AddPartitionsToTxnRequest_v0(Request):
3035
API_KEY = 24
3136
API_VERSION = 0
3237
SCHEMA = Schema(
33-
('transactional_id', String('utf-8')),
34-
('producer_id', Int64),
35-
('producer_epoch', Int16),
36-
('topics', Array(
37-
('topic', String('utf-8')),
38+
('v3_and_below_transactional_id', String('utf-8')),
39+
('v3_and_below_producer_id', Int64),
40+
('v3_and_below_producer_epoch', Int16),
41+
('v3_and_below_topics', Array(
42+
('name', String('utf-8')),
3843
('partitions', Array(Int32)))))
44+
ALIASES = {
45+
'transactional_id': 'v3_and_below_transactional_id',
46+
'producer_id': 'v3_and_below_producer_id',
47+
'producer_epoch': 'v3_and_below_producer_epoch',
48+
'topics': 'v3_and_below_topics',
49+
}
3950

4051

4152
class AddPartitionsToTxnRequest_v1(Request):
4253
API_KEY = 24
4354
API_VERSION = 1
4455
SCHEMA = AddPartitionsToTxnRequest_v0.SCHEMA
56+
ALIASES = AddPartitionsToTxnRequest_v0.ALIASES
4557

4658

4759
class AddPartitionsToTxnRequest_v2(Request):
4860
API_KEY = 24
4961
API_VERSION = 2
5062
SCHEMA = AddPartitionsToTxnRequest_v1.SCHEMA
63+
ALIASES = AddPartitionsToTxnRequest_v1.ALIASES
5164

5265

5366
AddPartitionsToTxnRequest = [

0 commit comments

Comments
 (0)