diff options
author | 2018-10-31 08:54:08 -0700 | |
---|---|---|
committer | 2018-10-31 09:13:44 -0700 | |
commit | 1e64fa629c75ec2cf3be6dd40985f9517c4d33bc (patch) | |
tree | 7c2c7e565a886a8fb2bec0f4307e542e10ea606f /src/core/lib/channel/channelz.h | |
parent | 48c3c964b1c39cd5e0b85387ac85df38bb9db67b (diff) |
Add AddressType
Diffstat (limited to 'src/core/lib/channel/channelz.h')
-rw-r--r-- | src/core/lib/channel/channelz.h | 42 |
1 files changed, 39 insertions, 3 deletions
diff --git a/src/core/lib/channel/channelz.h b/src/core/lib/channel/channelz.h index 404d8341ff..70efbd861d 100644 --- a/src/core/lib/channel/channelz.h +++ b/src/core/lib/channel/channelz.h @@ -229,10 +229,45 @@ class ServerNode : public BaseNode { ChannelTrace trace_; }; +// helper class for holding and rendering the information about a particular +// socket's address +class SocketAddress { + public: + enum class AddressType { + kUnset, + kTcpAddress, + kUdsAddress, + kDirectChannelAddress, + }; + + SocketAddress(); + SocketAddress(SocketAddress&& other); + + void PopulateJson(const char* name, grpc_json* json); + + void set_blob(char* blob) { blob_.reset(blob); } + void set_port(int port) { port_ = port; } + void set_type(AddressType type) { type_ = type; } + + const char* blob_view() { return blob_.get(); } + int port() { return port_; } + AddressType type() { return type_; } + + private: + AddressType type_; + // this holds different information for different address types: + // kTcpAddress = host + // kUdsAddress = filename + // kDirectChannelAddress = name (which is fd num) + UniquePtr<char> blob_; + // used for kTcpAddress, otherwise -1 + int port_; +}; + // Handles channelz bookkeeping for sockets class SocketNode : public BaseNode { public: - SocketNode(UniquePtr<char> remote_host, int remote_port); + SocketNode(SocketAddress local, SocketAddress remote); ~SocketNode() override {} grpc_json* RenderJson() override; @@ -262,14 +297,15 @@ class SocketNode : public BaseNode { gpr_atm last_remote_stream_created_millis_ = 0; gpr_atm last_message_sent_millis_ = 0; gpr_atm last_message_received_millis_ = 0; - UniquePtr<char> remote_host_; - int remote_port_; + SocketAddress local_; + SocketAddress remote_; }; // Handles channelz bookkeeping for listen sockets class ListenSocketNode : public BaseNode { public: // ListenSocketNode takes ownership of host. + // TODO(ncteisen): use SocketAddress to support more address types. ListenSocketNode(UniquePtr<char> host, int port); ~ListenSocketNode() override {} |