You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2022/12/26 10:14:20 UTC

[GitHub] [pulsar-client-python] BewareMyPower opened a new issue, #66: [feature request] Give a human readable description for MessageId

BewareMyPower opened a new issue, #66:
URL: https://github.com/apache/pulsar-client-python/issues/66

   Currently the `MessageId` cannot be converted to a human readable string.
   
   ```python
   >>> producer.send('hello'.encode('utf-8'))
   <_pulsar.MessageId object at 0x00000226E895AC70>
   ```


-- 
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.apache.org

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


[GitHub] [pulsar-client-python] erichare commented on issue #66: [feature request] Give a human readable description for MessageId

Posted by "erichare (via GitHub)" <gi...@apache.org>.
erichare commented on issue #66:
URL: https://github.com/apache/pulsar-client-python/issues/66#issuecomment-1420052277

   Awesome, thanks @BewareMyPower . Yep should be pretty straight forward. Only immediate question I have - is there actually an existing toString (or similar) implementation on the C++ client for MessageId? I looked here: https://github.com/apache/pulsar-client-cpp/blob/main/lib/MessageId.cc and didnt see it. I guess we could have something like:
   
   ```
       std::string toString() const {
           return std::to_string(impl_->ledgerId_) + ":" + std::to_string(impl_-> entryId_) + ":" + std::to_string(impl_->partition_)
       }
    ```
   
   With an added conditional to include the batch index if needed. I just wanted to make sure im not missing somewhere where this has already been done.
    
    


-- 
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


[GitHub] [pulsar-client-python] erichare commented on issue #66: [feature request] Give a human readable description for MessageId

Posted by "erichare (via GitHub)" <gi...@apache.org>.
erichare commented on issue #66:
URL: https://github.com/apache/pulsar-client-python/issues/66#issuecomment-1420114366

   Thanks @BewareMyPower - very unfamiliar with C++ so appreciate the guidance 👍 . I'll open a PR soon 


-- 
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


[GitHub] [pulsar-client-python] erichare commented on issue #66: [feature request] Give a human readable description for MessageId

Posted by "erichare (via GitHub)" <gi...@apache.org>.
erichare commented on issue #66:
URL: https://github.com/apache/pulsar-client-python/issues/66#issuecomment-1419859700

   @BewareMyPower I like the idea too, any thoughts on what would make for a nice string representation of a MessageId? Something indicating the entry_id, ledger_id, etc?


-- 
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


[GitHub] [pulsar-client-python] BewareMyPower commented on issue #66: [feature request] Give a human readable description for MessageId

Posted by "BewareMyPower (via GitHub)" <gi...@apache.org>.
BewareMyPower commented on issue #66:
URL: https://github.com/apache/pulsar-client-python/issues/66#issuecomment-1420043947

   I think we can follow the description of the Java client, i.e. `1:2:3` means the ledger id is 1, entry id is 2, partition index is 3. `1:2:3:4` means the batch index is 4 in addition to `1:2:3`. We can reuse the implementation of the C++ client and we should modify the C++ wrapper becase `send` API returns the `MessageId` in the `_pulsar` module, not `pulsar`. It should be easy to implement, see examples here: https://pybind11.readthedocs.io/en/stable/advanced/classes.html
   
   ```c++
           .def("__repr__", &Vector2::toString);
   ```


-- 
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


[GitHub] [pulsar-client-python] BewareMyPower commented on issue #66: [feature request] Give a human readable description for MessageId

Posted by "BewareMyPower (via GitHub)" <gi...@apache.org>.
BewareMyPower commented on issue #66:
URL: https://github.com/apache/pulsar-client-python/issues/66#issuecomment-1420079946

   In C++ we usually don't provide a `toString` method, instead, a `operator<<` is provided so it can be reused to write an object to standard output, files or strings via `std::ostream`.
   
   https://github.com/apache/pulsar-client-cpp/blob/63c424555cdb1209c82e2f844d7414c1fc399ef8/lib/MessageId.cc#L121
   
   You can see here for how to convert a `MessageId` to `std::string`:
   
   https://github.com/apache/pulsar-client-python/blob/cbd31e75adc592ee16dd1698335f6f34b8fb4844/src/message.cc#L53-L55


-- 
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


[GitHub] [pulsar-client-python] erichare commented on issue #66: [feature request] Give a human readable description for MessageId

Posted by "erichare (via GitHub)" <gi...@apache.org>.
erichare commented on issue #66:
URL: https://github.com/apache/pulsar-client-python/issues/66#issuecomment-1430688825

   Merged in as of today!


-- 
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


[GitHub] [pulsar-client-python] BewareMyPower closed issue #66: [feature request] Give a human readable description for MessageId

Posted by "BewareMyPower (via GitHub)" <gi...@apache.org>.
BewareMyPower closed issue #66: [feature request] Give a human readable description for MessageId
URL: https://github.com/apache/pulsar-client-python/issues/66


-- 
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