Skip to content

Commit

Permalink
Automated rollback of commit b455726.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 591089109
  • Loading branch information
gRPC Team Bot authored and copybara-github committed Dec 15, 2023
1 parent f0dcac3 commit a5a25c7
Show file tree
Hide file tree
Showing 26 changed files with 143 additions and 554 deletions.
1 change: 0 additions & 1 deletion BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -1763,7 +1763,6 @@ grpc_cc_library(
"//src/core:lib/security/credentials/plugin/plugin_credentials.cc",
"//src/core:lib/security/security_connector/security_connector.cc",
"//src/core:lib/security/transport/client_auth_filter.cc",
"//src/core:lib/security/transport/legacy_server_auth_filter.cc",
"//src/core:lib/security/transport/secure_endpoint.cc",
"//src/core:lib/security/transport/security_handshaker.cc",
"//src/core:lib/security/transport/server_auth_filter.cc",
Expand Down
3 changes: 0 additions & 3 deletions CMakeLists.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions Makefile

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Package.swift

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion bazel/experiments.bzl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions build_autogenerated.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion config.m4

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion config.w32

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion gRPC-Core.podspec

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion grpc.gemspec

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions grpc.gyp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

141 changes: 40 additions & 101 deletions src/core/lib/channel/promise_based_filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@
#include "src/core/lib/promise/poll.h"
#include "src/core/lib/promise/promise.h"
#include "src/core/lib/promise/race.h"
#include "src/core/lib/promise/try_seq.h"
#include "src/core/lib/resource_quota/arena.h"
#include "src/core/lib/slice/slice_buffer.h"
#include "src/core/lib/surface/call.h"
Expand Down Expand Up @@ -331,88 +330,54 @@ auto MapResult(void (Derived::Call::*fn)(ServerMetadata&), Promise x,
});
}

template <typename Interceptor, typename Derived, typename SfinaeVoid = void>
struct RunCallImpl;

template <typename Derived>
struct RunCallImpl<const NoInterceptor*, Derived> {
static auto Run(CallArgs call_args, NextPromiseFactory next_promise_factory,
void*) {
return next_promise_factory(std::move(call_args));
}
};
inline auto RunCall(const NoInterceptor*, CallArgs call_args,
NextPromiseFactory next_promise_factory, void*) {
return next_promise_factory(std::move(call_args));
}

template <typename Derived>
struct RunCallImpl<void (Derived::Call::*)(ClientMetadata& md), Derived> {
static auto Run(CallArgs call_args, NextPromiseFactory next_promise_factory,
FilterCallData<Derived>* call_data) {
call_data->call.OnClientInitialMetadata(*call_args.client_initial_metadata);
return next_promise_factory(std::move(call_args));
}
};
inline auto RunCall(void (Derived::Call::*fn)(ClientMetadata& md),
CallArgs call_args, NextPromiseFactory next_promise_factory,
FilterCallData<Derived>* call_data) {
GPR_DEBUG_ASSERT(fn == &Derived::Call::OnClientInitialMetadata);
call_data->call.OnClientInitialMetadata(*call_args.client_initial_metadata);
return next_promise_factory(std::move(call_args));
}

template <typename Derived>
struct RunCallImpl<ServerMetadataHandle (Derived::Call::*)(ClientMetadata& md),
Derived> {
static auto Run(CallArgs call_args, NextPromiseFactory next_promise_factory,
FilterCallData<Derived>* call_data)
-> ArenaPromise<ServerMetadataHandle> {
auto return_md = call_data->call.OnClientInitialMetadata(
*call_args.client_initial_metadata);
if (return_md == nullptr) return next_promise_factory(std::move(call_args));
return Immediate(std::move(return_md));
}
};
inline auto RunCall(
ServerMetadataHandle (Derived::Call::*fn)(ClientMetadata& md),
CallArgs call_args, NextPromiseFactory next_promise_factory,
FilterCallData<Derived>* call_data) -> ArenaPromise<ServerMetadataHandle> {
GPR_DEBUG_ASSERT(fn == &Derived::Call::OnClientInitialMetadata);
auto return_md = call_data->call.OnClientInitialMetadata(
*call_args.client_initial_metadata);
if (return_md == nullptr) return next_promise_factory(std::move(call_args));
return Immediate(std::move(return_md));
}

