Skip to content

Commit 162da25

Browse files
Add Pulsar support (#1204)
* Add pulsar connector * Add unit tests for PulsarIODataset * Fix lint errors * Add PulsarWriter * Add unit tests for PulsarWriter * Add PulsarResourceBase to reduce repeated code * Start Pulsar service for tests in Github Actions * Fix CI error * Reuse variables * Fix undefined symbol BIO_f_base64 * Fix conflict of test environment between Pulsar and Kafka * Increase timeout to avoid flaky * Update Copyright
1 parent 5e73f46 commit 162da25

File tree

13 files changed

+996
-0
lines changed

13 files changed

+996
-0
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ jobs:
206206
bash -x -e tests/test_azure/start_azure.sh
207207
bash -x -e tests/test_pubsub/pubsub_test.sh
208208
bash -x -e tests/test_aws/aws_test.sh
209+
bash -x -e tests/test_pulsar/pulsar_test.sh
209210
- name: Install ${{ matrix.python }} macOS
210211
run: |
211212
set -x -e
@@ -304,6 +305,7 @@ jobs:
304305
bash -x -e tests/test_azure/start_azure.sh
305306
bash -x -e tests/test_sql/sql_test.sh
306307
bash -x -e tests/test_gcloud/test_gcs.sh gcs-emulator
308+
bash -x -e tests/test_pulsar/pulsar_test.sh
307309
- name: Test Linux
308310
run: |
309311
set -x -e

WORKSPACE

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,9 @@ http_archive(
405405

406406
http_archive(
407407
name = "boringssl",
408+
patch_cmds = [
409+
"""sed -i.bak 's/bio.c",/bio.c","src\\/decrepit\\/bio\\/base64_bio.c",/g' BUILD.generated.bzl""",
410+
],
408411
sha256 = "1188e29000013ed6517168600fc35a010d58c5d321846d6a6dfee74e4c788b45",
409412
strip_prefix = "boringssl-7f634429a04abc48e2eb041c81c5235816c96514",
410413
urls = [
@@ -1063,3 +1066,29 @@ http_archive(
10631066
"https://downloads.apache.org/hadoop/common/hadoop-3.3.0/hadoop-3.3.0-src.tar.gz",
10641067
],
10651068
)
1069+
1070+
http_archive(
1071+
name = "dlfcn-win32",
1072+
build_file = "//third_party:dlfcn-win32.BUILD",
1073+
sha256 = "f18a412e84d8b701e61a78252411fe8c72587f52417c1ef21ca93604de1b9c55",
1074+
strip_prefix = "dlfcn-win32-1.2.0",
1075+
urls = [
1076+
"https://storage.googleapis.com/mirror.tensorflow.org/github.com/dlfcn-win32/dlfcn-win32/archive/v1.2.0.tar.gz",
1077+
"https://github.com/dlfcn-win32/dlfcn-win32/archive/v1.2.0.tar.gz",
1078+
],
1079+
)
1080+
1081+
http_archive(
1082+
name = "pulsar",
1083+
build_file = "//third_party:pulsar.BUILD",
1084+
patch_cmds = [
1085+
"cp pulsar-common/src/main/proto/PulsarApi.proto pulsar-client-cpp/lib",
1086+
"sed -i.bak 's/define PULSAR_DEFINES_H_/define PULSAR_DEFINES_H_\\'$'\\n''#if defined(_MSC_VER)\\'$'\\n''#include <Windows.h>\\'$'\\n''#undef ERROR\\'$'\\n''#endif/g' pulsar-client-cpp/include/pulsar/defines.h",
1087+
"sed -i.bak 's/define LIB_ACKGROUPINGTRACKER_H_/define LIB_ACKGROUPINGTRACKER_H_\\'$'\\n''#include <pulsar\\/defines.h>/g' pulsar-client-cpp/lib/AckGroupingTracker.h",
1088+
],
1089+
sha256 = "08f19ca6d6353751ff0661403b16b71425bf7ada3d8835a38e426ae303b0e385",
1090+
strip_prefix = "pulsar-2.6.1",
1091+
urls = [
1092+
"https://github.com/apache/pulsar/archive/v2.6.1.tar.gz",
1093+
],
1094+
)

tensorflow_io/core/BUILD

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -663,6 +663,22 @@ cc_library(
663663
alwayslink = 1,
664664
)
665665

666+
cc_library(
667+
name = "pulsar_ops",
668+
srcs = [
669+
"kernels/pulsar_kernel.cc",
670+
"ops/pulsar_ops.cc",
671+
],
672+
copts = tf_io_copts(),
673+
linkstatic = True,
674+
deps = [
675+
"@local_config_tf//:libtensorflow_framework",
676+
"@local_config_tf//:tf_header_lib",
677+
"@pulsar",
678+
],
679+
alwayslink = 1,
680+
)
681+
666682
cc_binary(
667683
name = "python/ops/libtensorflow_io.so",
668684
copts = tf_io_copts(),
@@ -684,6 +700,7 @@ cc_binary(
684700
"//tensorflow_io/core:numpy_ops",
685701
"//tensorflow_io/core:parquet_ops",
686702
"//tensorflow_io/core:pcap_ops",
703+
"//tensorflow_io/core:pulsar_ops",
687704
"//tensorflow_io/core:operation_ops",
688705
"//tensorflow_io/core:pubsub_ops",
689706
"//tensorflow_io/core:serialization_ops",

0 commit comments

Comments
 (0)