@@ -108,24 +108,40 @@ Topic KafkaHandleBase::get_topic(const string& name, TopicConfiguration config)
108108
109109KafkaHandleBase::OffsetTuple
110110KafkaHandleBase::query_offsets (const TopicPartition& topic_partition) const {
111+ return query_offsets (topic_partition, timeout_ms_);
112+ }
113+
114+ KafkaHandleBase::OffsetTuple
115+ KafkaHandleBase::query_offsets (const TopicPartition& topic_partition,
116+ milliseconds timeout) const {
111117 int64_t low;
112118 int64_t high;
113119 const string& topic = topic_partition.get_topic ();
114120 const int partition = topic_partition.get_partition ();
115- const int timeout = static_cast <int >(timeout_ms_ .count ());
121+ const int timeout_ms = static_cast <int >(timeout .count ());
116122 rd_kafka_resp_err_t result = rd_kafka_query_watermark_offsets (handle_.get (), topic.data (),
117123 partition, &low, &high,
118- timeout );
124+ timeout_ms );
119125 check_error (result);
120126 return make_tuple (low, high);
121127}
122128
123129Metadata KafkaHandleBase::get_metadata (bool all_topics) const {
124- return get_metadata (all_topics, nullptr );
130+ return get_metadata (all_topics, nullptr , timeout_ms_);
131+ }
132+
133+ Metadata KafkaHandleBase::get_metadata (bool all_topics,
134+ milliseconds timeout) const {
135+ return get_metadata (all_topics, nullptr , timeout);
125136}
126137
127138TopicMetadata KafkaHandleBase::get_metadata (const Topic& topic) const {
128- Metadata md = get_metadata (false , topic.get_handle ());
139+ return get_metadata (topic, timeout_ms_);
140+ }
141+
142+ TopicMetadata KafkaHandleBase::get_metadata (const Topic& topic,
143+ milliseconds timeout) const {
144+ Metadata md = get_metadata (false , topic.get_handle (), timeout);
129145 auto topics = md.get_topics ();
130146 if (topics.empty ()) {
131147 throw ElementNotFound (" topic metadata" , topic.get_name ());
@@ -134,29 +150,44 @@ TopicMetadata KafkaHandleBase::get_metadata(const Topic& topic) const {
134150}
135151
136152GroupInformation KafkaHandleBase::get_consumer_group (const string& name) {
137- auto result = fetch_consumer_groups (name.c_str ());
153+ return get_consumer_group (name, timeout_ms_);
154+ }
155+
156+ GroupInformation KafkaHandleBase::get_consumer_group (const string& name,
157+ milliseconds timeout) {
158+ auto result = fetch_consumer_groups (name.c_str (), timeout);
138159 if (result.empty ()) {
139160 throw ElementNotFound (" consumer group information" , name);
140161 }
141162 return move (result[0 ]);
142163}
143164
144165vector<GroupInformation> KafkaHandleBase::get_consumer_groups () {
145- return fetch_consumer_groups (nullptr );
166+ return get_consumer_groups (timeout_ms_);
167+ }
168+
169+ vector<GroupInformation> KafkaHandleBase::get_consumer_groups (milliseconds timeout) {
170+ return fetch_consumer_groups (nullptr , timeout);
146171}
147172
148173TopicPartitionList
149174KafkaHandleBase::get_offsets_for_times (const TopicPartitionsTimestampsMap& queries) const {
175+ return get_offsets_for_times (queries, timeout_ms_);
176+ }
177+
178+ TopicPartitionList
179+ KafkaHandleBase::get_offsets_for_times (const TopicPartitionsTimestampsMap& queries,
180+ milliseconds timeout) const {
150181 TopicPartitionList topic_partitions;
151182 for (const auto & query : queries) {
152183 const TopicPartition& topic_partition = query.first ;
153184 topic_partitions.emplace_back (topic_partition.get_topic (), topic_partition.get_partition (),
154185 query.second .count ());
155186 }
156187 TopicPartitionsListPtr topic_list_handle = convert (topic_partitions);
157- const int timeout = static_cast <int >(timeout_ms_ .count ());
188+ const int timeout_ms = static_cast <int >(timeout .count ());
158189 rd_kafka_resp_err_t result = rd_kafka_offsets_for_times (handle_.get (), topic_list_handle.get (),
159- timeout );
190+ timeout_ms );
160191 check_error (result, topic_list_handle.get ());
161192 return convert (topic_list_handle);
162193}
@@ -193,19 +224,22 @@ Topic KafkaHandleBase::get_topic(const string& name, rd_kafka_topic_conf_t* conf
193224 return Topic (topic);
194225}
195226
196- Metadata KafkaHandleBase::get_metadata (bool all_topics, rd_kafka_topic_t * topic_ptr) const {
227+ Metadata KafkaHandleBase::get_metadata (bool all_topics,
228+ rd_kafka_topic_t * topic_ptr,
229+ milliseconds timeout) const {
197230 const rd_kafka_metadata_t * metadata;
198- const int timeout = static_cast <int >(timeout_ms_ .count ());
231+ const int timeout_ms = static_cast <int >(timeout .count ());
199232 rd_kafka_resp_err_t error = rd_kafka_metadata (get_handle (), !!all_topics,
200- topic_ptr, &metadata, timeout );
233+ topic_ptr, &metadata, timeout_ms );
201234 check_error (error);
202235 return Metadata (metadata);
203236}
204237
205- vector<GroupInformation> KafkaHandleBase::fetch_consumer_groups (const char * name) {
238+ vector<GroupInformation> KafkaHandleBase::fetch_consumer_groups (const char * name,
239+ milliseconds timeout) {
206240 const rd_kafka_group_list* list = nullptr ;
207- const int timeout = static_cast <int >(timeout_ms_ .count ());
208- auto result = rd_kafka_list_groups (get_handle (), name, &list, timeout );
241+ const int timeout_ms = static_cast <int >(timeout .count ());
242+ auto result = rd_kafka_list_groups (get_handle (), name, &list, timeout_ms );
209243 check_error (result);
210244
211245 // Wrap this in a unique_ptr so it gets auto deleted
0 commit comments