[grpc][Gpr_To_Absl_Logging] Migrating from gpr to absl logging GPR_ASSERT (#36327)

[grpc][Gpr_To_Absl_Logging] Migrating from gpr to absl logging

go/gpr_to_absl_logs

Replacing GPR_ASSERT with absl CHECK

GPR_ASSERT http://google3/third_party/grpc/include/grpc/support/log.h?q=symbol%3A%5CbGPR_ASSERT%5Cb%20case%3Ayes

CHECK http://google3/third_party/absl/log/check.h?q=symbol%3A%5CbCHECK%5Cb%20case%3Ayes

<!--

If you know who should review your pull request, please assign it to that
person, otherwise the pull request would get assigned randomly.

If your pull request is for a specific language, please add the appropriate
lang label.

-->

Closes #36327

PiperOrigin-RevId: 623851813
pull/36335/head
Tanvi Jagtap 10 months ago committed by Copybara-Service
parent bff23d9d1b
commit fc09bb43b7
  1. 3
      examples/cpp/helloworld/BUILD
  2. 2
      examples/cpp/helloworld/CMakeLists.txt
  3. 7
      examples/cpp/helloworld/greeter_async_client.cc
  4. 3
      examples/cpp/helloworld/greeter_async_client2.cc
  5. 7
      examples/cpp/helloworld/greeter_async_server.cc
  6. 1
      examples/cpp/interceptors/BUILD
  7. 3
      examples/cpp/interceptors/CMakeLists.txt
  8. 9
      examples/cpp/interceptors/caching_interceptor.h

@ -35,6 +35,7 @@ cc_binary(
"//examples/protos:helloworld_cc_grpc",
"@com_google_absl//absl/flags:flag",
"@com_google_absl//absl/flags:parse",
"@com_google_absl//absl/log:check",
],
)
@ -47,6 +48,7 @@ cc_binary(
"//examples/protos:helloworld_cc_grpc",
"@com_google_absl//absl/flags:flag",
"@com_google_absl//absl/flags:parse",
"@com_google_absl//absl/log:check",
],
)
@ -97,6 +99,7 @@ cc_binary(
"//examples/protos:helloworld_cc_grpc",
"@com_google_absl//absl/flags:flag",
"@com_google_absl//absl/flags:parse",
"@com_google_absl//absl/log:check",
"@com_google_absl//absl/strings:str_format",
],
)

@ -52,6 +52,7 @@ add_library(hw_grpc_proto
${hw_proto_srcs}
${hw_proto_hdrs})
target_link_libraries(hw_grpc_proto
absl::check
${_REFLECTION}
${_GRPC_GRPCPP}
${_PROTOBUF_LIBPROTOBUF})
@ -64,6 +65,7 @@ foreach(_target
add_executable(${_target} "${_target}.cc")
target_link_libraries(${_target}
hw_grpc_proto
absl::check
absl::flags
absl::flags_parse
${_REFLECTION}

@ -22,6 +22,7 @@
#include "absl/flags/flag.h"
#include "absl/flags/parse.h"
#include "absl/log/check.h"
#include <grpc/support/log.h>
#include <grpcpp/grpcpp.h>
@ -81,14 +82,14 @@ class GreeterClient {
// Block until the next result is available in the completion queue "cq".
// The return value of Next should always be checked. This return value
// tells us whether there is any kind of event or the cq_ is shutting down.
GPR_ASSERT(cq.Next(&got_tag, &ok));
CHECK(cq.Next(&got_tag, &ok));
// Verify that the result from "cq" corresponds, by its tag, our previous
// request.
GPR_ASSERT(got_tag == (void*)1);
CHECK_EQ(got_tag, (void*)1);
// ... and that the request was completed successfully. Note that "ok"
// corresponds solely to the request for updates introduced by Finish().
GPR_ASSERT(ok);
CHECK(ok);
// Act upon the status of the actual RPC.
if (status.ok()) {

@ -23,6 +23,7 @@
#include "absl/flags/flag.h"
#include "absl/flags/parse.h"
#include "absl/log/check.h"
#include <grpc/support/log.h>
#include <grpcpp/grpcpp.h>
@ -88,7 +89,7 @@ class GreeterClient {
// Verify that the request was completed successfully. Note that "ok"
// corresponds solely to the request for updates introduced by Finish().
GPR_ASSERT(ok);
CHECK(ok);
if (call->status.ok())
std::cout << "Greeter received: " << call->reply.message() << std::endl;

@ -23,6 +23,7 @@
#include "absl/flags/flag.h"
#include "absl/flags/parse.h"
#include "absl/log/check.h"
#include "absl/strings/str_format.h"
#include <grpc/support/log.h>
@ -116,7 +117,7 @@ class ServerImpl final {
status_ = FINISH;
responder_.Finish(reply_, Status::OK, this);
} else {
GPR_ASSERT(status_ == FINISH);
CHECK_EQ(status_, FINISH);
// Once in the FINISH state, deallocate ourselves (CallData).
delete this;
}
@ -158,8 +159,8 @@ class ServerImpl final {
// memory address of a CallData instance.
// The return value of Next should always be checked. This return value
// tells us whether there is any kind of event or cq_ is shutting down.
GPR_ASSERT(cq_->Next(&tag, &ok));
GPR_ASSERT(ok);
CHECK(cq_->Next(&tag, &ok));
CHECK(ok);
static_cast<CallData*>(tag)->Proceed();
}
}

@ -24,6 +24,7 @@ cc_binary(
deps = [
"//:grpc++",
"//examples/protos:keyvaluestore",
"@com_google_absl//absl/log:check",
],
)

@ -52,6 +52,7 @@ add_library(kvs_grpc_proto
${kvs_proto_srcs}
${kvs_proto_hdrs})
target_link_libraries(kvs_grpc_proto
absl::check
${_REFLECTION}
${_GRPC_GRPCPP}
${_PROTOBUF_LIBPROTOBUF})
@ -59,6 +60,7 @@ target_link_libraries(kvs_grpc_proto
# client
add_executable(client "client.cc" "caching_interceptor.h")
target_link_libraries(client
absl::check
kvs_grpc_proto
${_REFLECTION}
${_GRPC_GRPCPP}
@ -67,6 +69,7 @@ target_link_libraries(client
# server
add_executable(server "server.cc")
target_link_libraries(server
absl::check
kvs_grpc_proto
${_REFLECTION}
${_GRPC_GRPCPP}

@ -18,6 +18,8 @@
#include <map>
#include "absl/log/check.h"
#include <grpcpp/support/client_interceptor.h>
#ifdef BAZEL_BUILD
@ -62,10 +64,9 @@ class CachingInterceptor : public grpc::experimental::Interceptor {
keyvaluestore::Request req_msg;
auto* buffer = methods->GetSerializedSendMessage();
auto copied_buffer = *buffer;
GPR_ASSERT(
grpc::SerializationTraits<keyvaluestore::Request>::Deserialize(
&copied_buffer, &req_msg)
.ok());
CHECK(grpc::SerializationTraits<keyvaluestore::Request>::Deserialize(
&copied_buffer, &req_msg)
.ok());
requested_key = req_msg.key();
}

Loading…
Cancel
Save