LameClient ready for absl::Status (#27319)

* LameClient ready for absl::Status

* Update by review
pull/27359/head
Esun Kim 4 years ago committed by GitHub
parent 0a502d8f2e
commit 7710e94617
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      src/core/ext/filters/client_channel/dynamic_filters.cc
  2. 24
      src/core/lib/surface/lame_client.cc
  3. 2
      src/core/lib/surface/lame_client.h

@ -163,7 +163,7 @@ RefCountedPtr<DynamicFilters> DynamicFilters::Create(
// Channel stack creation failed with requested filters.
// Create with lame filter instead.
grpc_error_handle error = p.second;
grpc_arg error_arg = MakeLameClientErrorArg(error);
grpc_arg error_arg = MakeLameClientErrorArg(&error);
grpc_channel_args* new_args =
grpc_channel_args_copy_and_add(args, &error_arg, 1);
GRPC_ERROR_UNREF(error);

@ -45,9 +45,9 @@ namespace {
struct ChannelData {
explicit ChannelData(grpc_channel_element_args* args)
: state_tracker("lame_channel", GRPC_CHANNEL_SHUTDOWN) {
grpc_error_handle err = grpc_channel_args_find_pointer<grpc_error>(
grpc_error_handle* err = grpc_channel_args_find_pointer<grpc_error_handle>(
args->channel_args, GRPC_ARG_LAME_FILTER_ERROR);
if (err != nullptr) error = GRPC_ERROR_REF(err);
if (err != nullptr) error = GRPC_ERROR_REF(*err);
}
~ChannelData() { GRPC_ERROR_UNREF(error); }
@ -125,12 +125,20 @@ static void lame_destroy_channel_elem(grpc_channel_element* elem) {
// Channel arg vtable for a grpc_error_handle.
void* ErrorCopy(void* p) {
grpc_error_handle error = static_cast<grpc_error_handle>(p);
return GRPC_ERROR_REF(error);
grpc_error_handle* new_error = nullptr;
if (p != nullptr) {
grpc_error_handle* error = static_cast<grpc_error_handle*>(p);
new_error = new grpc_error_handle();
*new_error = GRPC_ERROR_REF(*error);
}
return new_error;
}
void ErrorDestroy(void* p) {
grpc_error_handle error = static_cast<grpc_error_handle>(p);
GRPC_ERROR_UNREF(error);
if (p != nullptr) {
grpc_error_handle* error = static_cast<grpc_error_handle*>(p);
GRPC_ERROR_UNREF(*error);
delete error;
}
}
int ErrorCompare(void* p, void* q) { return GPR_ICMP(p, q); }
const grpc_arg_pointer_vtable kLameFilterErrorArgVtable = {
@ -138,7 +146,7 @@ const grpc_arg_pointer_vtable kLameFilterErrorArgVtable = {
} // namespace
grpc_arg MakeLameClientErrorArg(grpc_error_handle error) {
grpc_arg MakeLameClientErrorArg(grpc_error_handle* error) {
return grpc_channel_arg_pointer_create(
const_cast<char*>(GRPC_ARG_LAME_FILTER_ERROR), error,
&kLameFilterErrorArgVtable);
@ -176,7 +184,7 @@ grpc_channel* grpc_lame_client_channel_create(const char* target,
GRPC_ERROR_INT_GRPC_STATUS, error_code),
GRPC_ERROR_STR_GRPC_MESSAGE,
grpc_slice_from_static_string(error_message));
grpc_arg error_arg = grpc_core::MakeLameClientErrorArg(error);
grpc_arg error_arg = grpc_core::MakeLameClientErrorArg(&error);
grpc_channel_args args = {1, &error_arg};
grpc_channel* channel = grpc_channel_create(
target, &args, GRPC_CLIENT_LAME_CHANNEL, nullptr, nullptr, 0, nullptr);

@ -25,7 +25,7 @@
namespace grpc_core {
// Does NOT take ownership of error.
grpc_arg MakeLameClientErrorArg(grpc_error_handle error);
grpc_arg MakeLameClientErrorArg(grpc_error_handle* error);
} // namespace grpc_core
extern const grpc_channel_filter grpc_lame_filter;

Loading…
Cancel
Save