Add /v3/cluster/snapshot endpoint

This commit is contained in:
Ingo Oppermann
2023-06-27 15:11:31 +02:00
parent dd128ac99b
commit 89379b2acd
10 changed files with 110 additions and 13 deletions

View File

@@ -48,7 +48,7 @@ type Cluster interface {
Join(origin, id, raftAddress, peerAddress string) error
Leave(origin, id string) error // gracefully remove a node from the cluster
Snapshot() (io.ReadCloser, error)
Snapshot(origin string) (io.ReadCloser, error)
Shutdown() error
@@ -827,10 +827,10 @@ func (c *cluster) Join(origin, id, raftAddress, peerAddress string) error {
return nil
}
func (c *cluster) Snapshot() (io.ReadCloser, error) {
func (c *cluster) Snapshot(origin string) (io.ReadCloser, error) {
if !c.IsRaftLeader() {
c.logger.Debug().Log("Not leader, forwarding to leader")
return c.forwarder.Snapshot()
return c.forwarder.Snapshot(origin)
}
return c.raft.Snapshot()