3 * Copyright 2018 gRPC authors.
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
9 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 #ifndef GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_SERVER_ADDRESS_H
20 #define GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_SERVER_ADDRESS_H
22 #include <grpc/support/port_platform.h>
24 #include "src/core/lib/channel/channel_args.h"
25 #include "src/core/lib/gprpp/inlined_vector.h"
26 #include "src/core/lib/iomgr/resolve_address.h"
28 // Channel arg key for a bool indicating whether an address is a grpclb
29 // load balancer (as opposed to a backend).
30 #define GRPC_ARG_ADDRESS_IS_BALANCER "grpc.address_is_balancer"
32 // Channel arg key for a string indicating an address's balancer name.
33 #define GRPC_ARG_ADDRESS_BALANCER_NAME "grpc.address_balancer_name"
41 // A server address is a grpc_resolved_address with an associated set of
42 // channel args. Any args present here will be merged into the channel
43 // args when a subchannel is created for this address.
46 // Takes ownership of args.
47 ServerAddress(const grpc_resolved_address& address, grpc_channel_args* args);
48 ServerAddress(const void* address, size_t address_len,
49 grpc_channel_args* args);
51 ~ServerAddress() { grpc_channel_args_destroy(args_); }
54 ServerAddress(const ServerAddress& other)
55 : address_(other.address_), args_(grpc_channel_args_copy(other.args_)) {}
56 ServerAddress& operator=(const ServerAddress& other) {
57 address_ = other.address_;
58 grpc_channel_args_destroy(args_);
59 args_ = grpc_channel_args_copy(other.args_);
64 ServerAddress(ServerAddress&& other)
65 : address_(other.address_), args_(other.args_) {
66 other.args_ = nullptr;
68 ServerAddress& operator=(ServerAddress&& other) {
69 address_ = other.address_;
70 grpc_channel_args_destroy(args_);
72 other.args_ = nullptr;
76 bool operator==(const ServerAddress& other) const;
78 const grpc_resolved_address& address() const { return address_; }
79 const grpc_channel_args* args() const { return args_; }
81 bool IsBalancer() const;
84 grpc_resolved_address address_;
85 grpc_channel_args* args_;
92 typedef InlinedVector<ServerAddress, 1> ServerAddressList;
94 } // namespace grpc_core
96 #endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_SERVER_ADDRESS_H */