Skip to content

Commit

Permalink
[call-v3] Add some initialization support for the new call architectu…
Browse files Browse the repository at this point in the history
…re (grpc#35301)

Closes grpc#35301

COPYBARA_INTEGRATE_REVIEW=grpc#35301 from ctiller:init-call-review a2022cc
PiperOrigin-RevId: 590982608
  • Loading branch information
ctiller authored and copybara-github committed Dec 14, 2023
1 parent 96ac691 commit def3288
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/core/lib/channel/channel_stack.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <grpc/support/log.h>

#include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/channel/channel_fwd.h"
#include "src/core/lib/channel/channel_stack_trace.h"
#include "src/core/lib/gpr/alloc.h"
#include "src/core/lib/surface/channel_init.h"
Expand Down Expand Up @@ -320,3 +321,19 @@ grpc_channel_stack::MakeServerCallPromise(grpc_core::CallArgs call_args) {
return ServerNext(grpc_channel_stack_element(this, this->count - 1))(
std::move(call_args));
}

void grpc_channel_stack::InitClientCallSpine(
grpc_core::CallSpineInterface* call) {
for (size_t i = 0; i < count; i++) {
auto* elem = grpc_channel_stack_element(this, i);
elem->filter->init_call(elem, call);
}
}

void grpc_channel_stack::InitServerCallSpine(
grpc_core::CallSpineInterface* call) {
for (size_t i = 0; i < count; i++) {
auto* elem = grpc_channel_stack_element(this, count - 1 - i);
elem->filter->init_call(elem, call);
}
}
3 changes: 3 additions & 0 deletions src/core/lib/channel/channel_stack.h
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,9 @@ struct grpc_channel_stack {
MakeClientCallPromise(grpc_core::CallArgs call_args);
grpc_core::ArenaPromise<grpc_core::ServerMetadataHandle>
MakeServerCallPromise(grpc_core::CallArgs call_args);

void InitClientCallSpine(grpc_core::CallSpineInterface* call);
void InitServerCallSpine(grpc_core::CallSpineInterface* call);
};

// A call stack tracks a set of related filters for one call, and guarantees
Expand Down
5 changes: 5 additions & 0 deletions src/core/lib/transport/transport.h
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,11 @@ class CallHandler {
const RefCountedPtr<CallSpine> spine_;
};

struct CallInitiatorAndHandler {
CallInitiator initiator;
CallHandler handler;
};

template <typename CallHalf>
auto OutgoingMessages(CallHalf& h) {
struct Wrapper {
Expand Down

0 comments on commit def3288

Please sign in to comment.