Expose promise-ness to filter proper (#28658)

* Expose promise-ness to filter proper

* Make transports able to export promises too

* Add make promise op to transport
pull/28660/head^2
Craig Tiller 3 years ago committed by GitHub
parent 9454ab0912
commit 17c6a486cd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      src/core/ext/filters/client_channel/client_channel.cc
  2. 1
      src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc
  3. 1
      src/core/ext/filters/client_channel/retry_filter.cc
  4. 1
      src/core/ext/filters/client_channel/service_config_channel_arg_filter.cc
  5. 1
      src/core/ext/filters/client_idle/client_idle_filter.cc
  6. 2
      src/core/ext/filters/deadline/deadline_filter.cc
  7. 1
      src/core/ext/filters/fault_injection/fault_injection_filter.cc
  8. 1
      src/core/ext/filters/http/client/http_client_filter.cc
  9. 1
      src/core/ext/filters/http/message_compress/message_compress_filter.cc
  10. 1
      src/core/ext/filters/http/message_compress/message_decompress_filter.cc
  11. 1
      src/core/ext/filters/http/server/http_server_filter.cc
  12. 1
      src/core/ext/filters/max_age/max_age_filter.cc
  13. 1
      src/core/ext/filters/message_size/message_size_filter.cc
  14. 1
      src/core/ext/filters/rbac/rbac_filter.cc
  15. 1
      src/core/ext/filters/server_config_selector/server_config_selector_filter.cc
  16. 1
      src/core/ext/transport/binder/transport/binder_transport.cc
  17. 1
      src/core/ext/transport/chttp2/transport/chttp2_transport.cc
  18. 1
      src/core/ext/transport/cronet/transport/cronet_transport.cc
  19. 8
      src/core/ext/transport/inproc/inproc_transport.cc
  20. 16
      src/core/lib/channel/channel_stack.h
  21. 1
      src/core/lib/channel/connected_channel.cc
  22. 60
      src/core/lib/channel/promise_based_filter.h
  23. 1
      src/core/lib/security/authorization/sdk_server_authz_filter.cc
  24. 1
      src/core/lib/security/transport/client_auth_filter.cc
  25. 1
      src/core/lib/security/transport/server_auth_filter.cc
  26. 1
      src/core/lib/surface/lame_client.cc
  27. 1
      src/core/lib/surface/server.cc
  28. 65
      src/core/lib/transport/transport.h
  29. 13
      src/core/lib/transport/transport_impl.h
  30. 1
      src/cpp/common/channel_filter.h
  31. 2
      test/core/channel/channel_stack_builder_test.cc
  32. 1
      test/core/channel/channel_stack_test.cc
  33. 1
      test/core/end2end/tests/filter_causes_close.cc
  34. 1
      test/core/end2end/tests/filter_context.cc
  35. 1
      test/core/end2end/tests/filter_init_fails.cc
  36. 2
      test/core/end2end/tests/filter_latency.cc
  37. 2
      test/core/end2end/tests/filter_status_code.cc
  38. 1
      test/core/end2end/tests/retry_cancel_with_multiple_send_batches.cc
  39. 1
      test/core/end2end/tests/retry_recv_trailing_metadata_error.cc
  40. 1
      test/core/end2end/tests/retry_send_op_fails.cc
  41. 16
      test/core/xds/xds_channel_stack_modifier_test.cc
  42. 49
      test/cpp/microbenchmarks/bm_call_create.cc

@ -233,6 +233,7 @@ class ClientChannel::CallData {
const grpc_channel_filter ClientChannel::kFilterVtable = {
ClientChannel::CallData::StartTransportStreamOpBatch,
nullptr,
ClientChannel::StartTransportOp,
sizeof(ClientChannel::CallData),
ClientChannel::CallData::Init,
@ -383,6 +384,7 @@ class DynamicTerminationFilter::CallData {
const grpc_channel_filter DynamicTerminationFilter::kFilterVtable = {
DynamicTerminationFilter::CallData::StartTransportStreamOpBatch,
nullptr,
DynamicTerminationFilter::StartTransportOp,
sizeof(DynamicTerminationFilter::CallData),
DynamicTerminationFilter::CallData::Init,

@ -132,6 +132,7 @@ static void clr_start_transport_stream_op_batch(
const grpc_channel_filter grpc_client_load_reporting_filter = {
clr_start_transport_stream_op_batch,
nullptr,
grpc_channel_next_op,
sizeof(call_data),
clr_init_call_elem,

@ -2541,6 +2541,7 @@ void RetryFilter::CallData::OnRetryTimerLocked(void* arg,
const grpc_channel_filter kRetryFilterVtable = {
RetryFilter::CallData::StartTransportStreamOpBatch,
nullptr,
RetryFilter::StartTransportOp,
sizeof(RetryFilter::CallData),
RetryFilter::CallData::Init,

@ -123,6 +123,7 @@ void ServiceConfigChannelArgDestroyChannelElem(grpc_channel_element* elem) {
const grpc_channel_filter ServiceConfigChannelArgFilter = {
grpc_call_next_op,
nullptr,
grpc_channel_next_op,
sizeof(ServiceConfigChannelArgCallData),
ServiceConfigChannelArgInitCallElem,

@ -233,6 +233,7 @@ void CallData::Destroy(grpc_call_element* elem,
const grpc_channel_filter grpc_client_idle_filter = {
grpc_call_next_op,
nullptr,
ChannelData::StartTransportOp,
sizeof(CallData),
CallData::Init,

@ -338,6 +338,7 @@ static void deadline_server_start_transport_stream_op_batch(
const grpc_channel_filter grpc_client_deadline_filter = {
deadline_client_start_transport_stream_op_batch,
nullptr,
grpc_channel_next_op,
sizeof(base_call_data),
deadline_init_call_elem,
@ -352,6 +353,7 @@ const grpc_channel_filter grpc_client_deadline_filter = {
const grpc_channel_filter grpc_server_deadline_filter = {
deadline_server_start_transport_stream_op_batch,
nullptr,
grpc_channel_next_op,
sizeof(server_call_data),
deadline_init_call_elem,

@ -471,6 +471,7 @@ void CallData::HijackedRecvTrailingMetadataReady(void* arg,
extern const grpc_channel_filter FaultInjectionFilterVtable = {
CallData::StartTransportStreamOpBatch,
nullptr,
grpc_channel_next_op,
sizeof(CallData),
CallData::Init,

@ -505,6 +505,7 @@ static void http_client_destroy_channel_elem(grpc_channel_element* elem) {
const grpc_channel_filter grpc_http_client_filter = {
http_client_start_transport_stream_op_batch,
nullptr,
grpc_channel_next_op,
sizeof(call_data),
http_client_init_call_elem,

@ -443,6 +443,7 @@ void CompressDestroyChannelElem(grpc_channel_element* elem) {
const grpc_channel_filter grpc_message_compress_filter = {
CompressStartTransportStreamOpBatch,
nullptr,
grpc_channel_next_op,
sizeof(CallData),
CompressInitCallElem,

@ -365,6 +365,7 @@ void DecompressDestroyChannelElem(grpc_channel_element* elem) {
const grpc_channel_filter MessageDecompressFilter = {
DecompressStartTransportStreamOpBatch,
nullptr,
grpc_channel_next_op,
sizeof(CallData),
DecompressInitCallElem,

@ -423,6 +423,7 @@ static void hs_destroy_channel_elem(grpc_channel_element* /*elem*/) {}
const grpc_channel_filter grpc_http_server_filter = {
hs_start_transport_stream_op_batch,
nullptr,
grpc_channel_next_op,
sizeof(call_data),
hs_init_call_elem,

@ -523,6 +523,7 @@ static void max_age_destroy_channel_elem(grpc_channel_element* elem) {
const grpc_channel_filter grpc_max_age_filter = {
grpc_call_next_op,
nullptr,
grpc_channel_next_op,
0, /* sizeof_call_data */
max_age_init_call_elem,

@ -330,6 +330,7 @@ static void message_size_destroy_channel_elem(grpc_channel_element* elem) {
const grpc_channel_filter grpc_message_size_filter = {
message_size_start_transport_stream_op_batch,
nullptr,
grpc_channel_next_op,
sizeof(call_data),
message_size_init_call_elem,

@ -109,6 +109,7 @@ void RbacFilter::CallData::RecvInitialMetadataReady(void* user_data,
const grpc_channel_filter RbacFilter::kFilterVtable = {
RbacFilter::CallData::StartTransportStreamOpBatch,
nullptr,
grpc_channel_next_op,
sizeof(RbacFilter::CallData),
RbacFilter::CallData::Init,

@ -255,6 +255,7 @@ void CallData::MaybeResumeRecvTrailingMetadataReady() {
const grpc_channel_filter kServerConfigSelectorFilter = {
CallData::StartTransportStreamOpBatch,
nullptr,
grpc_channel_next_op,
sizeof(CallData),
CallData::Init,

@ -689,6 +689,7 @@ static grpc_endpoint* get_endpoint(grpc_transport*) {
static const grpc_transport_vtable vtable = {sizeof(grpc_binder_stream),
"binder",
init_stream,
nullptr,
set_pollset,
set_pollset_set,
perform_stream_op,

@ -3161,6 +3161,7 @@ static grpc_endpoint* chttp2_get_endpoint(grpc_transport* t) {
static const grpc_transport_vtable vtable = {sizeof(grpc_chttp2_stream),
"chttp2",
init_stream,
nullptr,
set_pollset,
set_pollset_set,
perform_stream_op,

@ -1483,6 +1483,7 @@ static const grpc_transport_vtable grpc_cronet_vtable = {
sizeof(stream_obj),
"cronet_http",
init_stream,
nullptr,
set_pollset_do_nothing,
set_pollset_set_do_nothing,
perform_stream_op,

@ -1212,9 +1212,11 @@ void set_pollset_set(grpc_transport* /*gt*/, grpc_stream* /*gs*/,
grpc_endpoint* get_endpoint(grpc_transport* /*t*/) { return nullptr; }
const grpc_transport_vtable inproc_vtable = {
sizeof(inproc_stream), "inproc", init_stream,
set_pollset, set_pollset_set, perform_stream_op,
perform_transport_op, destroy_stream, destroy_transport,
sizeof(inproc_stream), "inproc",
init_stream, nullptr,
set_pollset, set_pollset_set,
perform_stream_op, perform_transport_op,
destroy_stream, destroy_transport,
get_endpoint};
/*******************************************************************************

@ -48,6 +48,8 @@
#include <stddef.h>
#include <functional>
#include <grpc/grpc.h>
#include <grpc/support/log.h>
#include <grpc/support/time.h>
@ -57,6 +59,7 @@
#include "src/core/lib/iomgr/call_combiner.h"
#include "src/core/lib/iomgr/polling_entity.h"
#include "src/core/lib/resource_quota/arena.h"
#include "src/core/lib/transport/metadata_batch.h"
#include "src/core/lib/transport/transport.h"
typedef struct grpc_channel_element grpc_channel_element;
@ -109,6 +112,19 @@ struct grpc_channel_filter {
See grpc_call_next_op on how to call the next element in the stack */
void (*start_transport_stream_op_batch)(grpc_call_element* elem,
grpc_transport_stream_op_batch* op);
/* Create a promise to execute one call.
If this is non-null, it may be used in preference to
start_transport_stream_op_batch.
If this is used in preference to start_transport_stream_op_batch, the
following can be omitted also:
- calling init_call_elem, destroy_call_elem, set_pollset_or_pollset_set
- allocation of memory for call data
There is an on-going migration to move all filters to providing this, and
then to drop start_transport_stream_op_batch. */
grpc_core::ArenaPromise<grpc_core::TrailingMetadata> (*make_call_promise)(
grpc_channel_element* elem,
grpc_core::ClientInitialMetadata initial_metadata,
grpc_core::NextPromiseFactory next_promise_factory);
/* Called to handle channel level operations - e.g. new calls, or transport
closure.
See grpc_channel_next_op on how to call the next element in the stack */

@ -203,6 +203,7 @@ static void connected_channel_get_channel_info(
const grpc_channel_filter grpc_connected_filter = {
connected_channel_start_transport_stream_op_batch,
nullptr,
connected_channel_start_transport_op,
sizeof(call_data),
connected_channel_init_call_elem,

@ -33,59 +33,6 @@
namespace grpc_core {
namespace promise_filter_detail {
class BaseCallData;
};
// Small unowned "handle" type to ensure one accessor at a time to metadata.
// The focus here is to get promises to use the syntax we'd like - we'll
// probably substitute some other smart pointer later.
template <typename T>
class MetadataHandle {
public:
MetadataHandle() = default;
MetadataHandle(const MetadataHandle&) = delete;
MetadataHandle& operator=(const MetadataHandle&) = delete;
MetadataHandle(MetadataHandle&& other) noexcept : handle_(other.handle_) {
other.handle_ = nullptr;
}
MetadataHandle& operator=(MetadataHandle&& other) noexcept {
handle_ = other.handle_;
other.handle_ = nullptr;
return *this;
}
T* operator->() const { return handle_; }
bool has_value() const { return handle_ != nullptr; }
static MetadataHandle TestOnlyWrap(T* p) { return MetadataHandle(p); }
private:
friend class promise_filter_detail::BaseCallData;
explicit MetadataHandle(T* handle) : handle_(handle) {}
T* Unwrap() {
T* result = handle_;
handle_ = nullptr;
return result;
}
T* handle_ = nullptr;
};
// Trailing metadata type
// TODO(ctiller): This should be a bespoke instance of MetadataMap<>
using TrailingMetadata = MetadataHandle<grpc_metadata_batch>;
// Client initial metadata type
// TODO(ctiller): This should be a bespoke instance of MetadataMap<>
using ClientInitialMetadata = MetadataHandle<grpc_metadata_batch>;
using NextPromiseFactory =
std::function<ArenaPromise<TrailingMetadata>(ClientInitialMetadata)>;
namespace promise_filter_detail {
// Call data shared between all implementations of promise-based filters.
@ -456,6 +403,13 @@ grpc_channel_filter MakePromiseBasedFilter() {
[](grpc_call_element* elem, grpc_transport_stream_op_batch* batch) {
static_cast<CallData*>(elem->call_data)->StartBatch(batch);
},
// make_call_promise
[](grpc_channel_element* elem, ClientInitialMetadata initial_metadata,
NextPromiseFactory next_promise_factory) {
return static_cast<ChannelFilter*>(elem->channel_data)
->MakeCallPromise(std::move(initial_metadata),
std::move(next_promise_factory));
},
// start_transport_op - for now unsupported
grpc_channel_next_op,
// sizeof_call_data

@ -159,6 +159,7 @@ void SdkServerAuthzFilter::CallData::RecvInitialMetadataReady(
const grpc_channel_filter SdkServerAuthzFilter::kFilterVtable = {
SdkServerAuthzFilter::CallData::StartTransportStreamOpBatch,
nullptr,
grpc_channel_next_op,
sizeof(SdkServerAuthzFilter::CallData),
SdkServerAuthzFilter::CallData::Init,

@ -481,6 +481,7 @@ static void client_auth_destroy_channel_elem(grpc_channel_element* elem) {
const grpc_channel_filter grpc_client_auth_filter = {
client_auth_start_transport_stream_op_batch,
nullptr,
grpc_channel_next_op,
sizeof(call_data),
client_auth_init_call_elem,

@ -324,6 +324,7 @@ static void server_auth_destroy_channel_elem(grpc_channel_element* elem) {
const grpc_channel_filter grpc_server_auth_filter = {
server_auth_start_transport_stream_op_batch,
nullptr,
grpc_channel_next_op,
sizeof(call_data),
server_auth_init_call_elem,

@ -156,6 +156,7 @@ grpc_arg MakeLameClientErrorArg(grpc_error_handle* error) {
const grpc_channel_filter grpc_lame_filter = {
grpc_core::lame_start_transport_stream_op_batch,
nullptr,
grpc_core::lame_start_transport_op,
sizeof(grpc_core::CallData),
grpc_core::lame_init_call_elem,

@ -498,6 +498,7 @@ class ChannelBroadcaster {
const grpc_channel_filter Server::kServerTopFilter = {
Server::CallData::StartTransportStreamOpBatch,
nullptr,
grpc_channel_next_op,
sizeof(Server::CallData),
Server::CallData::InitCallElement,

@ -30,6 +30,7 @@
#include "src/core/lib/iomgr/polling_entity.h"
#include "src/core/lib/iomgr/pollset.h"
#include "src/core/lib/iomgr/pollset_set.h"
#include "src/core/lib/promise/arena_promise.h"
#include "src/core/lib/resource_quota/arena.h"
#include "src/core/lib/slice/slice_internal.h"
#include "src/core/lib/transport/byte_stream.h"
@ -42,6 +43,62 @@
#define GRPC_PROTOCOL_VERSION_MIN_MAJOR 2
#define GRPC_PROTOCOL_VERSION_MIN_MINOR 1
namespace grpc_core {
// TODO(ctiller): eliminate once MetadataHandle is constructable directly.
namespace promise_filter_detail {
class BaseCallData;
}
// Small unowned "handle" type to ensure one accessor at a time to metadata.
// The focus here is to get promises to use the syntax we'd like - we'll
// probably substitute some other smart pointer later.
template <typename T>
class MetadataHandle {
public:
MetadataHandle() = default;
MetadataHandle(const MetadataHandle&) = delete;
MetadataHandle& operator=(const MetadataHandle&) = delete;
MetadataHandle(MetadataHandle&& other) noexcept : handle_(other.handle_) {
other.handle_ = nullptr;
}
MetadataHandle& operator=(MetadataHandle&& other) noexcept {
handle_ = other.handle_;
other.handle_ = nullptr;
return *this;
}
T* operator->() const { return handle_; }
bool has_value() const { return handle_ != nullptr; }
static MetadataHandle TestOnlyWrap(T* p) { return MetadataHandle(p); }
private:
friend class promise_filter_detail::BaseCallData;
explicit MetadataHandle(T* handle) : handle_(handle) {}
T* Unwrap() {
T* result = handle_;
handle_ = nullptr;
return result;
}
T* handle_ = nullptr;
};
// Trailing metadata type
// TODO(ctiller): This should be a bespoke instance of MetadataMap<>
using TrailingMetadata = MetadataHandle<grpc_metadata_batch>;
// Client initial metadata type
// TODO(ctiller): This should be a bespoke instance of MetadataMap<>
using ClientInitialMetadata = MetadataHandle<grpc_metadata_batch>;
using NextPromiseFactory =
std::function<ArenaPromise<TrailingMetadata>(ClientInitialMetadata)>;
} // namespace grpc_core
/* forward declarations */
typedef struct grpc_transport grpc_transport;
@ -353,6 +410,14 @@ typedef struct grpc_transport_op {
void (*set_accept_stream_fn)(void* user_data, grpc_transport* transport,
const void* server_data) = nullptr;
void* set_accept_stream_user_data = nullptr;
/** set the callback for accepting new streams based upon promises;
this is a permanent callback, unlike the other one-shot closures.
If true, the callback is set to set_make_promise_fn, with its
user_data argument set to set_make_promise_data */
bool set_make_promise = false;
void (*set_make_promise_fn)(void* user_data, grpc_transport* transport,
const void* server_data) = nullptr;
void* set_make_promise_user_data = nullptr;
/** add this transport to a pollset */
grpc_pollset* bind_pollset = nullptr;
/** add this transport to a pollset_set */

@ -36,6 +36,19 @@ typedef struct grpc_transport_vtable {
grpc_stream_refcount* refcount, const void* server_data,
grpc_core::Arena* arena);
/* Create a promise to execute one client call.
If this is non-null, it may be used in preference to
perform_stream_op.
If this is used in preference to perform_stream_op, the
following can be omitted also:
- calling init_stream, destroy_stream, set_pollset, set_pollset_set
- allocation of memory for call data (sizeof_stream may be ignored)
There is an on-going migration to move all filters to providing this, and
then to drop perform_stream_op. */
grpc_core::ArenaPromise<grpc_core::TrailingMetadata> (*make_call_promise)(
grpc_transport* self, grpc_core::ClientInitialMetadata initial_metadata,
grpc_core::NextPromiseFactory next_promise_factory);
/* implementation of grpc_transport_set_pollset */
void (*set_pollset)(grpc_transport* self, grpc_stream* stream,
grpc_pollset* pollset);

@ -328,6 +328,7 @@ void RegisterChannelFilter(
using FilterType = internal::ChannelFilter<ChannelDataType, CallDataType>;
static const grpc_channel_filter filter = {
FilterType::StartTransportStreamOpBatch,
nullptr,
FilterType::StartTransportOp,
FilterType::call_data_size,
FilterType::InitCallElement,

@ -75,6 +75,7 @@ TEST(ChannelStackBuilderTest, ReplaceFilter) {
const grpc_channel_filter replacement_filter = {
grpc_call_next_op,
nullptr,
grpc_channel_next_op,
0,
CallInitFunc,
@ -88,6 +89,7 @@ const grpc_channel_filter replacement_filter = {
const grpc_channel_filter original_filter = {
grpc_call_next_op,
nullptr,
grpc_channel_next_op,
0,
CallInitFunc,

@ -77,6 +77,7 @@ static void free_call(void* arg, grpc_error_handle /*error*/) {
static void test_create_channel_stack(void) {
const grpc_channel_filter filter = {
call_func,
nullptr,
channel_func,
sizeof(int),
call_init_func,

@ -235,6 +235,7 @@ static void destroy_channel_elem(grpc_channel_element* /*elem*/) {}
static const grpc_channel_filter test_filter = {
start_transport_stream_op_batch,
nullptr,
grpc_channel_next_op,
sizeof(call_data),
init_call_elem,

@ -258,6 +258,7 @@ static void destroy_channel_elem(grpc_channel_element* /*elem*/) {}
static const grpc_channel_filter test_filter = {
start_transport_stream_op_batch,
nullptr,
grpc_channel_next_op,
sizeof(call_data),
init_call_elem,

@ -442,6 +442,7 @@ static void destroy_channel_elem(grpc_channel_element* /*elem*/) {}
static const grpc_channel_filter test_filter = {
grpc_call_next_op,
nullptr,
grpc_channel_next_op,
0,
init_call_elem,

@ -276,6 +276,7 @@ static void destroy_channel_elem(grpc_channel_element* /*elem*/) {}
static const grpc_channel_filter test_client_filter = {
grpc_call_next_op,
nullptr,
grpc_channel_next_op,
0,
init_call_elem,
@ -289,6 +290,7 @@ static const grpc_channel_filter test_client_filter = {
static const grpc_channel_filter test_server_filter = {
grpc_call_next_op,
nullptr,
grpc_channel_next_op,
0,
init_call_elem,

@ -323,6 +323,7 @@ static void destroy_channel_elem(grpc_channel_element* /*elem*/) {}
static const grpc_channel_filter test_client_filter = {
grpc_call_next_op,
nullptr,
grpc_channel_next_op,
sizeof(final_status_data),
init_call_elem,
@ -336,6 +337,7 @@ static const grpc_channel_filter test_client_filter = {
static const grpc_channel_filter test_server_filter = {
server_start_transport_stream_op_batch,
nullptr,
grpc_channel_next_op,
sizeof(final_status_data),
init_call_elem,

@ -293,6 +293,7 @@ class FailSendOpsFilter {
grpc_channel_filter FailSendOpsFilter::kFilterVtable = {
CallData::StartTransportStreamOpBatch,
nullptr,
grpc_channel_next_op,
sizeof(CallData),
CallData::Init,

@ -325,6 +325,7 @@ class InjectStatusFilter {
grpc_channel_filter InjectStatusFilter::kFilterVtable = {
CallData::StartTransportStreamOpBatch,
nullptr,
grpc_channel_next_op,
sizeof(CallData),
CallData::Init,

@ -344,6 +344,7 @@ class FailFirstSendOpFilter {
grpc_channel_filter FailFirstSendOpFilter::kFilterVtable = {
CallData::StartTransportStreamOpBatch,
nullptr,
grpc_channel_next_op,
sizeof(CallData),
CallData::Init,

@ -69,11 +69,11 @@ TEST(XdsChannelStackModifierTest, XdsHttpFiltersInsertion) {
grpc_init();
// Add 2 test filters to XdsChannelStackModifier
const grpc_channel_filter test_filter_1 = {
nullptr, nullptr, 0, nullptr, nullptr, nullptr,
0, nullptr, nullptr, nullptr, kTestFilter1};
nullptr, nullptr, nullptr, 0, nullptr, nullptr,
nullptr, 0, nullptr, nullptr, nullptr, kTestFilter1};
const grpc_channel_filter test_filter_2 = {
nullptr, nullptr, 0, nullptr, nullptr, nullptr,
0, nullptr, nullptr, nullptr, kTestFilter2};
nullptr, nullptr, nullptr, 0, nullptr, nullptr,
nullptr, 0, nullptr, nullptr, nullptr, kTestFilter2};
auto channel_stack_modifier = MakeRefCounted<XdsChannelStackModifier>(
std::vector<const grpc_channel_filter*>{&test_filter_1, &test_filter_2});
grpc_arg arg = channel_stack_modifier->MakeChannelArg();
@ -114,11 +114,11 @@ TEST(XdsChannelStackModifierTest, XdsHttpFiltersInsertionAfterCensus) {
grpc_init();
// Add 2 test filters to XdsChannelStackModifier
const grpc_channel_filter test_filter_1 = {
nullptr, nullptr, 0, nullptr, nullptr, nullptr,
0, nullptr, nullptr, nullptr, kTestFilter1};
nullptr, nullptr, nullptr, 0, nullptr, nullptr,
nullptr, 0, nullptr, nullptr, nullptr, kTestFilter1};
const grpc_channel_filter test_filter_2 = {
nullptr, nullptr, 0, nullptr, nullptr, nullptr,
0, nullptr, nullptr, nullptr, kTestFilter2};
nullptr, nullptr, nullptr, 0, nullptr, nullptr,
nullptr, 0, nullptr, nullptr, nullptr, kTestFilter2};
auto channel_stack_modifier = MakeRefCounted<XdsChannelStackModifier>(
std::vector<const grpc_channel_filter*>{&test_filter_1, &test_filter_2});
grpc_arg arg = channel_stack_modifier->MakeChannelArg();

@ -384,17 +384,13 @@ void DestroyChannelElem(grpc_channel_element* /*elem*/) {}
void GetChannelInfo(grpc_channel_element* /*elem*/,
const grpc_channel_info* /*channel_info*/) {}
static const grpc_channel_filter phony_filter = {StartTransportStreamOp,
StartTransportOp,
0,
InitCallElem,
SetPollsetOrPollsetSet,
DestroyCallElem,
0,
InitChannelElem,
DestroyChannelElem,
GetChannelInfo,
"phony_filter"};
static const grpc_channel_filter phony_filter = {
StartTransportStreamOp, nullptr,
StartTransportOp, 0,
InitCallElem, SetPollsetOrPollsetSet,
DestroyCallElem, 0,
InitChannelElem, DestroyChannelElem,
GetChannelInfo, "phony_filter"};
} // namespace phony_filter
@ -441,10 +437,16 @@ void Destroy(grpc_transport* /*self*/) {}
/* implementation of grpc_transport_get_endpoint */
grpc_endpoint* GetEndpoint(grpc_transport* /*self*/) { return nullptr; }
static const grpc_transport_vtable phony_transport_vtable = {
0, "phony_http2", InitStream,
SetPollset, SetPollsetSet, PerformStreamOp,
PerformOp, DestroyStream, Destroy,
static const grpc_transport_vtable phony_transport_vtable = {0,
"phony_http2",
InitStream,
nullptr,
SetPollset,
SetPollsetSet,
PerformStreamOp,
PerformOp,
DestroyStream,
Destroy,
GetEndpoint};
static grpc_transport phony_transport = {&phony_transport_vtable};
@ -682,17 +684,12 @@ void GetChannelInfo(grpc_channel_element* /*elem*/,
const grpc_channel_info* /*channel_info*/) {}
static const grpc_channel_filter isolated_call_filter = {
StartTransportStreamOp,
StartTransportOp,
sizeof(call_data),
InitCallElem,
SetPollsetOrPollsetSet,
DestroyCallElem,
0,
InitChannelElem,
DestroyChannelElem,
GetChannelInfo,
"isolated_call_filter"};
StartTransportStreamOp, nullptr,
StartTransportOp, sizeof(call_data),
InitCallElem, SetPollsetOrPollsetSet,
DestroyCallElem, 0,
InitChannelElem, DestroyChannelElem,
GetChannelInfo, "isolated_call_filter"};
} // namespace isolated_call_filter
class IsolatedCallFixture : public TrackCounters {

Loading…
Cancel
Save