Skip to content

Commit 7665433

Browse files
committed
Add String() func for NodeEventType and NodeStateType
Signed-off-by: Etienne Champetier <e.champetier@ateme.com>
1 parent 83c5487 commit 7665433

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

event_delegate.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ const (
4242
NodeUpdate
4343
)
4444

45+
func (net NodeEventType) String() string {
46+
return []string{"NodeJoin", "NodeLeave", "NodeUpdate"}[net]
47+
}
48+
4549
// NodeEvent is a single event related to node activity in the memberlist.
4650
// The Node member of this struct must not be directly modified. It is passed
4751
// as a pointer to avoid unnecessary copies. If you wish to modify the node,

state.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ const (
4040
StateLeft
4141
)
4242

43+
func (nst NodeStateType) String() string {
44+
return []string{"StateAlive", "StateSuspect", "StateDead", "StateLeft"}[nst]
45+
}
46+
4347
// Node represents a node in the cluster.
4448
type Node struct {
4549
Name string

0 commit comments

Comments
 (0)