Skip to content

Commit c54f257

Browse files
committed
Use consistent naming style
1 parent a244a5f commit c54f257

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

aiokafka/protocol/api.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from .types import Array, Int16, Int32, Schema, String, TaggedFields
55

66

7-
class RequestHeader(Struct):
7+
class RequestHeader_v0(Struct):
88
SCHEMA = Schema(
99
("api_key", Int16),
1010
("api_version", Int16),
@@ -13,12 +13,12 @@ class RequestHeader(Struct):
1313
)
1414

1515
def __init__(self, request, correlation_id=0, client_id="aiokafka"):
16-
super(RequestHeader, self).__init__(
16+
super().__init__(
1717
request.API_KEY, request.API_VERSION, correlation_id, client_id
1818
)
1919

2020

21-
class RequestHeaderV2(Struct):
21+
class RequestHeader_v1(Struct):
2222
# Flexible response / request headers end in field buffer
2323
SCHEMA = Schema(
2424
("api_key", Int16),
@@ -29,18 +29,18 @@ class RequestHeaderV2(Struct):
2929
)
3030

3131
def __init__(self, request, correlation_id=0, client_id="aiokafka", tags=None):
32-
super(RequestHeaderV2, self).__init__(
32+
super().__init__(
3333
request.API_KEY, request.API_VERSION, correlation_id, client_id, tags or {}
3434
)
3535

3636

37-
class ResponseHeader(Struct):
37+
class ResponseHeader_v0(Struct):
3838
SCHEMA = Schema(
3939
("correlation_id", Int32),
4040
)
4141

4242

43-
class ResponseHeaderV2(Struct):
43+
class ResponseHeader_v1(Struct):
4444
SCHEMA = Schema(
4545
("correlation_id", Int32),
4646
("tags", TaggedFields),
@@ -81,15 +81,17 @@ def to_object(self):
8181

8282
def build_request_header(self, correlation_id, client_id):
8383
if self.FLEXIBLE_VERSION:
84-
return RequestHeaderV2(
84+
return RequestHeader_v1(
8585
self, correlation_id=correlation_id, client_id=client_id
8686
)
87-
return RequestHeader(self, correlation_id=correlation_id, client_id=client_id)
87+
return RequestHeader_v0(
88+
self, correlation_id=correlation_id, client_id=client_id
89+
)
8890

8991
def parse_response_header(self, read_buffer):
9092
if self.FLEXIBLE_VERSION:
91-
return ResponseHeaderV2.decode(read_buffer)
92-
return ResponseHeader.decode(read_buffer)
93+
return ResponseHeader_v1.decode(read_buffer)
94+
return ResponseHeader_v0.decode(read_buffer)
9395

9496

9597
class Response(Struct):

tests/test_protocol.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import pytest
66

7-
from aiokafka.protocol.api import Request, RequestHeader, Response
7+
from aiokafka.protocol.api import Request, RequestHeader_v0, Response
88
from aiokafka.protocol.commit import GroupCoordinatorRequest
99
from aiokafka.protocol.fetch import FetchRequest, FetchResponse
1010
from aiokafka.protocol.message import Message, MessageSet, PartialMessage
@@ -188,7 +188,7 @@ def test_encode_message_header():
188188
)
189189

190190
req = GroupCoordinatorRequest[0]("foo")
191-
header = RequestHeader(req, correlation_id=4, client_id="client3")
191+
header = RequestHeader_v0(req, correlation_id=4, client_id="client3")
192192
assert header.encode() == expect
193193

194194

0 commit comments

Comments
 (0)