You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by "nachatz (via GitHub)" <gi...@apache.org> on 2026/01/29 00:14:49 UTC

[PR] feat: add get partitioned topic names [pulsar-client-python]

nachatz opened a new pull request, #289:
URL: https://github.com/apache/pulsar-client-python/pull/289

   # Motivation
   Expands async client support to match the primary Client. Particularly adds the partitioned topic name async constructs.
   
   # Modifications
   Adds support for getting partition names.
   
   # Issue
   #288


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat: add get partitioned topic names [pulsar-client-python]

Posted by "BewareMyPower (via GitHub)" <gi...@apache.org>.
BewareMyPower merged PR #289:
URL: https://github.com/apache/pulsar-client-python/pull/289


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat: add get partitioned topic names [pulsar-client-python]

Posted by "nachatz (via GitHub)" <gi...@apache.org>.
nachatz commented on code in PR #289:
URL: https://github.com/apache/pulsar-client-python/pull/289#discussion_r2752375595


##########
tests/asyncio_test.py:
##########
@@ -133,6 +155,48 @@ async def test_flush(self):
         self.assertEqual(msg_id0.batch_index(), 0)
         self.assertEqual(msg_id1.batch_index(), 1)
 
+    async def test_get_topics_partitions(self):
+        topic_partitioned = "persistent://public/default/test_get_topics_partitions_async"
+        topic_non_partitioned = "persistent://public/default/test_get_topics_async_not-partitioned"
+
+        url1 = ADMIN_URL + "/admin/v2/persistent/public/default/test_get_topics_partitions_async/partitions"
+        doHttpPut(url1, "3")
+
+        self.assertEqual(
+            await self._client.get_topic_partitions(topic_partitioned),
+            [
+                "persistent://public/default/test_get_topics_partitions_async-partition-0",
+                "persistent://public/default/test_get_topics_partitions_async-partition-1",
+                "persistent://public/default/test_get_topics_partitions_async-partition-2",
+            ],
+        )
+        self.assertEqual(await self._client.get_topic_partitions(topic_non_partitioned), [topic_non_partitioned])
+
+    async def test_get_partitioned_topic_name(self):
+        url1 = ADMIN_URL + "/admin/v2/persistent/public/default/partitioned_topic_name_test/partitions"
+        doHttpPut(url1, "3")
+
+        partitions = [
+            "persistent://public/default/partitioned_topic_name_test-partition-0",
+            "persistent://public/default/partitioned_topic_name_test-partition-1",
+            "persistent://public/default/partitioned_topic_name_test-partition-2",
+        ]
+        self.assertEqual(
+            await self._client.get_topic_partitions("persistent://public/default/partitioned_topic_name_test"), partitions
+        )
+
+        consumer = await self._client.subscribe(
+            "persistent://public/default/partitioned_topic_name_test",
+            "partitioned_topic_name_test_sub",
+            consumer_type=pulsar.ConsumerType.Shared,
+        )
+        producer = await self._client.create_producer("persistent://public/default/partitioned_topic_name_test")
+        await producer.send(b"hello")
+
+        async with asyncio.timeout(TIMEOUT_MS / 1000):

Review Comment:
   Got it -- thank you.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat: add get partitioned topic names [pulsar-client-python]

Posted by "BewareMyPower (via GitHub)" <gi...@apache.org>.
BewareMyPower commented on code in PR #289:
URL: https://github.com/apache/pulsar-client-python/pull/289#discussion_r2752320302


##########
tests/asyncio_test.py:
##########
@@ -133,6 +155,48 @@ async def test_flush(self):
         self.assertEqual(msg_id0.batch_index(), 0)
         self.assertEqual(msg_id1.batch_index(), 1)
 
+    async def test_get_topics_partitions(self):
+        topic_partitioned = "persistent://public/default/test_get_topics_partitions_async"
+        topic_non_partitioned = "persistent://public/default/test_get_topics_async_not-partitioned"
+
+        url1 = ADMIN_URL + "/admin/v2/persistent/public/default/test_get_topics_partitions_async/partitions"
+        doHttpPut(url1, "3")
+
+        self.assertEqual(
+            await self._client.get_topic_partitions(topic_partitioned),
+            [
+                "persistent://public/default/test_get_topics_partitions_async-partition-0",
+                "persistent://public/default/test_get_topics_partitions_async-partition-1",
+                "persistent://public/default/test_get_topics_partitions_async-partition-2",
+            ],
+        )
+        self.assertEqual(await self._client.get_topic_partitions(topic_non_partitioned), [topic_non_partitioned])
+
+    async def test_get_partitioned_topic_name(self):
+        url1 = ADMIN_URL + "/admin/v2/persistent/public/default/partitioned_topic_name_test/partitions"
+        doHttpPut(url1, "3")
+
+        partitions = [
+            "persistent://public/default/partitioned_topic_name_test-partition-0",
+            "persistent://public/default/partitioned_topic_name_test-partition-1",
+            "persistent://public/default/partitioned_topic_name_test-partition-2",
+        ]
+        self.assertEqual(
+            await self._client.get_topic_partitions("persistent://public/default/partitioned_topic_name_test"), partitions
+        )
+
+        consumer = await self._client.subscribe(
+            "persistent://public/default/partitioned_topic_name_test",
+            "partitioned_topic_name_test_sub",
+            consumer_type=pulsar.ConsumerType.Shared,
+        )
+        producer = await self._client.create_producer("persistent://public/default/partitioned_topic_name_test")
+        await producer.send(b"hello")
+
+        async with asyncio.timeout(TIMEOUT_MS / 1000):

Review Comment:
   The `timeout` function is first added in Python 3.11. Since Python 3.10 won't reach the EOL until Nov. 2026, you can use `asyncio.wait_for` instead



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org