1 /* 2 * 3 * Copyright 2018 gRPC authors. 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 * 17 */ 18 19 #ifndef GRPC_TEST_CORE_UTIL_TEST_LB_POLICIES_H 20 #define GRPC_TEST_CORE_UTIL_TEST_LB_POLICIES_H 21 22 #include "src/core/ext/filters/client_channel/lb_policy.h" 23 24 namespace grpc_core { 25 26 using MetadataVector = std::vector<std::pair<std::string, std::string>>; 27 28 struct PickArgsSeen { 29 std::string path; 30 MetadataVector metadata; 31 }; 32 33 using TestPickArgsCallback = std::function<void(const PickArgsSeen&)>; 34 35 // Registers an LB policy called "test_pick_args_lb" that checks the args 36 // passed to SubchannelPicker::Pick(). 37 void RegisterTestPickArgsLoadBalancingPolicy(TestPickArgsCallback cb); 38 39 struct TrailingMetadataArgsSeen { 40 const LoadBalancingPolicy::BackendMetricData* backend_metric_data; 41 MetadataVector metadata; 42 }; 43 44 using InterceptRecvTrailingMetadataCallback = 45 std::function<void(const TrailingMetadataArgsSeen&)>; 46 47 // Registers an LB policy called "intercept_trailing_metadata_lb" that 48 // invokes cb with argument user_data when trailing metadata is received 49 // for each call. 50 void RegisterInterceptRecvTrailingMetadataLoadBalancingPolicy( 51 InterceptRecvTrailingMetadataCallback cb); 52 53 } // namespace grpc_core 54 55 #endif // GRPC_TEST_CORE_UTIL_TEST_LB_POLICIES_H 56