Removed --in-memory config flag. InMemory is now inferred from whether the data directory was provided.

This commit is contained in:
Kelvin Clement Mwinuka
2024-06-13 16:37:30 +08:00
parent 088900c803
commit 33d6651928
7 changed files with 402 additions and 1437 deletions

View File

@@ -27,7 +27,6 @@ CMD "./server" \
"--eviction-interval" "${EVICTION_INTERVAL}" \
"--tls=${TLS}" \
"--mtls=${MTLS}" \
"--in-memory=${IN_MEMORY}" \
"--bootstrap-cluster=${BOOTSTRAP_CLUSTER}" \
"--acl-config=${ACL_CONFIG}" \
"--require-pass=${REQUIRE_PASS}" \

File diff suppressed because it is too large Load Diff

View File

@@ -17,7 +17,6 @@ services:
- SERVER_ID=1
- PLUGIN_DIR=/usr/local/lib/echovault
- DATA_DIR=/var/lib/echovault
- IN_MEMORY=false
- TLS=false
- MTLS=false
- BOOTSTRAP_CLUSTER=false
@@ -65,7 +64,6 @@ services:
- SERVER_ID=1
- JOIN_ADDR=2/cluster_node_2:7946
- DATA_DIR=/var/lib/echovault
- IN_MEMORY=true
- TLS=false
- MTLS=false
- BOOTSTRAP_CLUSTER=true
@@ -112,7 +110,6 @@ services:
- SERVER_ID=2
- JOIN_ADDR=3/cluster_node_3:7946
- DATA_DIR=/var/lib/echovault
- IN_MEMORY=true
- TLS=false
- MTLS=false
- BOOTSTRAP_CLUSTER=false
@@ -159,7 +156,6 @@ services:
- SERVER_ID=3
- JOIN_ADDR=4/cluster_node_4:7946
- DATA_DIR=/var/lib/echovault
- IN_MEMORY=true
- TLS=false
- MTLS=false
- BOOTSTRAP_CLUSTER=false
@@ -206,7 +202,6 @@ services:
- SERVER_ID=4
- JOIN_ADDR=5/cluster_node_5:7946
- DATA_DIR=/var/lib/echovault
- IN_MEMORY=true
- TLS=false
- MTLS=false
- BOOTSTRAP_CLUSTER=false
@@ -253,7 +248,6 @@ services:
- SERVER_ID=5
- JOIN_ADDR=1/cluster_node_1:7946
- DATA_DIR=/var/lib/echovault
- IN_MEMORY=true
- TLS=false
- MTLS=false
- BOOTSTRAP_CLUSTER=false

View File

@@ -86,7 +86,6 @@ func setupServer(
conf.BindAddr = bindAddr
conf.JoinAddr = joinAddr
conf.Port = uint16(port)
conf.InMemory = true
conf.ServerID = serverId
conf.RaftBindPort = uint16(raftPort)
conf.MemberListBindPort = uint16(mlPort)

View File

@@ -42,7 +42,6 @@ type Config struct {
BindAddr string `json:"BindAddr" yaml:"BindAddr"`
RaftBindPort uint16 `json:"RaftPort" yaml:"RaftPort"`
MemberListBindPort uint16 `json:"MlPort" yaml:"MlPort"`
InMemory bool `json:"InMemory" yaml:"InMemory"`
DataDir string `json:"DataDir" yaml:"DataDir"`
BootstrapCluster bool `json:"BootstrapCluster" yaml:"BootstrapCluster"`
AclConfig string `json:"AclConfig" yaml:"AclConfig"`
@@ -152,8 +151,7 @@ There is no limit by default.`, func(memory string) error {
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.")
mlBindPort := flag.Uint("memberlist-port", 7946, "Port to use for memberlist communication.")
inMemory := flag.Bool("in-memory", false, "Whether to use memory or persistent storage for raft logs and snapshots.")
dataDir := flag.String("data-dir", "/var/lib/echovault", "Directory to store snapshots and logs.")
dataDir := flag.String("data-dir", ".", "Directory to store snapshots and logs.")
bootstrapCluster := flag.Bool("bootstrap-cluster", false, "Whether this instance should bootstrap a new cluster.")
aclConfig := flag.String("acl-config", "", "ACL config file path.")
snapshotThreshold := flag.Uint64("snapshot-threshold", 1000, "The number of entries that trigger a snapshot. Default is 1000.")
@@ -197,7 +195,6 @@ It is a plain text value by default but you can provide a SHA256 hash by adding
BindAddr: *bindAddr,
RaftBindPort: uint16(*raftBindPort),
MemberListBindPort: uint16(*mlBindPort),
InMemory: *inMemory,
DataDir: *dataDir,
BootstrapCluster: *bootstrapCluster,
AclConfig: *aclConfig,

View File

@@ -17,7 +17,6 @@ func DefaultConfig() Config {
BindAddr: "localhost",
RaftBindPort: 7481,
MemberListBindPort: 7946,
InMemory: false,
DataDir: ".",
BootstrapCluster: false,
AclConfig: "",

View File

@@ -67,7 +67,8 @@ func (r *Raft) RaftInit(ctx context.Context) {
var stableStore raft.StableStore
var snapshotStore raft.SnapshotStore
if conf.InMemory {
if conf.DataDir == "" {
// No data directory provided, use in memory stores.
logStore = raft.NewInmemStore()
stableStore = raft.NewInmemStore()
snapshotStore = raft.NewInmemSnapshotStore()