poorbarcode commented on code in PR #22182:
URL: https://github.com/apache/pulsar/pull/22182#discussion_r1531665534


##########
pip/pip-344.md:
##########
@@ -0,0 +1,87 @@
+# PIP-344: Correct the behavior of the public API 
pulsarClient.getPartitionsForTopic(topicName)
+
+# Background knowledge
+
+**Topic auto-creation**
+- The partitioned topic auto-creation is dependent on 
`pulsarClient.getPartitionsForTopic`
+    - It triggers partitioned metadata creation by 
`pulsarClient.getPartitionsForTopic`
+    - And triggers the topic partition creation by producers' registration and 
consumers' registration.
+- When calling `pulsarClient.getPartitionsForTopic(topicName)`, Pulsar will 
automatically create the partitioned topic metadata if it does not exist, 
either using `HttpLookupService` or `BinaryProtoLookupService`.
+
+**Now `pulsarClient.getPartitionsForTopic`'s behavior**
+| case | broker allow `auto-create` | param allow <br> `create if not exists` 
| non-partitioned topic | partitioned topic |  current behavior |
+| --- | --- | --- | --- | --- | --- |
+| 1 | `true/false` | `true/false` | `exists: true` | | REST API: `partitions: 
0`<br> Client API: `partitions: 0` |
+| 2 | `true/false` | `true/false` | | `exists: true` <br> `partitions: 3` | 
REST API: `partitions: 3`<br> Client API: `partitions: 3` |
+| 3 | `true` | `true` | | | REST API: <br> &nbsp;&nbsp;- `create new: true` 
<br> &nbsp;&nbsp;- `partitions: 3` <br> Client API: <br> &nbsp;&nbsp;- `create 
new: true` <br> &nbsp;&nbsp;- `partitions: 3` <br> |
+| 4 | `true` | `false` | | | REST API: <br> &nbsp;&nbsp;- `create new: false` 
<br> &nbsp;&nbsp;- `partitions: 0` <br> Client API: <br> &nbsp;&nbsp;not 
support <br> |
+| 5 | `false` | `true` | | | REST API: <br> &nbsp;&nbsp;- `create new: false` 
<br> &nbsp;&nbsp;- `partitions: 0` <br> Client API: <br> &nbsp;&nbsp;- `create 
new: false` <br> &nbsp;&nbsp;- `partitions: 0` <br> |

Review Comment:
   Updated the doc below. The three questions have been answered. 
   <img width="998" alt="Screenshot 2024-03-20 at 16 23 48" 
src="https://github.com/apache/pulsar/assets/25195800/044a9284-a5d1-4321-a6b8-db6415ca1446";>
   



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to