Skip to content

Commit 336bc73

Browse files
authored
Merge pull request #237 V3 fix reader arg order
2 parents 3ebf21d + 3b5db9f commit 336bc73

File tree

3 files changed

+15
-14
lines changed

3 files changed

+15
-14
lines changed

Diff for: CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
* Fixed global_allow_split_transactions
22
* Added reader.receive_message() method
3+
* Swap topic_path and consumer arguments in topic_client.reader method
34

45
## 3.0.1b10 ##
56
* fixed sqlalchemy get_columns method with not null columns

Diff for: tests/topics/test_topic_reader.py

+12-12
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class TestTopicReaderAsyncIO:
88
async def test_read_batch(
99
self, driver, topic_path, topic_with_messages, topic_consumer
1010
):
11-
reader = driver.topic_client.reader(topic_consumer, topic_path)
11+
reader = driver.topic_client.reader(topic_path, topic_consumer)
1212
batch = await reader.receive_batch()
1313

1414
assert batch is not None
@@ -19,7 +19,7 @@ async def test_read_batch(
1919
async def test_read_message(
2020
self, driver, topic_path, topic_with_messages, topic_consumer
2121
):
22-
reader = driver.topic_client.reader(topic_consumer, topic_path)
22+
reader = driver.topic_client.reader(topic_path, topic_consumer)
2323
msg = await reader.receive_message()
2424

2525
assert msg is not None
@@ -31,11 +31,11 @@ async def test_read_and_commit_message(
3131
self, driver, topic_path, topic_with_messages, topic_consumer
3232
):
3333

34-
reader = driver.topic_client.reader(topic_consumer, topic_path)
34+
reader = driver.topic_client.reader(topic_path, topic_consumer)
3535
batch = await reader.receive_batch()
3636
await reader.commit_with_ack(batch)
3737

38-
reader = driver.topic_client.reader(topic_consumer, topic_path)
38+
reader = driver.topic_client.reader(topic_path, topic_consumer)
3939
batch2 = await reader.receive_batch()
4040
assert batch.messages[0] != batch2.messages[0]
4141

@@ -47,7 +47,7 @@ async def test_read_compressed_messages(self, driver, topic_path, topic_consumer
4747
) as writer:
4848
await writer.write("123")
4949

50-
async with driver.topic_client.reader(topic_consumer, topic_path) as reader:
50+
async with driver.topic_client.reader(topic_path, topic_consumer) as reader:
5151
batch = await reader.receive_batch()
5252
assert batch.messages[0].data.decode() == "123"
5353

@@ -66,7 +66,7 @@ def decode(b: bytes):
6666
await writer.write("123")
6767

6868
async with driver.topic_client.reader(
69-
topic_consumer, topic_path, decoders={codec: decode}
69+
topic_path, topic_consumer, decoders={codec: decode}
7070
) as reader:
7171
batch = await reader.receive_batch()
7272
assert batch.messages[0].data.decode() == "123"
@@ -76,7 +76,7 @@ class TestTopicReaderSync:
7676
def test_read_batch(
7777
self, driver_sync, topic_path, topic_with_messages, topic_consumer
7878
):
79-
reader = driver_sync.topic_client.reader(topic_consumer, topic_path)
79+
reader = driver_sync.topic_client.reader(topic_path, topic_consumer)
8080
batch = reader.receive_batch()
8181

8282
assert batch is not None
@@ -87,7 +87,7 @@ def test_read_batch(
8787
def test_read_message(
8888
self, driver_sync, topic_path, topic_with_messages, topic_consumer
8989
):
90-
reader = driver_sync.topic_client.reader(topic_consumer, topic_path)
90+
reader = driver_sync.topic_client.reader(topic_path, topic_consumer)
9191
msg = reader.receive_message()
9292

9393
assert msg is not None
@@ -98,11 +98,11 @@ def test_read_message(
9898
def test_read_and_commit_message(
9999
self, driver_sync, topic_path, topic_with_messages, topic_consumer
100100
):
101-
reader = driver_sync.topic_client.reader(topic_consumer, topic_path)
101+
reader = driver_sync.topic_client.reader(topic_path, topic_consumer)
102102
batch = reader.receive_batch()
103103
reader.commit_with_ack(batch)
104104

105-
reader = driver_sync.topic_client.reader(topic_consumer, topic_path)
105+
reader = driver_sync.topic_client.reader(topic_path, topic_consumer)
106106
batch2 = reader.receive_batch()
107107
assert batch.messages[0] != batch2.messages[0]
108108

@@ -112,7 +112,7 @@ def test_read_compressed_messages(self, driver_sync, topic_path, topic_consumer)
112112
) as writer:
113113
writer.write("123")
114114

115-
with driver_sync.topic_client.reader(topic_consumer, topic_path) as reader:
115+
with driver_sync.topic_client.reader(topic_path, topic_consumer) as reader:
116116
batch = reader.receive_batch()
117117
assert batch.messages[0].data.decode() == "123"
118118

@@ -131,7 +131,7 @@ def decode(b: bytes):
131131
writer.write("123")
132132

133133
with driver_sync.topic_client.reader(
134-
topic_consumer, topic_path, decoders={codec: decode}
134+
topic_path, topic_consumer, decoders={codec: decode}
135135
) as reader:
136136
batch = reader.receive_batch()
137137
assert batch.messages[0].data.decode() == "123"

Diff for: ydb/topic.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,8 @@ async def drop_topic(self, path: str):
137137

138138
def reader(
139139
self,
140-
consumer: str,
141140
topic: str,
141+
consumer: str,
142142
buffer_size_bytes: int = 50 * 1024 * 1024,
143143
# decoders: map[codec_code] func(encoded_bytes)->decoded_bytes
144144
decoders: Union[Mapping[int, Callable[[bytes], bytes]], None] = None,
@@ -306,8 +306,8 @@ def drop_topic(self, path: str):
306306

307307
def reader(
308308
self,
309-
consumer: str,
310309
topic: str,
310+
consumer: str,
311311
buffer_size_bytes: int = 50 * 1024 * 1024,
312312
# decoders: map[codec_code] func(encoded_bytes)->decoded_bytes
313313
decoders: Union[Mapping[int, Callable[[bytes], bytes]], None] = None,

0 commit comments

Comments
 (0)