-
Notifications
You must be signed in to change notification settings - Fork 1.1k
custreamz oauth callback for kafka (librdkafka) #9486
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
84 commits
Select commit
Hold shift + click to select a range
5595fda
pass pyobject to c++ library rather than map<std::string, std::string>
jdye64 0cfcfd0
Checkpoint: C++, Cython, and Python compiling working. Callback objec…
jdye64 1b6b19c
moved configuration building and validating logic to its own method
jdye64 9c08aa0
Merge branch 'rapidsai:branch-21.12' into custreamz_oauth
jdye64 25a8b33
Introduce callbacks class where all the possible kafka callbacks can …
jdye64 4af5b05
Refactored class names
jdye64 97f8830
Updated tests to match new function parameters
jdye64 38e52c1
Remove error of leaving previous decleration
jdye64 2401b8b
upgrade librdkafka version for CI
jdye64 64cdf1c
Merge remote-tracking branch 'upstream/branch-21.12' into custreamz_o…
jdye64 69a8639
link python development headers against test
jdye64 4e4ed72
latest version of librdkafka requires that committed offsets be > 0. …
jdye64 98ed97d
updates
jdye64 d1925ab
Make Python3 package REQUIRED in cmake
jdye64 9916e4d
updates per review
jdye64 2499a78
modified to use std::function
jdye64 ec2cab7
added back whitespace that was removed by accident
jdye64 4672922
temporarily update librdkakfa for CI testing
ajschmidt8 6a6e629
updates per review
jdye64 3524f56
merge conflict resolution and upstream branch-21.12 merge
jdye64 981d44d
test fixes
jdye64 269d962
removed python dependency from tests as libcudf brings it in
jdye64 186408d
Merge remote-tracking branch 'upstream/branch-21.12' into custreamz_o…
jdye64 20ecb3f
update custreamz read_gdf() to check type and handle appropriately
jdye64 ac77f2e
modify cmake
jdye64 18aa6f0
merge upstream/branch-21.12
jdye64 3c525a1
updated conda recipe to include python which is needed for the python…
jdye64 1d73af2
removing all doubt
jdye64 3c44432
add numpy to conda recipe build
jdye64 b5c3ffd
updates
jdye64 16bef4c
hopefully resolve conda errors
jdye64 1bbb134
Merge remote-tracking branch 'upstream/branch-21.12' into custreamz_o…
jdye64 fc4a4aa
Merge remote-tracking branch 'upstream/branch-21.12' into custreamz_o…
jdye64 fafc831
review updates
jdye64 43e1aa9
add python to conda recipes since that is needed for python-dev now
jdye64 ecb3ac7
Merge branch 'branch-22.02' into custreamz_oauth
jdye64 099ca27
add numpy to conda recipe for cudf_kafka
jdye64 1d96eef
add numpy to conda recipe for cudf_kafka
jdye64 5ac4736
add numpy to conda recipe for cudf_kafka
jdye64 7932468
add numpy to conda recipe for cudf_kafka
jdye64 9a5b2d9
add numpy to conda recipe for cudf_kafka
jdye64 ab8f6a0
add numpy to conda recipe for cudf_kafka
jdye64 9bbedd4
Debugging setup.py dependency issues
jdye64 b4f9232
Change CUDA version for debugging
jdye64 d1f4fe5
debug conda build for cudf_kafka
jdye64 037b386
debug cudf_kafka conda
jdye64 2c8adce
conda debugging
jdye64 ef5e072
Add numpy include directory
jdye64 72a3c49
Merge remote-tracking branch 'upstream/branch-22.02' into custreamz_o…
jdye64 5d57b1a
Add Python has host and build requirement since libcudf_kafka uses Py…
jdye64 0a3ee3a
Updated conda meta.yml files
jdye64 97897ad
Testing out a theory about python versions
jdye64 0347540
add cmake function for setting up conda environment
jdye64 a137d23
Merge remote-tracking branch 'upstream/branch-22.02' into custreamz_o…
jdye64 e10b1e9
Disable PROJECT_FLASH test
jdye64 0047d64
test manually specifying python version
jdye64 877030f
Merge remote-tracking branch 'upstream/branch-22.02' into custreamz_o…
jdye64 6af1cd1
Re-enable PROJECT_FLASH support
jdye64 25a27ef
use environment version of python
jdye64 a867d1b
fix typo
jdye64 e5d4f59
change version of python
jdye64 2f582bb
libcudf_kafka is not being passed a conda python environment variable
jdye64 33c9cbb
use python instead of PYTHON environment variable
jdye64 0cd3fe9
make versions strings instead of floats
jdye64 86f02c6
removed references in python in cpp
jdye64 c249b5f
introduce wrapper
jdye64 bcfae4a
Refactor to use functools.partial
jdye64 daca522
Remove python find_package command from cmake
jdye64 ac99019
Update test syntax after refactoring
jdye64 cc28000
Remove Python versions from anaconda builds to satisfy Java build pro…
jdye64 7e59211
update conda recipes to get the correct version of python-confluent-k…
jdye64 6c12fd7
Merge remote-tracking branch 'upstream/branch-22.02' into custreamz_o…
jdye64 ac46705
include librdkafka 1.7.0 in Java test gpu CI script
jdye64 47ee207
remove manual librdkafka updates since integration repo is merged and…
jdye64 1e1dc90
add back conda installs for ops test
jdye64 53f5465
clang formatting
jdye64 e0c7048
remove manual librdkafka updates now that gpuci integrations have bee…
jdye64 740a3bd
Merge upstream
jdye64 eba67e2
Fix missed merge conflict
jdye64 f365667
Update cpp/libcudf_kafka/include/cudf_kafka/kafka_callback.hpp
jdye64 5437b84
Update cpp/libcudf_kafka/src/kafka_callback.cpp
jdye64 831b84b
Address reviewers suggestions
jdye64 4087acc
Update source file years and also adjust import for cudf_kafka
jdye64 44eea02
Adjust source file years
jdye64 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| # Copyright (c) 2020, NVIDIA CORPORATION. | ||
| # Copyright (c) 2020-2022, NVIDIA CORPORATION. | ||
|
|
||
| # This assumes the script is executed from the root of the repo directory | ||
| ./build.sh -v cudf_kafka |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| # Copyright (c) 2020, NVIDIA CORPORATION. | ||
| # Copyright (c) 2020-2022, NVIDIA CORPORATION. | ||
|
|
||
| # This assumes the script is executed from the root of the repo directory | ||
| ./build.sh -v custreamz |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| /* | ||
| * Copyright (c) 2021-2022, NVIDIA CORPORATION. | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| #pragma once | ||
|
|
||
| #include <cudf/io/datasource.hpp> | ||
|
|
||
| #include <librdkafka/rdkafkacpp.h> | ||
|
|
||
| #include <map> | ||
| #include <memory> | ||
| #include <string> | ||
|
|
||
| namespace cudf { | ||
| namespace io { | ||
| namespace external { | ||
| namespace kafka { | ||
|
|
||
| /** | ||
| * @brief Python Callback function wrapper type used for Kafka OAuth events | ||
| * | ||
| * The KafkaConsumer calls the `kafka_oauth_callback_wrapper_type` when the existing | ||
| * oauth token is considered expired by the KafkaConsumer. Typically that | ||
| * means this will be invoked a single time when the KafkaConsumer is created | ||
| * to get the initial token and then intermediately as the token becomes | ||
| * expired. | ||
| * | ||
| * The callback function signature is: | ||
| * `std::map<std::string, std::string> kafka_oauth_callback_wrapper_type(void*)` | ||
| * | ||
| * The callback function returns a std::map<std::string, std::string>, | ||
| * where the std::map consists of the Oauth token and its | ||
| * linux epoch expiration time. Generally the token and expiration | ||
| * time is retrieved from an external service by the callback. | ||
| * Ex: [token, token_expiration_in_epoch] | ||
| */ | ||
| using kafka_oauth_callback_wrapper_type = std::map<std::string, std::string> (*)(void*); | ||
| using python_callable_type = void*; | ||
|
|
||
| /** | ||
| * @brief Callback to retrieve OAuth token from external source. Invoked when | ||
| * token refresh is required. | ||
| */ | ||
| class python_oauth_refresh_callback : public RdKafka::OAuthBearerTokenRefreshCb { | ||
| public: | ||
| python_oauth_refresh_callback(kafka_oauth_callback_wrapper_type callback_wrapper, | ||
| python_callable_type python_callable); | ||
|
|
||
| void oauthbearer_token_refresh_cb(RdKafka::Handle* handle, const std::string& oauthbearer_config); | ||
|
jdye64 marked this conversation as resolved.
|
||
|
|
||
| private: | ||
| kafka_oauth_callback_wrapper_type callback_wrapper_; | ||
| python_callable_type python_callable_; | ||
| }; | ||
|
|
||
| } // namespace kafka | ||
| } // namespace external | ||
| } // namespace io | ||
| } // namespace cudf | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| /* | ||
| * Copyright (c) 2021-2022, NVIDIA CORPORATION. | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| #include "cudf_kafka/kafka_callback.hpp" | ||
|
jdye64 marked this conversation as resolved.
|
||
|
|
||
| #include <librdkafka/rdkafkacpp.h> | ||
|
jdye64 marked this conversation as resolved.
|
||
|
|
||
| namespace cudf { | ||
| namespace io { | ||
| namespace external { | ||
| namespace kafka { | ||
|
|
||
| python_oauth_refresh_callback::python_oauth_refresh_callback( | ||
| kafka_oauth_callback_wrapper_type callback_wrapper, python_callable_type python_callable) | ||
| : callback_wrapper_(callback_wrapper), python_callable_(python_callable){}; | ||
|
|
||
| void python_oauth_refresh_callback::oauthbearer_token_refresh_cb( | ||
| RdKafka::Handle* handle, std::string const& oauthbearer_config) | ||
| { | ||
| std::map<std::string, std::string> resp = callback_wrapper_(python_callable_); | ||
|
|
||
| // Build parameters to pass to librdkafka | ||
| std::string token = resp["token"]; | ||
| int64_t token_lifetime_ms = std::stoll(resp["token_expiration_in_epoch"]); | ||
| std::list<std::string> extensions; // currently not supported | ||
| std::string errstr; | ||
| CUDF_EXPECTS( | ||
| RdKafka::ErrorCode::ERR_NO_ERROR == | ||
| handle->oauthbearer_set_token(token, token_lifetime_ms, "kafka", extensions, errstr), | ||
| "Error occurred while setting the oauthbearer token"); | ||
| } | ||
|
|
||
| } // namespace kafka | ||
| } // namespace external | ||
| } // namespace io | ||
| } // namespace cudf | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.