Skip to content

Commit

Permalink
Added Slave Mode status to stolonctl status
Browse files Browse the repository at this point in the history
  • Loading branch information
mhkarimi1383 committed Dec 30, 2022
1 parent 4cb160a commit 6fca5bd
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions cmd/proxy/cmd/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ func (c *ClusterChecker) SetProxyInfo(e store.Store, generation int64, proxyTime
UID: c.uid,
Generation: generation,
ProxyTimeout: proxyTimeout,
SlaveMode: cfg.slaveNode,
}
log.Debugf("proxyInfo dump: %s", spew.Sdump(proxyInfo))

Expand Down
7 changes: 4 additions & 3 deletions cmd/stolonctl/cmd/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ type SentinelStatus struct {
type ProxyStatus struct {
UID string `json:"uid"`
Generation int64 `json:"generation"`
SlaveMode bool `json:"slaveMode"`
}

type KeeperStatus struct {
Expand Down Expand Up @@ -134,9 +135,9 @@ func renderText(status Status, generateErr error) {
if len(status.Proxies) == 0 {
stdout("No active proxies")
} else {
fmt.Fprintf(tabOut, "ID\n")
fmt.Fprintf(tabOut, "ID\tSLAVE MODE\n")
for _, p := range status.Proxies {
fmt.Fprintf(tabOut, "%s\n", p.UID)
fmt.Fprintf(tabOut, "%s\t%t\n", p.UID, p.SlaveMode)
tabOut.Flush()
}
}
Expand Down Expand Up @@ -273,7 +274,7 @@ func generateStatus() (Status, error) {
proxies := make([]ProxyStatus, 0)
sort.Sort(proxiesInfoSlice)
for _, pi := range proxiesInfoSlice {
proxies = append(proxies, ProxyStatus{UID: pi.UID, Generation: pi.Generation})
proxies = append(proxies, ProxyStatus{UID: pi.UID, Generation: pi.Generation, SlaveMode: pi.SlaveMode})
}
status.Proxies = proxies

Expand Down
2 changes: 2 additions & 0 deletions internal/cluster/member.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ type ProxyInfo struct {
// It's used by the sentinel to know for how much time the
// proxy should be considered active.
ProxyTimeout time.Duration

SlaveMode bool
}

type ProxiesInfo map[string]*ProxyInfo
Expand Down

0 comments on commit 6fca5bd

Please sign in to comment.