• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2024 gRPC authors.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //     http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef GRPC_SRC_CORE_CLIENT_CHANNEL_LB_METADATA_H
16 #define GRPC_SRC_CORE_CLIENT_CHANNEL_LB_METADATA_H
17 
18 #include <grpc/event_engine/slice.h>
19 
20 #include <string>
21 #include <vector>
22 
23 #include "absl/strings/string_view.h"
24 #include "absl/types/optional.h"
25 #include "src/core/lib/transport/metadata_batch.h"
26 #include "src/core/load_balancing/lb_policy.h"
27 
28 namespace grpc_core {
29 
30 class LbMetadata : public LoadBalancingPolicy::MetadataInterface {
31  public:
LbMetadata(grpc_metadata_batch * batch)32   explicit LbMetadata(grpc_metadata_batch* batch) : batch_(batch) {}
33 
34   absl::optional<absl::string_view> Lookup(absl::string_view key,
35                                            std::string* buffer) const override;
36 
37   std::vector<std::pair<std::string, std::string>> TestOnlyCopyToVector() const;
38 
39  private:
40   grpc_metadata_batch* batch_;
41 };
42 
43 class MetadataMutationHandler {
44  public:
45   static void Apply(LoadBalancingPolicy::MetadataMutations& metadata_mutations,
46                     grpc_metadata_batch* metadata);
47 };
48 
49 void MaybeOverrideAuthority(
50     grpc_event_engine::experimental::Slice authority_override,
51     grpc_metadata_batch* metadata);
52 
53 }  // namespace grpc_core
54 
55 #endif  // GRPC_SRC_CORE_CLIENT_CHANNEL_LB_METADATA_H
56