Implemented RewriteLog functionality and defined handler for REWRITE AOF command.

This commit is contained in:
Kelvin Clement Mwinuka
2024-01-30 23:33:24 +08:00
parent dff80940cd
commit 25b2cb7154
4 changed files with 47 additions and 4 deletions

View File

@@ -242,7 +242,8 @@ func (server *Server) Start(ctx context.Context) {
} else {
// Initialize standalone AOF engine
server.AOFEngine = aof.NewAOFEngine(aof.Opts{
Config: conf,
Config: conf,
GetState: server.GetState,
})
// Initialize and start standalone snapshot engine
server.SnapshotEngine = snapshot.NewSnapshotEngine(snapshot.Opts{
@@ -295,6 +296,11 @@ func (server *Server) GetLatestSnapshot() int64 {
return server.LatestSnapshotMilliseconds.Load()
}
func (server *Server) RewriteAOF() error {
// TODO: Make this concurrent
return server.AOFEngine.RewriteLog()
}
func (server *Server) ShutDown(ctx context.Context) {
if server.IsInCluster() {
server.raft.RaftShutdown(ctx)