zhanglistar opened a new pull request, #543:
URL: https://github.com/apache/pulsar-client-cpp/pull/543
Fixes #<xyz>
<!-- or this PR is one task of an issue -->
Master Issue: #<xyz>
### Motivation
ClientConfiguration only exposes operation timeout in seconds via
`setOperationTimeoutSeconds()` / `getOperationTimeoutSeconds()`. Applications
that need sub-second or precise millisecond timeouts (e.g. 500ms, 1500ms) have
to convert manually and cannot express values that are not whole seconds.
Adding a millisecond-based API allows finer control and avoids conversion in
user code.
### Modifications
- **include/pulsar/ClientConfiguration.h**
- Added `setOperationTimeoutMs(int timeoutMs)` to set client operation
timeout in milliseconds (subscribe, create producer, close, unsubscribe, etc.).
- Added `getOperationTimeoutMs() const` to return the current operation
timeout in milliseconds.
- Documented that calling `setOperationTimeoutMs` after
`setOperationTimeoutSeconds` overrides the previous value (same internal
`operationTimeout` storage).
- **lib/ClientConfiguration.cc**
- Implemented `setOperationTimeoutMs()` by assigning
`std::chrono::milliseconds(timeoutMs)` to the existing
`impl_->operationTimeout` (stored as `std::chrono::nanoseconds`).
- Implemented `getOperationTimeoutMs()` by casting `operationTimeout` to
milliseconds and returning the count.
No new fields; all existing code that reads `operationTimeout` (e.g.
`ClientImpl::getOperationTimeout`, `HandlerBase`, lookup services) continues to
work without change. Backward compatibility is preserved.
### Verifying this change
- [ ] Make sure that the change passes the CI checks.
This change is a trivial rework / code cleanup without any test coverage.
*(Optional: existing tests that use `setOperationTimeoutSeconds` (e.g. in
`ClientTest.cc`, `ConsumerTest.cc`, `BasicEndToEndTest.cc`) continue to pass;
the new ms API uses the same internal value.)*
### Documentation
- [ ] `doc-required` (Your PR needs to update docs and you will update later)
- [x] `doc-not-needed`
(New API is self-documenting via existing header comments; no separate doc
site change required for a single overload-style API.)
- [ ] `doc` (Your PR contains doc changes)
- [ ] `doc-complete` (Docs have been already added)
--
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]