GRPC C++  1.39.1
xds.h
Go to the documentation of this file.
1 //
2 // Copyright 2018 gRPC authors.
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16 
17 #ifndef GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_LB_POLICY_XDS_XDS_H
18 #define GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_LB_POLICY_XDS_XDS_H
19 
21 
25 
26 namespace grpc_core {
27 
28 // Defined in the EDS policy.
29 extern const char* kXdsLocalityNameAttributeKey;
30 
32  public:
34  : locality_name_(std::move(locality_name)) {}
35 
37  return locality_name_;
38  }
39 
40  std::unique_ptr<AttributeInterface> Copy() const override {
41  return absl::make_unique<XdsLocalityAttribute>(locality_name_->Ref());
42  }
43 
44  int Cmp(const AttributeInterface* other) const override {
45  const auto* other_locality_attr =
46  static_cast<const XdsLocalityAttribute*>(other);
47  return locality_name_->Compare(*other_locality_attr->locality_name_);
48  }
49 
50  std::string ToString() const override {
51  return locality_name_->AsHumanReadableString();
52  }
53 
54  private:
55  RefCountedPtr<XdsLocalityName> locality_name_;
56 };
57 
58 } // namespace grpc_core
59 
60 #endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_LB_POLICY_XDS_XDS_H */
Definition: ref_counted_ptr.h:35
Definition: server_address.h:52
RefCountedPtr< XdsLocalityName > locality_name() const
Definition: xds.h:36
XdsLocalityAttribute(RefCountedPtr< XdsLocalityName > locality_name)
Definition: xds.h:33
std::string ToString() const override
Definition: xds.h:50
int Cmp(const AttributeInterface *other) const override
Definition: xds.h:44
std::unique_ptr< AttributeInterface > Copy() const override
Definition: xds.h:40
Round Robin Policy.
Definition: backend_metric.cc:26
const char * kXdsLocalityNameAttributeKey
Definition: xds_cluster_resolver.cc:56
Definition: async_unary_call.h:398