Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions include/pulsar/ClientConfiguration.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,19 @@ class PULSAR_PUBLIC ClientConfiguration {
*/
int getOperationTimeoutSeconds() const;

/**
* Set timeout on client operations (subscribe, create producer, close, unsubscribe) in milliseconds.
* Overrides the value set by setOperationTimeoutSeconds if called after it.
*
* @param timeoutMs the timeout in milliseconds after which the operation will be considered as failed
*/
ClientConfiguration& setOperationTimeoutMs(int timeoutMs);

/**
* @return the client operations timeout in milliseconds
*/
int getOperationTimeoutMs() const;

/**
* Set the number of IO threads to be used by the Pulsar client. Default is 1
* thread.
Expand Down
1 change: 1 addition & 0 deletions lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ else ()
set(PULSAR_SOURCES ${PULSAR_SOURCES} ${PROTO_SOURCES})
ADD_CUSTOM_COMMAND(
OUTPUT ${PROTO_SOURCES}
COMMAND ${CMAKE_COMMAND} -E echo "Generating PulsarApi.pb.cc/h with: ${PROTOC_PATH} -I ../proto ../proto/PulsarApi.proto --cpp_out=${LIB_AUTOGEN_DIR}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is not necessary

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but it helps to debug which protoc used for debug.

COMMAND ${PROTOC_PATH} -I ../proto ../proto/PulsarApi.proto --cpp_out=${LIB_AUTOGEN_DIR}
DEPENDS
../proto/PulsarApi.proto
Expand Down
10 changes: 10 additions & 0 deletions lib/ClientConfiguration.cc
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,16 @@ int ClientConfiguration::getOperationTimeoutSeconds() const {
return std::chrono::duration_cast<std::chrono::seconds>(impl_->operationTimeout).count();
}

ClientConfiguration& ClientConfiguration::setOperationTimeoutMs(int timeoutMs) {
impl_->operationTimeout = std::chrono::milliseconds(timeoutMs);
return *this;
}

int ClientConfiguration::getOperationTimeoutMs() const {
return static_cast<int>(
std::chrono::duration_cast<std::chrono::milliseconds>(impl_->operationTimeout).count());
}

ClientConfiguration& ClientConfiguration::setIOThreads(int threads) {
impl_->ioThreads = threads;
return *this;
Expand Down
Loading