Created basic handling for taking snapshots. Will implemented error when snapshot in progress and propagation of snapshot command to the rest of the cluster

This commit is contained in:
Kelvin Clement Mwinuka
2024-01-26 00:58:43 +08:00
parent 63fcb490c9
commit 3c5d6fef2c
5 changed files with 46 additions and 1 deletions

View File

@@ -240,6 +240,15 @@ func (server *Server) Start(ctx context.Context) {
server.StartTCP(ctx)
}
func (server *Server) TakeSnapshot() error {
// TODO: Check if there's a snapshot currently in progress
go func() {
err := server.raft.TakeSnapshot()
log.Println(err)
}()
return nil
}
func (server *Server) ShutDown(ctx context.Context) {
if server.IsInCluster() {
server.raft.RaftShutdown(ctx)