mirror of https://github.com/grpc/grpc.git
[resolver API] remove address attribute interface (#33514)
The address attribute interface was intended to provide a mechanism to pass attributes separately from channel args, for values that do not affect subchannel behavior and therefore do not need to be present in the subchannel key, which does include channel args. However, the mechanism as currently designed is fairly clunky and is probably not the direction we will want to go in the long term. Eventually, we will want some mechanism for registering channel args, which would provide a cleaner way to indicate that a given channel arg should not be used in the subchannel key, so that we don't need a completely different mechanism. For now, this PR is just doing an interim step, which is to establish a special channel arg key prefix to indicate that an arg is not needed in the subchannel key.pull/33551/head
parent
35754ac603
commit
8427bacaea
46 changed files with 240 additions and 623 deletions
@ -1,42 +0,0 @@ |
||||
//
|
||||
// Copyright 2018 gRPC authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
#include <grpc/support/port_platform.h> |
||||
|
||||
#include "src/core/ext/filters/client_channel/lb_policy/xds/xds_attributes.h" |
||||
|
||||
#include "absl/strings/str_cat.h" |
||||
|
||||
#include "src/core/lib/gpr/useful.h" |
||||
|
||||
namespace grpc_core { |
||||
|
||||
const char* kXdsLocalityNameAttributeKey = "xds_locality_name"; |
||||
|
||||
int XdsLocalityAttribute::Cmp(const AttributeInterface* other) const { |
||||
const auto* other_locality_attr = |
||||
static_cast<const XdsLocalityAttribute*>(other); |
||||
int r = locality_name_->Compare(*other_locality_attr->locality_name_); |
||||
if (r != 0) return r; |
||||
return QsortCompare(weight_, other_locality_attr->weight_); |
||||
} |
||||
|
||||
std::string XdsLocalityAttribute::ToString() const { |
||||
return absl::StrCat("{name=", locality_name_->AsHumanReadableString(), |
||||
", weight=", weight_, "}"); |
||||
} |
||||
|
||||
} // namespace grpc_core
|
@ -1,64 +0,0 @@ |
||||
//
|
||||
// Copyright 2018 gRPC authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
#ifndef GRPC_SRC_CORE_EXT_FILTERS_CLIENT_CHANNEL_LB_POLICY_XDS_XDS_ATTRIBUTES_H |
||||
#define GRPC_SRC_CORE_EXT_FILTERS_CLIENT_CHANNEL_LB_POLICY_XDS_XDS_ATTRIBUTES_H |
||||
|
||||
#include <grpc/support/port_platform.h> |
||||
|
||||
#include <stdint.h> |
||||
|
||||
#include <memory> |
||||
#include <string> |
||||
#include <utility> |
||||
|
||||
#include "src/core/ext/xds/xds_client_stats.h" |
||||
#include "src/core/lib/gprpp/ref_counted_ptr.h" |
||||
#include "src/core/lib/resolver/server_address.h" |
||||
|
||||
namespace grpc_core { |
||||
|
||||
extern const char* kXdsLocalityNameAttributeKey; |
||||
|
||||
class XdsLocalityAttribute : public ServerAddress::AttributeInterface { |
||||
public: |
||||
XdsLocalityAttribute(RefCountedPtr<XdsLocalityName> locality_name, |
||||
uint32_t weight) |
||||
: locality_name_(std::move(locality_name)), weight_(weight) {} |
||||
|
||||
RefCountedPtr<XdsLocalityName> locality_name() const { |
||||
return locality_name_; |
||||
} |
||||
|
||||
uint32_t weight() const { return weight_; } |
||||
|
||||
std::unique_ptr<AttributeInterface> Copy() const override { |
||||
return std::make_unique<XdsLocalityAttribute>(locality_name_->Ref(), |
||||
weight_); |
||||
} |
||||
|
||||
int Cmp(const AttributeInterface* other) const override; |
||||
|
||||
std::string ToString() const override; |
||||
|
||||
private: |
||||
RefCountedPtr<XdsLocalityName> locality_name_; |
||||
uint32_t weight_; |
||||
}; |
||||
|
||||
} // namespace grpc_core
|
||||
|
||||
#endif // GRPC_SRC_CORE_EXT_FILTERS_CLIENT_CHANNEL_LB_POLICY_XDS_XDS_ATTRIBUTES_H
|
Loading…
Reference in new issue