libcudf  24.02.00
kafka_callback.hpp
1 /*
2  * Copyright (c) 2021-2023, NVIDIA CORPORATION.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #pragma once
17 
18 #include <cudf/io/datasource.hpp>
19 
20 #include <librdkafka/rdkafkacpp.h>
21 
22 #include <map>
23 #include <memory>
24 #include <string>
25 
26 namespace cudf {
27 namespace io {
28 namespace external {
29 namespace kafka {
30 
49 using kafka_oauth_callback_wrapper_type = std::map<std::string, std::string> (*)(void*);
50 using python_callable_type = void*;
51 
56 class python_oauth_refresh_callback : public RdKafka::OAuthBearerTokenRefreshCb {
57  public:
67  python_oauth_refresh_callback(kafka_oauth_callback_wrapper_type callback_wrapper,
68  python_callable_type python_callable);
69 
76  void oauthbearer_token_refresh_cb(RdKafka::Handle* handle, std::string const& oauthbearer_config);
77 
78  private:
79  kafka_oauth_callback_wrapper_type callback_wrapper_;
80  python_callable_type python_callable_;
81 };
82 
83 } // namespace kafka
84 } // namespace external
85 } // namespace io
86 } // namespace cudf
Callback to retrieve OAuth token from external source. Invoked when token refresh is required.
void oauthbearer_token_refresh_cb(RdKafka::Handle *handle, std::string const &oauthbearer_config)
Invoke the Python callback function to get the OAuth token and its expiration time.
python_oauth_refresh_callback(kafka_oauth_callback_wrapper_type callback_wrapper, python_callable_type python_callable)
Construct a new python oauth refresh callback object.
cuDF interfaces
Definition: aggregation.hpp:34