File size: 625 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package swogrp

import "github.com/google/uuid"

// Status represents the current status of the switchover process.
type Status struct {
	State      ClusterState
	Nodes      []Node
	LeaderID   uuid.UUID
	LastStatus string
	LastError  string
}

// Status returns the current status of the switchover process.
func (t *TaskMgr) Status() Status {
	t.mx.Lock()
	defer t.mx.Unlock()

	nodes := make([]Node, 0, len(t.nodes))
	for _, n := range t.nodes {
		nodes = append(nodes, n)
	}

	return Status{
		State:      t.state,
		Nodes:      nodes,
		LeaderID:   t.leaderID,
		LastStatus: t.lastStatus,
		LastError:  t.lastError,
	}
}