Renamed memebrlist_layer directory to memberlist.

Renamed raft_layer directory to raft.
Created snapshot and aof packages to handle snapshots in standalone mode and aof package to handle append-only function.
Created server package that will contain the server logic.
This commit is contained in:
Kelvin Clement Mwinuka
2024-01-21 15:03:36 +08:00
parent 12c78a4a5a
commit 78aa9a82c6
28 changed files with 28 additions and 21 deletions

1
src/aof/aof.go Normal file
View File

@@ -0,0 +1 @@
package aof

View File

@@ -7,18 +7,18 @@ import (
"encoding/json"
"errors"
"fmt"
"github.com/kelvinmwinuka/memstore/src/command_modules/acl"
"github.com/kelvinmwinuka/memstore/src/command_modules/etc"
"github.com/kelvinmwinuka/memstore/src/command_modules/get"
"github.com/kelvinmwinuka/memstore/src/command_modules/hash"
"github.com/kelvinmwinuka/memstore/src/command_modules/list"
"github.com/kelvinmwinuka/memstore/src/command_modules/ping"
"github.com/kelvinmwinuka/memstore/src/command_modules/pubsub"
"github.com/kelvinmwinuka/memstore/src/command_modules/set"
"github.com/kelvinmwinuka/memstore/src/command_modules/sorted_set"
str "github.com/kelvinmwinuka/memstore/src/command_modules/string"
ml "github.com/kelvinmwinuka/memstore/src/memberlist_layer"
rl "github.com/kelvinmwinuka/memstore/src/raft_layer"
ml "github.com/kelvinmwinuka/memstore/src/memberlist"
"github.com/kelvinmwinuka/memstore/src/modules/acl"
"github.com/kelvinmwinuka/memstore/src/modules/etc"
"github.com/kelvinmwinuka/memstore/src/modules/get"
"github.com/kelvinmwinuka/memstore/src/modules/hash"
"github.com/kelvinmwinuka/memstore/src/modules/list"
"github.com/kelvinmwinuka/memstore/src/modules/ping"
"github.com/kelvinmwinuka/memstore/src/modules/pubsub"
"github.com/kelvinmwinuka/memstore/src/modules/set"
"github.com/kelvinmwinuka/memstore/src/modules/sorted_set"
str "github.com/kelvinmwinuka/memstore/src/modules/string"
rl "github.com/kelvinmwinuka/memstore/src/raft"
"io"
"log"
"net"
@@ -242,6 +242,7 @@ func (server *Server) handleConnection(ctx context.Context, conn net.Conn) {
connRW.Write([]byte(fmt.Sprintf("-%s\r\n\n", err.Error())))
} else {
connRW.Write(res)
// TODO: Write successful, add entry to AOF
}
connRW.Flush()
continue

View File

@@ -1,4 +1,4 @@
package memberlist_layer
package memberlist
import (
"encoding/json"

View File

@@ -1,4 +1,4 @@
package memberlist_layer
package memberlist
import (
"context"

View File

@@ -1,4 +1,4 @@
package memberlist_layer
package memberlist
import (
"encoding/json"

View File

@@ -1,4 +1,4 @@
package memberlist_layer
package memberlist
import (
"context"

View File

@@ -1,4 +1,4 @@
package raft_layer
package raft
import (
"encoding/json"

View File

@@ -1,4 +1,4 @@
package raft_layer
package raft
import (
"context"

View File

@@ -1,10 +1,10 @@
package raft_layer
package raft
import (
"context"
"errors"
"fmt"
"github.com/kelvinmwinuka/memstore/src/memberlist_layer"
"github.com/kelvinmwinuka/memstore/src/memberlist"
"log"
"net"
"os"
@@ -175,7 +175,7 @@ func (r *Raft) AddVoter(
return nil
}
func (r *Raft) RemoveServer(meta memberlist_layer.NodeMeta) error {
func (r *Raft) RemoveServer(meta memberlist.NodeMeta) error {
if !r.IsRaftLeader() {
return errors.New("not leader, could not remove server")
}

1
src/server/server.go Normal file
View File

@@ -0,0 +1 @@
package server

4
src/snapshot/snapshot.go Normal file
View File

@@ -0,0 +1,4 @@
package snapshot
// This package contains the snapshot engine for standalone mode.
// Snapshots in cluster mode will be handled using the raft package in the raft layer.