Skip to content

Commit

Permalink
Move GetChannelConnectivityStateChangeString to channelz code
Browse files Browse the repository at this point in the history
  • Loading branch information
hcaseyal committed Jul 22, 2019
1 parent 0beb353 commit 81013e5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
19 changes: 1 addition & 18 deletions src/core/ext/filters/client_channel/client_channel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,7 @@ class ChannelData::ConnectivityStateAndPickerSetter {
chand->channelz_node_->AddTraceEvent(
channelz::ChannelTrace::Severity::Info,
grpc_slice_from_static_string(
GetChannelConnectivityStateChangeString(state)));
channelz::GetChannelConnectivityStateChangeString(state)));
}
// Bounce into the data plane combiner to reset the picker.
GRPC_CHANNEL_STACK_REF(chand->owning_stack_,
Expand All @@ -744,23 +744,6 @@ class ChannelData::ConnectivityStateAndPickerSetter {
}

private:
static const char* GetChannelConnectivityStateChangeString(
grpc_connectivity_state state) {
switch (state) {
case GRPC_CHANNEL_IDLE:
return "Channel state change to IDLE";
case GRPC_CHANNEL_CONNECTING:
return "Channel state change to CONNECTING";
case GRPC_CHANNEL_READY:
return "Channel state change to READY";
case GRPC_CHANNEL_TRANSIENT_FAILURE:
return "Channel state change to TRANSIENT_FAILURE";
case GRPC_CHANNEL_SHUTDOWN:
return "Channel state change to SHUTDOWN";
}
GPR_UNREACHABLE_CODE(return "UNKNOWN");
}

static void SetPicker(void* arg, grpc_error* ignored) {
auto* self = static_cast<ConnectivityStateAndPickerSetter*>(arg);
// Update picker.
Expand Down
17 changes: 17 additions & 0 deletions src/core/lib/channel/channelz.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,23 @@ class CallCountingHelperPeer;
class ChannelNodePeer;
} // namespace testing

inline static const char* GetChannelConnectivityStateChangeString(
grpc_connectivity_state state) {
switch (state) {
case GRPC_CHANNEL_IDLE:
return "Channel state change to IDLE";
case GRPC_CHANNEL_CONNECTING:
return "Channel state change to CONNECTING";
case GRPC_CHANNEL_READY:
return "Channel state change to READY";
case GRPC_CHANNEL_TRANSIENT_FAILURE:
return "Channel state change to TRANSIENT_FAILURE";
case GRPC_CHANNEL_SHUTDOWN:
return "Channel state change to SHUTDOWN";
}
GPR_UNREACHABLE_CODE(return "UNKNOWN");
}

// base class for all channelz entities
class BaseNode : public RefCounted<BaseNode> {
public:
Expand Down

0 comments on commit 81013e5

Please sign in to comment.