From 12f52d5835388f22fdecb2a890d58e5425688c8e Mon Sep 17 00:00:00 2001
From: zhangzengfei <zhangzengfei@smartai.com>
Date: 星期一, 15 五月 2023 17:43:16 +0800
Subject: [PATCH] add default tag
---
agent.go | 2 ++
config.go | 5 ++++-
2 files changed, 6 insertions(+), 1 deletions(-)
diff --git a/agent.go b/agent.go
index a2ae892..3330119 100644
--- a/agent.go
+++ b/agent.go
@@ -60,6 +60,7 @@
NodeID string `json:"nodeID"`
NodeAddress string `json:"nodeAddress"`
IsAlive int `json:"isAlive"`
+ Role string `json:"role"`
}
// Create create serf agent with config
@@ -762,6 +763,7 @@
node.NodeAddress = mb.Addr.String() + ":" + strconv.Itoa(int(mb.Port))
node.IsAlive = int(mb.Status)
node.ClusterID = mb.Tags[tagKeyClusterID]
+ node.Role = mb.Tags["role"]
nodes = append(nodes, node)
}
diff --git a/config.go b/config.go
index 81b019b..ccd6316 100644
--- a/config.go
+++ b/config.go
@@ -137,7 +137,10 @@
serfConf.MemberlistConfig.BindPort = bindPort
serfConf.NodeName = c.NodeName
- serfConf.Tags = map[string]string{TagKeyRPCPort: strconv.Itoa(c.RPCPort)}
+ serfConf.Tags = map[string]string{
+ TagKeyRPCPort: strconv.Itoa(c.RPCPort),
+ "role": "slave",
+ }
if c.ClusterID != "" {
serfConf.Tags[tagKeyClusterID] = c.ClusterID
--
Gitblit v1.8.0