From 5e1e362b28134178beb9fd38f9e4141ea1ec0c7c Mon Sep 17 00:00:00 2001 From: Kelvin Clement Mwinuka Date: Sun, 25 Feb 2024 23:27:57 +0800 Subject: [PATCH] Updated flags from camelCase to kebab-case --- Dockerfile.dev | 39 ++++++++++++++++++++------------------- docker-compose.yaml | 6 ++++++ src/utils/config.go | 40 ++++++++++++++++++++-------------------- 3 files changed, 46 insertions(+), 39 deletions(-) diff --git a/Dockerfile.dev b/Dockerfile.dev index 230a7699..903d02e2 100644 --- a/Dockerfile.dev +++ b/Dockerfile.dev @@ -12,28 +12,29 @@ COPY ./openssl/client /etc/ssl/certs/echovault/client WORKDIR /opt/echovault/bin CMD "./server" \ - "--bindAddr" "${BIND_ADDR}" \ + "--bind-addr" "${BIND_ADDR}" \ "--port" "${PORT}" \ - "--mlPort" "${ML_PORT}" \ - "--raftPort" "${RAFT_PORT}" \ - "--serverId" "${SERVER_ID}" \ - "--joinAddr" "${JOIN_ADDR}" \ - "--pluginDir" "${PLUGIN_DIR}" \ - "--dataDir" "${DATA_DIR}" \ - "--snapshotThreshold" "${SNAPSHOT_THRESHOLD}" \ - "--snapshotInterval" "${SNAPSHOT_INTERVAL}" \ + "--memberlist-port" "${ML_PORT}" \ + "--raft-port" "${RAFT_PORT}" \ + "--server-id" "${SERVER_ID}" \ + "--join-addr" "${JOIN_ADDR}" \ + "--plugin-dir" "${PLUGIN_DIR}" \ + "--data-dir" "${DATA_DIR}" \ + "--snapshot-threshold" "${SNAPSHOT_THRESHOLD}" \ + "--snapshot-interval" "${SNAPSHOT_INTERVAL}" \ "--tls=${TLS}" \ "--mtls=${MTLS}" \ - "--inMemory=${IN_MEMORY}" \ - "--bootstrapCluster=${BOOTSTRAP_CLUSTER}" \ - "--aclConfig=${ACL_CONFIG}" \ - "--requirePass=${REQUIRE_PASS}" \ + "--in-memory=${IN_MEMORY}" \ + "--bootstrap-cluster=${BOOTSTRAP_CLUSTER}" \ + "--acl-config=${ACL_CONFIG}" \ + "--require-pass=${REQUIRE_PASS}" \ "--password=${PASSWORD}" \ - "--forwardCommand=${FORWARD_COMMAND}" \ - "--restoreSnapshot=${RESTORE_SNAPSHOT}" \ - "--restoreAOF=${RESTORE_AOF}" \ + "--forward-commands=${FORWARD_COMMAND}" \ + "--restore-snapshot=${RESTORE_SNAPSHOT}" \ + "--restore-aof=${RESTORE_AOF}" \ + "--aof-sync-strategy=${AOF_SYNC_STRATEGY}" \ # List of server cert/key pairs - "--certKeyPair=${CERT_KEY_PAIR_1}" \ - "--certKeyPair=${CERT_KEY_PAIR_2}" \ + "--cert-key-pair=${CERT_KEY_PAIR_1}" \ + "--cert-key-pair=${CERT_KEY_PAIR_2}" \ # List of client certs - "--clientCA=${CLIENT_CA_1}" \ + "--client-ca=${CLIENT_CA_1}" \ diff --git a/docker-compose.yaml b/docker-compose.yaml index a7f88e91..779bd2d1 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -29,6 +29,7 @@ services: - SNAPSHOT_INTERVAL=5m30s - RESTORE_SNAPSHOT=false - RESTORE_AOF=true + - AOF_SYNC_STRATEGY=everysec # List of server cert/key pairs - CERT_KEY_PAIR_1=/etc/ssl/certs/echovault/server/server1.crt,/etc/ssl/certs/echovault/server/server1.key - CERT_KEY_PAIR_2=/etc/ssl/certs/echovault/server/server2.crt,/etc/ssl/certs/echovault/server/server2.key @@ -69,6 +70,7 @@ services: - SNAPSHOT_INTERVAL=5m30s - RESTORE_SNAPSHOT=false - RESTORE_AOF=false + - AOF_SYNC_STRATEGY=everysec # List of server cert/key pairs - CERT_KEY_PAIR_1=/etc/ssl/certs/echovault/server/server1.crt,/etc/ssl/certs/echovault/server/server1.key - CERT_KEY_PAIR_2=/etc/ssl/certs/echovault/server/server2.crt,/etc/ssl/certs/echovault/server/server2.key @@ -110,6 +112,7 @@ services: - SNAPSHOT_INTERVAL=5m30s - RESTORE_SNAPSHOT=false - RESTORE_AOF=false + - AOF_SYNC_STRATEGY=everysec # List of server cert/key pairs - CERT_KEY_PAIR_1=/etc/ssl/certs/echovault/server/server1.crt,/etc/ssl/certs/echovault/server/server1.key - CERT_KEY_PAIR_2=/etc/ssl/certs/echovault/server/server2.crt,/etc/ssl/certs/echovault/server/server2.key @@ -151,6 +154,7 @@ services: - SNAPSHOT_INTERVAL=5m30s - RESTORE_SNAPSHOT=false - RESTORE_AOF=false + - AOF_SYNC_STRATEGY=everysec # List of server cert/key pairs - CERT_KEY_PAIR_1=/etc/ssl/certs/echovault/server/server1.crt,/etc/ssl/certs/echovault/server/server1.key - CERT_KEY_PAIR_2=/etc/ssl/certs/echovault/server/server2.crt,/etc/ssl/certs/echovault/server/server2.key @@ -192,6 +196,7 @@ services: - SNAPSHOT_INTERVAL=5m30s - RESTORE_SNAPSHOT=false - RESTORE_AOF=false + - AOF_SYNC_STRATEGY=everysec # List of server cert/key pairs - CERT_KEY_PAIR_1=/etc/ssl/certs/echovault/server/server1.crt,/etc/ssl/certs/echovault/server/server1.key - CERT_KEY_PAIR_2=/etc/ssl/certs/echovault/server/server2.crt,/etc/ssl/certs/echovault/server/server2.key @@ -233,6 +238,7 @@ services: - SNAPSHOT_INTERVAL=5m30s - RESTORE_SNAPSHOT=false - RESTORE_AOF=false + - AOF_SYNC_STRATEGY=everysec # List of server cert/key pairs - CERT_KEY_PAIR_1=/etc/ssl/certs/echovault/server/server1.crt,/etc/ssl/certs/echovault/server/server1.key - CERT_KEY_PAIR_2=/etc/ssl/certs/echovault/server/server2.crt,/etc/ssl/certs/echovault/server/server2.key diff --git a/src/utils/config.go b/src/utils/config.go index 0e4f722a..73c8ebca 100644 --- a/src/utils/config.go +++ b/src/utils/config.go @@ -44,7 +44,7 @@ func GetConfig() (Config, error) { var certKeyPairs [][]string var clientCAs []string - flag.Func("certKeyPair", + flag.Func("cert-key-pair", "A pair of file paths representing the signed certificate and it's corresponding key separated by a comma.", func(s string) error { pair := strings.Split(strings.TrimSpace(s), ",") @@ -58,13 +58,13 @@ func GetConfig() (Config, error) { return nil }) - flag.Func("clientCA", "Path to certificate authority used to verify client certificates.", func(s string) error { + flag.Func("client-ca", "Path to certificate authority used to verify client certificates.", func(s string) error { clientCAs = append(clientCAs, s) return nil }) - var aofSyncStrategy string = "everysec" - flag.Func("aofSyncStrategy", `How often to flush the file contents written to append only file. + aofSyncStrategy := "everysec" + flag.Func("aof-sync-strategy", `How often to flush the file contents written to append only file. The options are 'always' for syncing on each command, 'everysec' to sync every second, and 'no' to leave it up to the os.`, func(option string) error { if !slices.ContainsFunc([]string{"always", "everysec", "no"}, func(s string) bool { @@ -79,26 +79,26 @@ The options are 'always' for syncing on each command, 'everysec' to sync every s tls := flag.Bool("tls", false, "Start the server in TLS mode. Default is false") mtls := flag.Bool("mtls", false, "Use mTLS to verify the client.") port := flag.Int("port", 7480, "Port to use. Default is 7480") - pluginDir := flag.String("pluginDir", "", "Directory where plugins are located.") - serverId := flag.String("serverId", "1", "Server ID in raft cluster. Leave empty for client.") - joinAddr := flag.String("joinAddr", "", "Address of cluster member in a cluster to you want to join.") - bindAddr := flag.String("bindAddr", "", "Address to bind the server to.") - raftBindPort := flag.Uint("raftPort", 7481, "Port to use for intra-cluster communication. Leave on the client.") - mlBindPort := flag.Uint("mlPort", 7946, "Port to use for memberlist communication.") - inMemory := flag.Bool("inMemory", false, "Whether to use memory or persistent storage for raft logs and snapshots.") - dataDir := flag.String("dataDir", "/var/lib/memstore", "Directory to store raft snapshots and logs.") - bootstrapCluster := flag.Bool("bootstrapCluster", false, "Whether this instance should bootstrap a new cluster.") - aclConfig := flag.String("aclConfig", "", "ACL config file path.") - snapshotThreshold := flag.Uint64("snapshotThreshold", 1000, "The number of entries that trigger a snapshot. Default is 1000.") - snapshotInterval := flag.Duration("snapshotInterval", 5*time.Minute, "The time interval between snapshots (in seconds). Default is 5 minutes.") - restoreSnapshot := flag.Bool("restoreSnapshot", false, "This flag prompts the server to restore state from snapshot when set to true. Only works in standalone mode. Higher priority than restoreAOF.") - restoreAOF := flag.Bool("restoreAOF", false, "This flag prompts the server to restore state from append-only logs. Only works in standalone mode. Lower priority than restoreSnapshot.") + pluginDir := flag.String("plugin-dir", "", "Directory where plugins are located.") + serverId := flag.String("server-id", "1", "Server 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.") + bindAddr := flag.String("bind-addr", "", "Address to bind the server 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/memstore", "Directory to store raft 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.") + snapshotInterval := flag.Duration("snapshot-interval", 5*time.Minute, "The time interval between snapshots (in seconds). Default is 5 minutes.") + restoreSnapshot := flag.Bool("restore-snapshot", false, "This flag prompts the server to restore state from snapshot when set to true. Only works in standalone mode. Higher priority than restoreAOF.") + restoreAOF := flag.Bool("restore-aof", false, "This flag prompts the server to restore state from append-only logs. Only works in standalone mode. Lower priority than restoreSnapshot.") forwardCommand := flag.Bool( - "forwardCommand", + "forward-commands", false, "If the node is a follower, this flag forwards mutation command to the leader when set to true") requirePass := flag.Bool( - "requirePass", + "require-pass", false, "Whether the server should require a password before allowing commands. Default is false.", )