From 2863a050be2530afc452e48aae8b4be9b3965ebd Mon Sep 17 00:00:00 2001
From: zhangzengfei <zhangzengfei@smartai.com>
Date: 星期一, 15 五月 2023 18:18:53 +0800
Subject: [PATCH] add default role tag
---
agent.go | 3 +++
config.go | 2 +-
2 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/agent.go b/agent.go
index 822583b..0274499 100644
--- a/agent.go
+++ b/agent.go
@@ -51,6 +51,7 @@
NodeID string `json:"nodeID"`
NodeAddress string `json:"nodeAddress"`
IsAlive int `json:"isAlive"`
+ Role string `json:"role"`
}
// Create create serf agent with config
@@ -177,6 +178,7 @@
nodeID,
nodeAddress,
isAlive,
+ mb.Tags["role"],
})
// replace node address
@@ -406,6 +408,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 825a0f5..ac65ecc 100644
--- a/config.go
+++ b/config.go
@@ -163,7 +163,7 @@
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