Skip to content

Commit ff41eb3

Browse files
authored
Depend on grpc-ecosystem/proto-converter (#95)
1 parent 332ba75 commit ff41eb3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+218
-205
lines changed

.bazelrc

+3
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
build --action_env=CC=clang-10
2020
build --action_env=CXX=clang++-10
2121

22+
build --cxxopt=-std=c++14
23+
build --host_cxxopt=-std=c++14
24+
2225
# The ASAN configuration suitable for C++ unit tests.
2326
build:asan --copt=-fsanitize=address
2427
build:asan --linkopt=-fsanitize=address

WORKSPACE

+9-8
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ load(
2424
"io_bazel_rules_docker",
2525
"nlohmannjson_repositories",
2626
"protobuf_repositories",
27+
"protoconverter_repositories",
2728
)
2829

2930
# See
@@ -39,6 +40,8 @@ http_archive(
3940
urls = ["https://github.com/bazelbuild/rules_fuzzing/archive/v0.3.2.zip"],
4041
)
4142

43+
absl_repositories()
44+
4245
load("@rules_fuzzing//fuzzing:repositories.bzl", "rules_fuzzing_dependencies")
4346

4447
rules_fuzzing_dependencies()
@@ -47,10 +50,14 @@ load("@rules_fuzzing//fuzzing:init.bzl", "rules_fuzzing_init")
4750

4851
rules_fuzzing_init()
4952

50-
absl_repositories()
51-
5253
protobuf_repositories()
5354

55+
load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
56+
57+
protobuf_deps()
58+
59+
protoconverter_repositories()
60+
5461
googletest_repositories()
5562

5663
googleapis_repositories()
@@ -79,14 +86,8 @@ load(
7986
_cc_image_repos()
8087
# END io_bazel_rules_docker
8188

82-
load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
83-
84-
protobuf_deps()
85-
8689
load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_proto_toolchains")
8790

88-
rules_proto_dependencies()
89-
9091
rules_proto_toolchains()
9192

9293
load("@com_google_googleapis//:repository_rules.bzl", "switched_rules_by_language")

perf_benchmark/BUILD

+9-6
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ cc_proto_library(
3333

3434
proto_library(
3535
name = "benchmark_proto",
36-
srcs = ["benchmark.proto"],
3736
testonly = 1,
37+
srcs = ["benchmark.proto"],
3838
deps = [
3939
"@com_google_googleapis//google/api:annotations_proto",
4040
"@com_google_protobuf//:struct_proto",
@@ -43,11 +43,11 @@ proto_library(
4343

4444
cc_binary(
4545
name = "benchmark_main",
46+
testonly = 1,
4647
srcs = ["benchmark_main.cc"],
4748
data = [
4849
"benchmark_service.textproto",
4950
],
50-
testonly = 1,
5151
deps = [
5252
"benchmark_cc_proto",
5353
":benchmark_input_stream",
@@ -72,8 +72,8 @@ cc_binary(
7272
# Please make sure if you're building from Debian 11 system as well.
7373
cc_image(
7474
name = "benchmark_main_image",
75-
binary = ":benchmark_main",
7675
testonly = 1,
76+
binary = ":benchmark_main",
7777
)
7878

7979
# Example run command:
@@ -83,19 +83,19 @@ cc_image(
8383
# --define=PUSH_TAG=latest
8484
container_push(
8585
name = "benchmark_main_image_push",
86+
testonly = 1,
8687
format = "Docker",
8788
image = ":benchmark_main_image",
88-
testonly = 1,
8989
registry = "$(PUSH_REGISTRY)",
9090
repository = "$(PUSH_PROJECT)/grpc-httpjson-transcoding-benchmark",
9191
tag = "$(PUSH_TAG)",
9292
)
9393

9494
cc_library(
9595
name = "utils",
96+
testonly = 1,
9697
srcs = ["utils.cc"],
9798
hdrs = ["utils.h"],
98-
testonly = 1,
9999
deps = [
100100
"benchmark_cc_proto",
101101
"//src:type_helper",
@@ -112,11 +112,13 @@ cc_library(
112112

113113
cc_library(
114114
name = "benchmark_input_stream",
115+
testonly = 1,
115116
srcs = ["benchmark_input_stream.cc"],
116117
hdrs = ["benchmark_input_stream.h"],
117-
testonly = 1,
118118
deps = [
119119
"//src:transcoder_input_stream",
120+
"@com_google_absl//absl/log:absl_check",
121+
"@com_google_absl//absl/log:absl_log",
120122
"@com_google_absl//absl/strings",
121123
"@com_google_protobuf//:protobuf",
122124
],
@@ -166,6 +168,7 @@ cc_test(
166168
"//src:response_to_json_translator",
167169
"//src:type_helper",
168170
"@com_github_nlohmann_json//:json",
171+
"@com_google_absl//absl/log:absl_check",
169172
"@com_google_googleapis//google/api:service_cc_proto",
170173
"@com_google_googletest//:gtest_main",
171174
],

perf_benchmark/benchmark_input_stream.cc

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
//
1717

1818
#include "perf_benchmark/benchmark_input_stream.h"
19-
#include "google/protobuf/stubs/logging.h"
19+
#include "absl/log/absl_check.h"
2020

2121
namespace google {
2222
namespace grpc {
@@ -29,7 +29,7 @@ BenchmarkZeroCopyInputStream::BenchmarkZeroCopyInputStream(
2929
msg_(std::move(json_data)),
3030
chunk_size_(msg_.size() / num_checks),
3131
pos_(0) {
32-
GOOGLE_CHECK(num_checks <= msg_.size());
32+
ABSL_CHECK(num_checks <= msg_.size());
3333
}
3434

3535
int64_t BenchmarkZeroCopyInputStream::BytesAvailable() const {
@@ -74,7 +74,7 @@ uint64_t BenchmarkZeroCopyInputStream::TotalBytes() const {
7474
}
7575

7676
void BenchmarkZeroCopyInputStream::BackUp(int count) {
77-
GOOGLE_CHECK(count <= pos_);
77+
ABSL_CHECK(count <= pos_);
7878
pos_ -= count;
7979
finished_ = false;
8080
}

perf_benchmark/benchmark_input_stream.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#define PERF_BENCHMARK_BENCHMARK_INPUT_STREAM_H_
1919

2020
#include "absl/strings/string_view.h"
21-
#include "google/protobuf/stubs/logging.h"
21+
#include "absl/log/absl_log.h"
2222
#include "grpc_transcoding/transcoder_input_stream.h"
2323

2424
namespace google {
@@ -55,7 +55,7 @@ class BenchmarkZeroCopyInputStream : public TranscoderInputStream {
5555
bool Next(const void** data, int* size) override;
5656
void BackUp(int count) override;
5757
bool Skip(int count) override {
58-
GOOGLE_LOG(FATAL) << "Not implemented";
58+
ABSL_LOG(FATAL) << "Not implemented";
5959
return false;
6060
};
6161
int64_t ByteCount() const override;

perf_benchmark/benchmark_input_stream_translator_integration_test.cc

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "perf_benchmark/benchmark_input_stream.h"
1818
#include "absl/strings/escaping.h"
1919
#include "absl/strings/str_format.h"
20+
#include "absl/log/absl_check.h"
2021
#include "google/api/service.pb.h"
2122
#include "google/protobuf/text_format.h"
2223
#include "grpc_transcoding/json_request_translator.h"
@@ -48,7 +49,7 @@ constexpr absl::string_view kServiceConfigTextProtoFile =
4849
// unnecessary heap allocations and create minor performance concerns.
4950
// For a small benchmark script, this is okay.
5051
auto* service = new google::api::Service();
51-
GOOGLE_CHECK_OK(
52+
ABSL_CHECK_OK(
5253
LoadService(std::string(kServiceConfigTextProtoFile), service));
5354

5455
// Create a TypeHelper based on the service config.

perf_benchmark/benchmark_main.cc

+2-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "absl/strings/escaping.h"
2121
#include "absl/strings/str_format.h"
2222
#include "absl/strings/string_view.h"
23+
#include "absl/log/absl_check.h"
2324
#include "google/api/service.pb.h"
2425
#include "google/protobuf/text_format.h"
2526
#include "grpc_transcoding/json_request_translator.h"
@@ -85,7 +86,7 @@ constexpr absl::string_view kMultiStringFieldPrefix = "f";
8586
// unnecessary heap allocations and create minor performance concerns.
8687
// For a small benchmark script, this is okay.
8788
auto* service = new google::api::Service();
88-
GOOGLE_CHECK_OK(
89+
ABSL_CHECK_OK(
8990
LoadService(std::string(kServiceConfigTextProtoFile), service));
9091

9192
// Create a TypeHelper based on the service config.

perf_benchmark/utils.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#include "absl/status/status.h"
2323
#include "absl/strings/string_view.h"
2424
#include "google/api/service.pb.h"
25-
#include "google/protobuf/util/internal/type_info.h"
25+
#include "google/protobuf/util/converter/type_info.h"
2626
#include "perf_benchmark/benchmark.pb.h"
2727
#include "src/include/grpc_transcoding/type_helper.h"
2828

repositories.bzl

+16-21
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,14 @@
1515
################################################################################
1616
#
1717
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
18-
19-
ABSEIL_COMMIT = "99477fa9f1e89a7d8253c8aeee331864710d080c"
20-
ABSEIL_SHA256 = "495e8e1c481018126b2a84bfe36e273907ce282b135e7d161e138e463d295f3d"
18+
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
2119

2220
def absl_repositories(bind = True):
2321
http_archive(
2422
name = "com_google_absl",
25-
strip_prefix = "abseil-cpp-" + ABSEIL_COMMIT,
26-
url = "https://github.com/abseil/abseil-cpp/archive/" + ABSEIL_COMMIT + ".tar.gz",
27-
sha256 = ABSEIL_SHA256,
23+
sha256 = "ea1d31db00eb37e607bfda17ffac09064670ddf05da067944c4766f517876390",
24+
strip_prefix = "abseil-cpp-c2435f8342c2d0ed8101cb43adfd605fdc52dca2", # May 04, 2023.
25+
urls = ["https://github.com/abseil/abseil-cpp/archive/c2435f8342c2d0ed8101cb43adfd605fdc52dca2.zip"],
2826
)
2927

3028
def zlib_repositories(bind = True):
@@ -92,28 +90,17 @@ cc_library(
9290
build_file_content = BUILD,
9391
)
9492

95-
PROTOBUF_COMMIT = "3.16.0" # Mar 04, 2021
96-
PROTOBUF_SHA256 = "7892a35d979304a404400a101c46ce90e85ec9e2a766a86041bb361f626247f5"
97-
98-
RULES_PROTO_SHA = "97d8af4dc474595af3900dd85cb3a29ad28cc313" # Oct 31, 2019
99-
RULES_PROTO_SHA256 = "602e7161d9195e50246177e7c55b2f39950a9cf7366f74ed5f22fd45750cd208"
93+
PROTOBUF_COMMIT = "315ffb5be89460f2857387d20aefc59b76b8bdc3" # May 31, 2023
94+
PROTOBUF_SHA256 = "aa61db6ff113a1c76eac9408144c6e996c5e2d6b2410818fd7f1b0d222a50bf8"
10095

10196
def protobuf_repositories(bind = True):
10297
http_archive(
10398
name = "com_google_protobuf",
10499
strip_prefix = "protobuf-" + PROTOBUF_COMMIT,
105-
url = "https://github.com/google/protobuf/archive/v" + PROTOBUF_COMMIT + ".tar.gz",
106-
sha256 = PROTOBUF_SHA256,
107-
)
108-
109-
http_archive(
110-
name = "rules_proto",
111-
sha256 = RULES_PROTO_SHA256,
112-
strip_prefix = "rules_proto-" + RULES_PROTO_SHA,
113100
urls = [
114-
"https://mirror.bazel.build/github.com/bazelbuild/rules_proto/archive/" + RULES_PROTO_SHA + ".tar.gz",
115-
"https://github.com/bazelbuild/rules_proto/archive/" + RULES_PROTO_SHA + ".tar.gz",
101+
"https://github.com/google/protobuf/archive/" + PROTOBUF_COMMIT + ".tar.gz",
116102
],
103+
sha256 = PROTOBUF_SHA256,
117104
)
118105

119106
GOOGLETEST_COMMIT = "703bd9caab50b139428cea1aaff9974ebee5742e" # v1.10.0: Oct 2, 2019
@@ -194,3 +181,11 @@ def io_bazel_rules_docker(bind = True):
194181
sha256 = RULES_DOCKER_SHA256,
195182
urls = ["https://github.com/bazelbuild/rules_docker/releases/download/v" + RULES_DOCKER_COMMIT + "/rules_docker-v" + RULES_DOCKER_COMMIT + ".tar.gz"],
196183
)
184+
185+
def protoconverter_repositories(bind = True):
186+
http_archive(
187+
name = "com_google_protoconverter",
188+
sha256 = "6081836fa3838ebb1aa15089a5c3e20f877a0244c7a39b92a2000efb40408dcb",
189+
strip_prefix = "proto-converter-d77ff301f48bf2e7a0f8935315e847c1a8e00017",
190+
urls = ["https://github.com/grpc-ecosystem/proto-converter/archive/d77ff301f48bf2e7a0f8935315e847c1a8e00017.zip"],
191+
)

src/BUILD

+4
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ cc_library(
2626
],
2727
deps = [
2828
"@com_google_protobuf//:protobuf",
29+
"@com_google_protoconverter//:all",
2930
],
3031
)
3132

@@ -78,6 +79,7 @@ cc_library(
7879
],
7980
deps = [
8081
":transcoder_input_stream",
82+
"@com_google_absl//absl/status",
8183
"@com_google_protobuf//:protobuf",
8284
],
8385
)
@@ -276,6 +278,7 @@ cc_library(
276278
"@com_google_absl//absl/strings",
277279
"@com_google_absl//absl/synchronization",
278280
"@com_google_protobuf//:protobuf",
281+
"@com_google_protoconverter//:all",
279282
],
280283
)
281284

@@ -292,6 +295,7 @@ cc_library(
292295
],
293296
deps = [
294297
":protobuf",
298+
"@com_google_absl//absl/status",
295299
"@com_google_absl//absl/strings",
296300
"@com_google_absl//absl/strings:str_format",
297301
],

src/include/grpc_transcoding/internal/protobuf_types.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,13 @@
1515
#ifndef GRPC_TRANSCODING_INTERNAL_PROTOBUF_TYPES_H_
1616
#define GRPC_TRANSCODING_INTERNAL_PROTOBUF_TYPES_H_
1717

18-
#include "google/protobuf/stubs/stringpiece.h"
1918

2019
namespace google {
2120
namespace grpc {
2221
namespace transcoding {
2322
namespace internal {
2423

25-
typedef ::google::protobuf::StringPiece string_view;
24+
typedef ::absl::string_view string_view;
2625

2726
} // namespace internal
2827
} // namespace transcoding

src/include/grpc_transcoding/json_request_translator.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#include <memory>
1919

2020
#include "google/protobuf/io/zero_copy_stream.h"
21-
#include "google/protobuf/util/internal/json_stream_parser.h"
21+
#include "google/protobuf/util/converter/json_stream_parser.h"
2222
#include "google/protobuf/util/type_resolver.h"
2323
#include "message_stream.h"
2424
#include "request_message_translator.h"

src/include/grpc_transcoding/message_reader.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717

1818
#include <memory>
1919

20-
#include "google/protobuf/stubs/status.h"
2120
#include "transcoder_input_stream.h"
21+
#include "absl/status/status.h"
2222

2323
namespace google {
2424
namespace grpc {
@@ -92,7 +92,7 @@ class MessageReader {
9292
// is OK before consuming the `grpc_frame`.
9393
MessageAndGrpcFrame NextMessageAndGrpcFrame();
9494

95-
::google::protobuf::util::Status Status() const { return status_; }
95+
absl::Status Status() const { return status_; }
9696

9797
// Returns true if the stream has ended (this is permanent); otherwise returns
9898
// false.
@@ -107,7 +107,7 @@ class MessageReader {
107107
// Are we all done?
108108
bool finished_;
109109
// Status
110-
::google::protobuf::util::Status status_;
110+
absl::Status status_;
111111
// Buffer to store the current delimiter value.
112112
unsigned char delimiter_[kGrpcDelimiterByteSize];
113113

src/include/grpc_transcoding/message_stream.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
#include <string>
2020

2121
#include "google/protobuf/io/zero_copy_stream.h"
22-
#include "google/protobuf/stubs/status.h"
2322
#include "transcoder_input_stream.h"
23+
#include "absl/status/status.h"
2424

2525
namespace google {
2626
namespace grpc {
@@ -70,7 +70,7 @@ class MessageStream {
7070
// false.
7171
virtual bool Finished() const = 0;
7272
// Stream status to report errors
73-
virtual ::google::protobuf::util::Status Status() const = 0;
73+
virtual absl::Status Status() const = 0;
7474
// Virtual destructor
7575
virtual ~MessageStream() {}
7676
// Creates ZeroCopyInputStream implementation based on this stream

0 commit comments

Comments
 (0)