mirror of
https://github.com/EchoVault/SugarDB.git
synced 2025-10-07 08:50:59 +08:00
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:
1
src/aof/aof.go
Normal file
1
src/aof/aof.go
Normal file
@@ -0,0 +1 @@
|
||||
package aof
|
25
src/main.go
25
src/main.go
@@ -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
|
||||
|
@@ -1,4 +1,4 @@
|
||||
package memberlist_layer
|
||||
package memberlist
|
||||
|
||||
import (
|
||||
"encoding/json"
|
@@ -1,4 +1,4 @@
|
||||
package memberlist_layer
|
||||
package memberlist
|
||||
|
||||
import (
|
||||
"context"
|
@@ -1,4 +1,4 @@
|
||||
package memberlist_layer
|
||||
package memberlist
|
||||
|
||||
import (
|
||||
"encoding/json"
|
@@ -1,4 +1,4 @@
|
||||
package memberlist_layer
|
||||
package memberlist
|
||||
|
||||
import (
|
||||
"context"
|
@@ -1,4 +1,4 @@
|
||||
package raft_layer
|
||||
package raft
|
||||
|
||||
import (
|
||||
"encoding/json"
|
@@ -1,4 +1,4 @@
|
||||
package raft_layer
|
||||
package raft
|
||||
|
||||
import (
|
||||
"context"
|
@@ -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
1
src/server/server.go
Normal file
@@ -0,0 +1 @@
|
||||
package server
|
4
src/snapshot/snapshot.go
Normal file
4
src/snapshot/snapshot.go
Normal 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.
|
Reference in New Issue
Block a user