template <typename Derived>
struct RunCallImpl<ServerMetadataHandle (Derived::Call::*)(ClientMetadata& md,
Derived* channel),
Derived> {
static auto Run(CallArgs call_args, NextPromiseFactory next_promise_factory,
FilterCallData<Derived>* call_data)
-> ArenaPromise<ServerMetadataHandle> {
auto return_md = call_data->call.OnClientInitialMetadata(
*call_args.client_initial_metadata, call_data->channel);
if (return_md == nullptr) return next_promise_factory(std::move(call_args));
return Immediate(std::move(return_md));
}
};
inline auto RunCall(ServerMetadataHandle (Derived::Call::*fn)(
ClientMetadata& md, Derived* channel),
CallArgs call_args, NextPromiseFactory next_promise_factory,
FilterCallData<Derived>* call_data)
-> ArenaPromise<ServerMetadataHandle> {
GPR_DEBUG_ASSERT(fn == &Derived::Call::OnClientInitialMetadata);
auto return_md = call_data->call.OnClientInitialMetadata(
*call_args.client_initial_metadata, call_data->channel);
if (return_md == nullptr) return next_promise_factory(std::move(call_args));
return Immediate(std::move(return_md));
}

template <typename Derived>
struct RunCallImpl<
void (Derived::Call::*)(ClientMetadata& md, Derived* channel), Derived> {
static auto Run(CallArgs call_args, NextPromiseFactory next_promise_factory,
FilterCallData<Derived>* call_data) {
call_data->call.OnClientInitialMetadata(*call_args.client_initial_metadata,
call_data->channel);
return next_promise_factory(std::move(call_args));
}
};

template <typename Derived, typename Promise>
struct RunCallImpl<
Promise (Derived::Call::*)(ClientMetadata& md, Derived* channel), Derived,
absl::void_t<decltype(StatusCast<ServerMetadataHandle>(
std::declval<PromiseResult<Promise>>))>> {
static auto Run(CallArgs call_args, NextPromiseFactory next_promise_factory,
FilterCallData<Derived>* call_data) {
ClientMetadata& md_ref = *call_args.client_initial_metadata;
return TrySeq(
call_data->call.OnClientInitialMetadata(md_ref, call_data->channel),
[call_args = std::move(call_args),
next_promise_factory = std::move(next_promise_factory)]() mutable {
return next_promise_factory(std::move(call_args));
});
}
};

template <typename Interceptor, typename Derived>
auto RunCall(Interceptor interceptor, CallArgs call_args,
NextPromiseFactory next_promise_factory,
FilterCallData<Derived>* call_data) {
GPR_DEBUG_ASSERT(interceptor == &Derived::Call::OnClientInitialMetadata);
return RunCallImpl<Interceptor, Derived>::Run(
std::move(call_args), std::move(next_promise_factory), call_data);
inline auto RunCall(void (Derived::Call::*fn)(ClientMetadata& md,
Derived* channel),
CallArgs call_args, NextPromiseFactory next_promise_factory,
FilterCallData<Derived>* call_data) {
GPR_DEBUG_ASSERT(fn == &Derived::Call::OnClientInitialMetadata);
call_data->call.OnClientInitialMetadata(*call_args.client_initial_metadata,
call_data->channel);
return next_promise_factory(std::move(call_args));
}

inline void InterceptClientToServerMessage(const NoInterceptor*, void*,
Expand Down Expand Up @@ -593,30 +558,6 @@ inline void InterceptClientInitialMetadata(
});
}

// Returning a promise that resolves to something that can be cast to
// ServerMetadataHandle also counts
template <typename Promise, typename Derived>
absl::void_t<decltype(StatusCast<ServerMetadataHandle>(
std::declval<PromiseResult<Promise>>))>
InterceptClientInitialMetadata(Promise (Derived::Call::*promise_factory)(
ClientMetadata& md, Derived* channel),
typename Derived::Call* call, Derived* channel,
CallSpineInterface* call_spine) {
GPR_DEBUG_ASSERT(promise_factory == &Derived::Call::OnClientInitialMetadata);
call_spine->client_initial_metadata().receiver.InterceptAndMap(
[call, call_spine, channel](ClientMetadataHandle md) {
ClientMetadata& md_ref = *md;
return Map(call->OnClientInitialMetadata(md_ref, channel),
[md = std::move(md),
call_spine](PromiseResult<Promise> status) mutable
-> absl::optional<ClientMetadataHandle> {
if (IsStatusOk(status)) return std::move(md);
return call_spine->Cancel(
StatusCast<ServerMetadataHandle>(std::move(status)));
});
});
}

template <typename CallArgs>
inline void InterceptServerInitialMetadata(const NoInterceptor*, void*,
const CallArgs&) {}
Expand Down Expand Up @@ -962,8 +903,6 @@ MakeFilterCall(Derived* derived) {
// the filter can return nullptr for success, or a metadata handle for
// failure (in which case the call will be aborted).
// useful for cases where the exact metadata returned needs to be customized.
// It's also acceptable to return a promise that resolves to the
// relevant return type listed above.
// Finally, OnFinalize can be added to intecept call finalization.
// It must have one of the signatures:
// - static const NoInterceptor OnFinalize:
Expand Down
Loading

0 comments on commit a5a25c7

Please sign in to comment.