MCPcopy Create free account
hub / github.com/apache/kvrocks-controller / GetClusterNodeInfo

Method GetClusterNodeInfo

store/cluster_node.go:210–234  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

208}
209
210func (n *ClusterNode) GetClusterNodeInfo(ctx context.Context) (*ClusterNodeInfo, error) {
211 infoStr, err := n.GetClient().Info(ctx).Result()
212 if err != nil {
213 return nil, err
214 }
215
216 clusterNodeInfo := &ClusterNodeInfo{}
217 lines := strings.Split(infoStr, "\r\n")
218 for _, line := range lines {
219 fields := strings.Split(line, ":")
220 if len(fields) != 2 {
221 continue
222 }
223 switch fields[0] {
224 case "sequence":
225 clusterNodeInfo.Sequence, err = strconv.ParseUint(fields[1], 10, 64)
226 if err != nil {
227 return nil, err
228 }
229 case "role":
230 clusterNodeInfo.Role = fields[1]
231 }
232 }
233 return clusterNodeInfo, nil
234}
235
236func (n *ClusterNode) GetClusterNodesString(ctx context.Context) (string, error) {
237 clusterNodesStr, err := n.GetClient().ClusterNodes(ctx).Result()

Callers 1

TestClusterNodeFunction · 0.95

Calls 2

GetClientMethod · 0.95
InfoMethod · 0.80

Tested by 1

TestClusterNodeFunction · 0.76