Moved main.go file to cmd subfolder. Renamed src folder to pkg folder as it will contain all the importable package code. Moved config.go to new internals folder

This commit is contained in:
Kelvin Mwinuka
2024-03-25 21:13:40 +08:00
parent c72e982833
commit 5c86fb6215
58 changed files with 2925 additions and 2906 deletions

View File

@@ -1,5 +1,5 @@
build-server: build-server:
CC=$(CC) GOOS=$(GOOS) GOARCH=$(GOARCH) go build -o $(DEST)/server ./src/*.go CC=$(CC) GOOS=$(GOOS) GOARCH=$(GOARCH) go build -o $(DEST)/server ./cmd/main.go
build: build:
env CC=x86_64-linux-musl-gcc GOOS=linux GOARCH=amd64 DEST=bin/linux/x86_64 make build-server env CC=x86_64-linux-musl-gcc GOOS=linux GOARCH=amd64 DEST=bin/linux/x86_64 make build-server
@@ -8,4 +8,4 @@ run:
make build && docker-compose up --build make build && docker-compose up --build
test: test:
go clean -testcache && go test ./src/... -coverprofile coverage/coverage.out go clean -testcache && go test ./pkg/... -coverprofile coverage/coverage.out

View File

@@ -16,18 +16,19 @@ package main
import ( import (
"context" "context"
"github.com/echovault/echovault/src/echovault" "github.com/echovault/echovault/internal"
"github.com/echovault/echovault/src/modules/acl" "github.com/echovault/echovault/pkg/echovault"
"github.com/echovault/echovault/src/modules/admin" "github.com/echovault/echovault/pkg/modules/acl"
"github.com/echovault/echovault/src/modules/connection" "github.com/echovault/echovault/pkg/modules/admin"
"github.com/echovault/echovault/src/modules/generic" "github.com/echovault/echovault/pkg/modules/connection"
"github.com/echovault/echovault/src/modules/hash" "github.com/echovault/echovault/pkg/modules/generic"
"github.com/echovault/echovault/src/modules/list" "github.com/echovault/echovault/pkg/modules/hash"
"github.com/echovault/echovault/src/modules/pubsub" "github.com/echovault/echovault/pkg/modules/list"
"github.com/echovault/echovault/src/modules/set" "github.com/echovault/echovault/pkg/modules/pubsub"
"github.com/echovault/echovault/src/modules/sorted_set" "github.com/echovault/echovault/pkg/modules/set"
str "github.com/echovault/echovault/src/modules/string" "github.com/echovault/echovault/pkg/modules/sorted_set"
"github.com/echovault/echovault/src/utils" str "github.com/echovault/echovault/pkg/modules/string"
"github.com/echovault/echovault/pkg/utils"
"log" "log"
"os" "os"
"os/signal" "os/signal"
@@ -50,7 +51,7 @@ func GetCommands() []utils.Command {
} }
func main() { func main() {
config, err := utils.GetConfig() config, err := internal.GetConfig()
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)

File diff suppressed because it is too large Load Diff

View File

@@ -12,13 +12,14 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
package utils package internal
import ( import (
"encoding/json" "encoding/json"
"errors" "errors"
"flag" "flag"
"fmt" "fmt"
"github.com/echovault/echovault/pkg/utils"
"log" "log"
"os" "os"
"path" "path"
@@ -98,7 +99,7 @@ The options are 'always' for syncing on each command, 'everysec' to sync every s
flag.Func("max-memory", `Upper memory limit before triggering eviction. flag.Func("max-memory", `Upper memory limit before triggering eviction.
Supported units (kb, mb, gb, tb, pb). When 0 is passed, there will be no memory limit. Supported units (kb, mb, gb, tb, pb). When 0 is passed, there will be no memory limit.
There is no limit by default.`, func(memory string) error { There is no limit by default.`, func(memory string) error {
b, err := ParseMemory(memory) b, err := utils.ParseMemory(memory)
if err != nil { if err != nil {
return err return err
} }
@@ -106,7 +107,7 @@ There is no limit by default.`, func(memory string) error {
return nil return nil
}) })
evictionPolicy := NoEviction evictionPolicy := utils.NoEviction
flag.Func("eviction-policy", `The eviction policy used to remove keys when max-memory is reached. The options are: flag.Func("eviction-policy", `The eviction policy used to remove keys when max-memory is reached. The options are:
1) noeviction - Do not evict any keys even when max-memory is exceeded. 1) noeviction - Do not evict any keys even when max-memory is exceeded.
2) allkeys-lfu - Evict the least frequently used keys. 2) allkeys-lfu - Evict the least frequently used keys.
@@ -116,9 +117,9 @@ There is no limit by default.`, func(memory string) error {
6) allkeys-random - Evict random keys until we get under the max-memory limit. 6) allkeys-random - Evict random keys until we get under the max-memory limit.
7) volatile-random - Evict random keys with an expiration.`, func(policy string) error { 7) volatile-random - Evict random keys with an expiration.`, func(policy string) error {
policies := []string{ policies := []string{
NoEviction, utils.NoEviction,
AllKeysLFU, AllKeysLRU, AllKeysRandom, utils.AllKeysLFU, utils.AllKeysLRU, utils.AllKeysRandom,
VolatileLFU, VolatileLRU, VolatileRandom, utils.VolatileLFU, utils.VolatileLRU, utils.VolatileRandom,
} }
policyIdx := slices.Index(policies, strings.ToLower(policy)) policyIdx := slices.Index(policies, strings.ToLower(policy))
if policyIdx == -1 { if policyIdx == -1 {
@@ -131,7 +132,7 @@ There is no limit by default.`, func(memory string) error {
tls := flag.Bool("tls", false, "Start the echovault in TLS mode. Default is false.") tls := flag.Bool("tls", false, "Start the echovault in TLS mode. Default is false.")
mtls := flag.Bool("mtls", false, "Use mTLS to verify the client.") mtls := flag.Bool("mtls", false, "Use mTLS to verify the client.")
port := flag.Int("port", 7480, "Port to use. Default is 7480") port := flag.Int("port", 7480, "Port to use. Default is 7480")
serverId := flag.String("echovault-id", "1", "EchoVault ID in raft cluster. Leave empty for client.") serverId := flag.String("server-id", "1", "EchoVault ID in raft cluster. Leave empty for client.")
joinAddr := flag.String("join-addr", "", "Address of cluster member in a cluster to you want to join.") joinAddr := flag.String("join-addr", "", "Address of cluster member in a cluster to you want to join.")
bindAddr := flag.String("bind-addr", "", "Address to bind the echovault to.") bindAddr := flag.String("bind-addr", "", "Address to bind the echovault to.")
raftBindPort := flag.Uint("raft-port", 7481, "Port to use for intra-cluster communication. Leave on the client.") raftBindPort := flag.Uint("raft-port", 7481, "Port to use for intra-cluster communication. Leave on the client.")

View File

@@ -16,9 +16,9 @@ package aof
import ( import (
"fmt" "fmt"
logstore "github.com/echovault/echovault/src/aof/log" logstore "github.com/echovault/echovault/pkg/aof/log"
"github.com/echovault/echovault/src/aof/preamble" "github.com/echovault/echovault/pkg/aof/preamble"
"github.com/echovault/echovault/src/utils" "github.com/echovault/echovault/pkg/utils"
"log" "log"
"sync" "sync"
) )

View File

@@ -17,7 +17,7 @@ package preamble
import ( import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"github.com/echovault/echovault/src/utils" "github.com/echovault/echovault/pkg/utils"
"io" "io"
"log" "log"
"os" "os"

View File

@@ -18,7 +18,7 @@ import (
"context" "context"
"encoding/json" "encoding/json"
"fmt" "fmt"
"github.com/echovault/echovault/src/utils" "github.com/echovault/echovault/pkg/utils"
"time" "time"
) )

View File

@@ -20,12 +20,13 @@ import (
"crypto/x509" "crypto/x509"
"errors" "errors"
"fmt" "fmt"
"github.com/echovault/echovault/src/aof" "github.com/echovault/echovault/internal"
"github.com/echovault/echovault/src/eviction" "github.com/echovault/echovault/pkg/aof"
"github.com/echovault/echovault/src/memberlist" "github.com/echovault/echovault/pkg/eviction"
"github.com/echovault/echovault/src/raft" "github.com/echovault/echovault/pkg/memberlist"
"github.com/echovault/echovault/src/snapshot" "github.com/echovault/echovault/pkg/raft"
"github.com/echovault/echovault/src/utils" "github.com/echovault/echovault/pkg/snapshot"
"github.com/echovault/echovault/pkg/utils"
"io" "io"
"log" "log"
"net" "net"
@@ -37,7 +38,7 @@ import (
type EchoVault struct { type EchoVault struct {
// config holds the echovault configuration variables. // config holds the echovault configuration variables.
config utils.Config config internal.Config
// The current index for the latest connection id. // The current index for the latest connection id.
// This number is incremented everytime there's a new connection and // This number is incremented everytime there's a new connection and
@@ -90,7 +91,7 @@ func WithContext(ctx context.Context) func(echovault *EchoVault) {
} }
} }
func WithConfig(config utils.Config) func(echovault *EchoVault) { func WithConfig(config internal.Config) func(echovault *EchoVault) {
return func(echovault *EchoVault) { return func(echovault *EchoVault) {
echovault.config = config echovault.config = config
} }

View File

@@ -18,7 +18,7 @@ import (
"context" "context"
"errors" "errors"
"fmt" "fmt"
"github.com/echovault/echovault/src/utils" "github.com/echovault/echovault/pkg/utils"
"log" "log"
"math/rand" "math/rand"
"runtime" "runtime"

View File

@@ -18,7 +18,7 @@ import (
"context" "context"
"errors" "errors"
"fmt" "fmt"
"github.com/echovault/echovault/src/utils" "github.com/echovault/echovault/pkg/utils"
"net" "net"
"strings" "strings"
) )

View File

@@ -18,7 +18,8 @@ import (
"context" "context"
"encoding/json" "encoding/json"
"fmt" "fmt"
"github.com/echovault/echovault/src/utils" "github.com/echovault/echovault/internal"
"github.com/echovault/echovault/pkg/utils"
"github.com/hashicorp/memberlist" "github.com/hashicorp/memberlist"
"github.com/hashicorp/raft" "github.com/hashicorp/raft"
"log" "log"
@@ -30,7 +31,7 @@ type Delegate struct {
} }
type DelegateOpts struct { type DelegateOpts struct {
config utils.Config config internal.Config
broadcastQueue *memberlist.TransmitLimitedQueue broadcastQueue *memberlist.TransmitLimitedQueue
addVoter func(id raft.ServerID, address raft.ServerAddress, prevIndex uint64, timeout time.Duration) error addVoter func(id raft.ServerID, address raft.ServerAddress, prevIndex uint64, timeout time.Duration) error
isRaftLeader func() bool isRaftLeader func() bool

View File

@@ -18,10 +18,11 @@ import (
"context" "context"
"crypto/md5" "crypto/md5"
"fmt" "fmt"
"github.com/echovault/echovault/internal"
"log" "log"
"time" "time"
"github.com/echovault/echovault/src/utils" "github.com/echovault/echovault/pkg/utils"
"github.com/hashicorp/memberlist" "github.com/hashicorp/memberlist"
"github.com/hashicorp/raft" "github.com/hashicorp/raft"
"github.com/sethvargo/go-retry" "github.com/sethvargo/go-retry"
@@ -34,7 +35,7 @@ type NodeMeta struct {
} }
type Opts struct { type Opts struct {
Config utils.Config Config internal.Config
HasJoinedCluster func() bool HasJoinedCluster func() bool
AddVoter func(id raft.ServerID, address raft.ServerAddress, prevIndex uint64, timeout time.Duration) error AddVoter func(id raft.ServerID, address raft.ServerAddress, prevIndex uint64, timeout time.Duration) error
RemoveRaftServer func(meta NodeMeta) error RemoveRaftServer func(meta NodeMeta) error

View File

@@ -20,7 +20,8 @@ import (
"encoding/json" "encoding/json"
"errors" "errors"
"fmt" "fmt"
"github.com/echovault/echovault/src/utils" "github.com/echovault/echovault/internal"
"github.com/echovault/echovault/pkg/utils"
"github.com/gobwas/glob" "github.com/gobwas/glob"
"gopkg.in/yaml.v3" "gopkg.in/yaml.v3"
"log" "log"
@@ -43,11 +44,11 @@ type ACL struct {
Users []*User // List of ACL user profiles Users []*User // List of ACL user profiles
UsersMutex sync.RWMutex // RWMutex for concurrency control when accessing ACL profile list UsersMutex sync.RWMutex // RWMutex for concurrency control when accessing ACL profile list
Connections map[*net.Conn]Connection // Connections to the echovault that are currently registered with the ACL module Connections map[*net.Conn]Connection // Connections to the echovault that are currently registered with the ACL module
Config utils.Config // EchoVault configuration that contains the relevant ACL config options Config internal.Config // EchoVault configuration that contains the relevant ACL config options
GlobPatterns map[string]glob.Glob GlobPatterns map[string]glob.Glob
} }
func NewACL(config utils.Config) *ACL { func NewACL(config internal.Config) *ACL {
var users []*User var users []*User
// 1. Initialise default ACL user // 1. Initialise default ACL user

View File

@@ -19,7 +19,7 @@ import (
"encoding/json" "encoding/json"
"errors" "errors"
"fmt" "fmt"
"github.com/echovault/echovault/src/utils" "github.com/echovault/echovault/pkg/utils"
"gopkg.in/yaml.v3" "gopkg.in/yaml.v3"
"log" "log"
"net" "net"

View File

@@ -18,8 +18,9 @@ import (
"context" "context"
"crypto/sha256" "crypto/sha256"
"fmt" "fmt"
"github.com/echovault/echovault/src/echovault" "github.com/echovault/echovault/internal"
"github.com/echovault/echovault/src/utils" "github.com/echovault/echovault/pkg/echovault"
"github.com/echovault/echovault/pkg/utils"
"github.com/tidwall/resp" "github.com/tidwall/resp"
"net" "net"
"slices" "slices"
@@ -45,7 +46,7 @@ func init() {
} }
func setUpServer(bindAddr string, port uint16, requirePass bool, aclConfig string) *echovault.EchoVault { func setUpServer(bindAddr string, port uint16, requirePass bool, aclConfig string) *echovault.EchoVault {
config := utils.Config{ config := internal.Config{
BindAddr: bindAddr, BindAddr: bindAddr,
Port: port, Port: port,
DataDir: "", DataDir: "",

View File

@@ -18,7 +18,7 @@ import (
"context" "context"
"errors" "errors"
"fmt" "fmt"
"github.com/echovault/echovault/src/utils" "github.com/echovault/echovault/pkg/utils"
"github.com/gobwas/glob" "github.com/gobwas/glob"
"net" "net"
"slices" "slices"

View File

@@ -18,15 +18,16 @@ import (
"bytes" "bytes"
"context" "context"
"fmt" "fmt"
"github.com/echovault/echovault/src/echovault" "github.com/echovault/echovault/internal"
"github.com/echovault/echovault/src/utils" "github.com/echovault/echovault/pkg/echovault"
"github.com/echovault/echovault/pkg/utils"
"github.com/tidwall/resp" "github.com/tidwall/resp"
"testing" "testing"
) )
func Test_CommandsHandler(t *testing.T) { func Test_CommandsHandler(t *testing.T) {
mockServer := echovault.NewEchoVault( mockServer := echovault.NewEchoVault(
echovault.WithConfig(utils.Config{ echovault.WithConfig(internal.Config{
DataDir: "", DataDir: "",
EvictionPolicy: utils.NoEviction, EvictionPolicy: utils.NoEviction,
}), }),

View File

@@ -18,7 +18,7 @@ import (
"context" "context"
"errors" "errors"
"fmt" "fmt"
"github.com/echovault/echovault/src/utils" "github.com/echovault/echovault/pkg/utils"
"net" "net"
) )

View File

@@ -18,8 +18,9 @@ import (
"bytes" "bytes"
"context" "context"
"errors" "errors"
"github.com/echovault/echovault/src/echovault" "github.com/echovault/echovault/internal"
"github.com/echovault/echovault/src/utils" "github.com/echovault/echovault/pkg/echovault"
"github.com/echovault/echovault/pkg/utils"
"github.com/tidwall/resp" "github.com/tidwall/resp"
"testing" "testing"
) )
@@ -28,7 +29,7 @@ var mockServer *echovault.EchoVault
func init() { func init() {
mockServer = echovault.NewEchoVault( mockServer = echovault.NewEchoVault(
echovault.WithConfig(utils.Config{ echovault.WithConfig(internal.Config{
DataDir: "", DataDir: "",
EvictionPolicy: utils.NoEviction, EvictionPolicy: utils.NoEviction,
}), }),

View File

@@ -19,7 +19,7 @@ import (
"errors" "errors"
"flag" "flag"
"fmt" "fmt"
"github.com/echovault/echovault/src/utils" "github.com/echovault/echovault/pkg/utils"
"log" "log"
"net" "net"
"strconv" "strconv"

View File

@@ -19,8 +19,9 @@ import (
"context" "context"
"errors" "errors"
"fmt" "fmt"
"github.com/echovault/echovault/src/echovault" "github.com/echovault/echovault/internal"
"github.com/echovault/echovault/src/utils" "github.com/echovault/echovault/pkg/echovault"
"github.com/echovault/echovault/pkg/utils"
"github.com/tidwall/resp" "github.com/tidwall/resp"
"testing" "testing"
"time" "time"
@@ -30,7 +31,7 @@ var mockServer *echovault.EchoVault
func init() { func init() {
mockServer = echovault.NewEchoVault( mockServer = echovault.NewEchoVault(
echovault.WithConfig(utils.Config{ echovault.WithConfig(internal.Config{
DataDir: "", DataDir: "",
EvictionPolicy: utils.NoEviction, EvictionPolicy: utils.NoEviction,
}), }),

View File

@@ -16,7 +16,7 @@ package generic
import ( import (
"errors" "errors"
"github.com/echovault/echovault/src/utils" "github.com/echovault/echovault/pkg/utils"
) )
func setKeyFunc(cmd []string) ([]string, error) { func setKeyFunc(cmd []string) ([]string, error) {

View File

@@ -18,7 +18,7 @@ import (
"context" "context"
"errors" "errors"
"fmt" "fmt"
"github.com/echovault/echovault/src/utils" "github.com/echovault/echovault/pkg/utils"
"math/rand" "math/rand"
"net" "net"
"slices" "slices"

View File

@@ -19,8 +19,9 @@ import (
"context" "context"
"errors" "errors"
"fmt" "fmt"
"github.com/echovault/echovault/src/echovault" "github.com/echovault/echovault/internal"
"github.com/echovault/echovault/src/utils" "github.com/echovault/echovault/pkg/echovault"
"github.com/echovault/echovault/pkg/utils"
"github.com/tidwall/resp" "github.com/tidwall/resp"
"slices" "slices"
"testing" "testing"
@@ -30,7 +31,7 @@ var mockServer *echovault.EchoVault
func init() { func init() {
mockServer = echovault.NewEchoVault( mockServer = echovault.NewEchoVault(
echovault.WithConfig(utils.Config{ echovault.WithConfig(internal.Config{
DataDir: "", DataDir: "",
EvictionPolicy: utils.NoEviction, EvictionPolicy: utils.NoEviction,
}), }),

View File

@@ -16,7 +16,7 @@ package hash
import ( import (
"errors" "errors"
"github.com/echovault/echovault/src/utils" "github.com/echovault/echovault/pkg/utils"
) )
func hsetKeyFunc(cmd []string) ([]string, error) { func hsetKeyFunc(cmd []string) ([]string, error) {

View File

@@ -18,7 +18,7 @@ import (
"context" "context"
"errors" "errors"
"fmt" "fmt"
"github.com/echovault/echovault/src/utils" "github.com/echovault/echovault/pkg/utils"
"math" "math"
"net" "net"
"slices" "slices"

View File

@@ -19,8 +19,9 @@ import (
"context" "context"
"errors" "errors"
"fmt" "fmt"
"github.com/echovault/echovault/src/echovault" "github.com/echovault/echovault/internal"
"github.com/echovault/echovault/src/utils" "github.com/echovault/echovault/pkg/echovault"
"github.com/echovault/echovault/pkg/utils"
"github.com/tidwall/resp" "github.com/tidwall/resp"
"testing" "testing"
) )
@@ -29,7 +30,7 @@ var mockServer *echovault.EchoVault
func init() { func init() {
mockServer = echovault.NewEchoVault( mockServer = echovault.NewEchoVault(
echovault.WithConfig(utils.Config{ echovault.WithConfig(internal.Config{
DataDir: "", DataDir: "",
EvictionPolicy: utils.NoEviction, EvictionPolicy: utils.NoEviction,
}), }),

View File

@@ -16,7 +16,7 @@ package list
import ( import (
"errors" "errors"
"github.com/echovault/echovault/src/utils" "github.com/echovault/echovault/pkg/utils"
) )
func lpushKeyFunc(cmd []string) ([]string, error) { func lpushKeyFunc(cmd []string) ([]string, error) {

View File

@@ -18,7 +18,7 @@ import (
"context" "context"
"errors" "errors"
"fmt" "fmt"
"github.com/echovault/echovault/src/utils" "github.com/echovault/echovault/pkg/utils"
"net" "net"
"strings" "strings"
) )

View File

@@ -18,8 +18,9 @@ import (
"bytes" "bytes"
"context" "context"
"fmt" "fmt"
"github.com/echovault/echovault/src/echovault" "github.com/echovault/echovault/internal"
"github.com/echovault/echovault/src/utils" "github.com/echovault/echovault/pkg/echovault"
"github.com/echovault/echovault/pkg/utils"
"github.com/tidwall/resp" "github.com/tidwall/resp"
"net" "net"
"slices" "slices"
@@ -45,7 +46,7 @@ func setUpServer(pubsub *PubSub, bindAddr string, port uint16) *echovault.EchoVa
return echovault.NewEchoVault( return echovault.NewEchoVault(
echovault.WithPubSub(pubsub), echovault.WithPubSub(pubsub),
echovault.WithCommands(Commands()), echovault.WithCommands(Commands()),
echovault.WithConfig(utils.Config{ echovault.WithConfig(internal.Config{
BindAddr: bindAddr, BindAddr: bindAddr,
Port: port, Port: port,
DataDir: "", DataDir: "",

View File

@@ -18,7 +18,7 @@ import (
"context" "context"
"errors" "errors"
"fmt" "fmt"
"github.com/echovault/echovault/src/utils" "github.com/echovault/echovault/pkg/utils"
"net" "net"
"slices" "slices"
"strings" "strings"

View File

@@ -19,8 +19,9 @@ import (
"context" "context"
"errors" "errors"
"fmt" "fmt"
"github.com/echovault/echovault/src/echovault" "github.com/echovault/echovault/internal"
"github.com/echovault/echovault/src/utils" "github.com/echovault/echovault/pkg/echovault"
"github.com/echovault/echovault/pkg/utils"
"github.com/tidwall/resp" "github.com/tidwall/resp"
"slices" "slices"
"testing" "testing"
@@ -30,7 +31,7 @@ var mockServer *echovault.EchoVault
func init() { func init() {
mockServer = echovault.NewEchoVault( mockServer = echovault.NewEchoVault(
echovault.WithConfig(utils.Config{ echovault.WithConfig(internal.Config{
DataDir: "", DataDir: "",
EvictionPolicy: utils.NoEviction, EvictionPolicy: utils.NoEviction,
}), }),

View File

@@ -16,7 +16,7 @@ package set
import ( import (
"errors" "errors"
"github.com/echovault/echovault/src/utils" "github.com/echovault/echovault/pkg/utils"
"slices" "slices"
"strings" "strings"
) )

View File

@@ -15,7 +15,7 @@
package set package set
import ( import (
"github.com/echovault/echovault/src/utils" "github.com/echovault/echovault/pkg/utils"
"math/rand" "math/rand"
"slices" "slices"
) )

View File

@@ -19,7 +19,7 @@ import (
"context" "context"
"errors" "errors"
"fmt" "fmt"
"github.com/echovault/echovault/src/utils" "github.com/echovault/echovault/pkg/utils"
"math" "math"
"net" "net"
"slices" "slices"

View File

@@ -19,8 +19,9 @@ import (
"context" "context"
"errors" "errors"
"fmt" "fmt"
"github.com/echovault/echovault/src/echovault" "github.com/echovault/echovault/internal"
"github.com/echovault/echovault/src/utils" "github.com/echovault/echovault/pkg/echovault"
"github.com/echovault/echovault/pkg/utils"
"github.com/tidwall/resp" "github.com/tidwall/resp"
"math" "math"
"slices" "slices"
@@ -32,7 +33,7 @@ var mockServer *echovault.EchoVault
func init() { func init() {
mockServer = echovault.NewEchoVault( mockServer = echovault.NewEchoVault(
echovault.WithConfig(utils.Config{ echovault.WithConfig(internal.Config{
DataDir: "", DataDir: "",
EvictionPolicy: utils.NoEviction, EvictionPolicy: utils.NoEviction,
}), }),

View File

@@ -16,7 +16,7 @@ package sorted_set
import ( import (
"errors" "errors"
"github.com/echovault/echovault/src/utils" "github.com/echovault/echovault/pkg/utils"
"slices" "slices"
"strings" "strings"
) )

View File

@@ -17,7 +17,7 @@ package sorted_set
import ( import (
"cmp" "cmp"
"errors" "errors"
"github.com/echovault/echovault/src/utils" "github.com/echovault/echovault/pkg/utils"
"math" "math"
"math/rand" "math/rand"
"slices" "slices"

View File

@@ -18,7 +18,7 @@ import (
"context" "context"
"errors" "errors"
"fmt" "fmt"
"github.com/echovault/echovault/src/utils" "github.com/echovault/echovault/pkg/utils"
"net" "net"
) )

View File

@@ -19,8 +19,9 @@ import (
"context" "context"
"errors" "errors"
"fmt" "fmt"
"github.com/echovault/echovault/src/echovault" "github.com/echovault/echovault/internal"
"github.com/echovault/echovault/src/utils" "github.com/echovault/echovault/pkg/echovault"
"github.com/echovault/echovault/pkg/utils"
"github.com/tidwall/resp" "github.com/tidwall/resp"
"strconv" "strconv"
"testing" "testing"
@@ -30,7 +31,7 @@ var mockServer *echovault.EchoVault
func init() { func init() {
mockServer = echovault.NewEchoVault( mockServer = echovault.NewEchoVault(
echovault.WithConfig(utils.Config{ echovault.WithConfig(internal.Config{
DataDir: "", DataDir: "",
EvictionPolicy: utils.NoEviction, EvictionPolicy: utils.NoEviction,
}), }),

View File

@@ -16,7 +16,7 @@ package str
import ( import (
"errors" "errors"
"github.com/echovault/echovault/src/utils" "github.com/echovault/echovault/pkg/utils"
) )
func setRangeKeyFunc(cmd []string) ([]string, error) { func setRangeKeyFunc(cmd []string) ([]string, error) {

View File

@@ -16,14 +16,15 @@ package raft
import ( import (
"encoding/json" "encoding/json"
"github.com/echovault/echovault/src/utils" "github.com/echovault/echovault/internal"
"github.com/echovault/echovault/pkg/utils"
"github.com/hashicorp/raft" "github.com/hashicorp/raft"
"strconv" "strconv"
"strings" "strings"
) )
type SnapshotOpts struct { type SnapshotOpts struct {
config utils.Config config internal.Config
data map[string]utils.KeyData data map[string]utils.KeyData
startSnapshot func() startSnapshot func()
finishSnapshot func() finishSnapshot func()

View File

@@ -18,7 +18,8 @@ import (
"context" "context"
"encoding/json" "encoding/json"
"fmt" "fmt"
"github.com/echovault/echovault/src/utils" "github.com/echovault/echovault/internal"
"github.com/echovault/echovault/pkg/utils"
"github.com/hashicorp/raft" "github.com/hashicorp/raft"
"io" "io"
"log" "log"
@@ -26,7 +27,7 @@ import (
) )
type FSMOpts struct { type FSMOpts struct {
Config utils.Config Config internal.Config
EchoVault utils.EchoVault EchoVault utils.EchoVault
GetCommand func(command string) (utils.Command, error) GetCommand func(command string) (utils.Command, error)
DeleteKey func(ctx context.Context, key string) error DeleteKey func(ctx context.Context, key string) error

View File

@@ -18,20 +18,21 @@ import (
"context" "context"
"errors" "errors"
"fmt" "fmt"
"github.com/echovault/echovault/src/memberlist" "github.com/echovault/echovault/internal"
"github.com/echovault/echovault/pkg/memberlist"
"log" "log"
"net" "net"
"os" "os"
"path/filepath" "path/filepath"
"time" "time"
"github.com/echovault/echovault/src/utils" "github.com/echovault/echovault/pkg/utils"
"github.com/hashicorp/raft" "github.com/hashicorp/raft"
raftboltdb "github.com/hashicorp/raft-boltdb" raftboltdb "github.com/hashicorp/raft-boltdb"
) )
type Opts struct { type Opts struct {
Config utils.Config Config internal.Config
EchoVault utils.EchoVault EchoVault utils.EchoVault
GetCommand func(command string) (utils.Command, error) GetCommand func(command string) (utils.Command, error)
DeleteKey func(ctx context.Context, key string) error DeleteKey func(ctx context.Context, key string) error

View File

@@ -19,7 +19,7 @@ import (
"encoding/json" "encoding/json"
"errors" "errors"
"fmt" "fmt"
"github.com/echovault/echovault/src/utils" "github.com/echovault/echovault/pkg/utils"
"io" "io"
"io/fs" "io/fs"
"log" "log"