From 0e08349a52b39b47497212e149a67276d06c6416 Mon Sep 17 00:00:00 2001 From: vinitparekh17 Date: Thu, 19 Dec 2024 00:22:52 +0530 Subject: [PATCH] patch release to enhance conf and redundant WAL validation --- config/config.go | 16 ++++++++-------- config/validator.go | 23 +---------------------- dicedb.conf | 12 ++++++------ go.mod | 1 - go.sum | 2 -- 5 files changed, 15 insertions(+), 39 deletions(-) diff --git a/config/config.go b/config/config.go index ff8ee6fa3..70bd617f4 100644 --- a/config/config.go +++ b/config/config.go @@ -46,12 +46,12 @@ const ( # Version version = "0.1.0" -# Async Server Configuration -async_server.addr = "0.0.0.0" -async_server.port = 7379 -async_server.keepalive = 300 -async_server.timeout = 300 -async_server.max_conn = 0 +# RESP Server Configuration +resp_server.addr = "0.0.0.0" +resp_server.port = 7379 +resp_server.keepalive = 300 +resp_server.timeout = 300 +resp_server.max_conn = 0 # HTTP Configuration http.enabled = false @@ -127,7 +127,7 @@ type Config struct { Version string `config:"version" default:"0.1.0"` InstanceID string `config:"instance_id"` Auth auth `config:"auth"` - RespServer respServer `config:"async_server"` + RespServer respServer `config:"resp_server"` HTTP http `config:"http"` WebSocket websocket `config:"websocket"` Performance performance `config:"performance"` @@ -193,7 +193,7 @@ type persistence struct { type WALConfig struct { // Directory where WAL log files will be stored - LogDir string `config:"log_dir" default:"tmp/dicedb-wal"` + LogDir string `config:"log_dir" default:"tmp/dicedb-wal" validate:"dirpath,required"` // Whether WAL is enabled Enabled bool `config:"enabled" default:"true"` // WAL buffering mode: 'buffered' (writes buffered in memory) or 'unbuffered' (immediate disk writes) diff --git a/config/validator.go b/config/validator.go index 95872aad3..1f67275e6 100644 --- a/config/validator.go +++ b/config/validator.go @@ -59,7 +59,7 @@ func validateConfig(config *Config) error { func validateShardCount(sl validator.StructLevel) { config := sl.Current().Interface().(Config) if config.Performance.NumShards <= 0 && config.Performance.NumShards != -1 { - sl.ReportError(config.Performance.NumShards, "NumShards", "NumShards", "invalidValue", "must be -1 or greater than 0") + sl.ReportError(config.Performance.NumShards, "NumShards", "NumShards", "invalidValue", "use -1 for auto-sharding as per the number of CPUs or a positive integer") } } @@ -115,27 +115,6 @@ func applyDefaultValuesFromTags(config *Config, fieldName string) error { func validateWALConfig(sl validator.StructLevel) { config := sl.Current().Interface().(Config) - - // LogDir validation - if config.WAL.LogDir == "" { - sl.ReportError(config.WAL.LogDir, "LogDir", "LogDir", "required", "cannot be empty") - } - - // MaxSegmentSize validation - if config.WAL.MaxSegmentSizeMB <= 0 { - sl.ReportError(config.WAL.MaxSegmentSizeMB, "MaxSegmentSize", "MaxSegmentSize", "gt", "must be greater than 0") - } - - // MaxSegmentCount validation - if config.WAL.MaxSegmentCount <= 0 { - sl.ReportError(config.WAL.MaxSegmentCount, "MaxSegmentCount", "MaxSegmentCount", "gt", "must be greater than 0") - } - - // BufferSize validation - if config.WAL.BufferSizeMB <= 0 { - sl.ReportError(config.WAL.BufferSizeMB, "BufferSize", "BufferSize", "gt", "must be greater than 0") - } - // WALMode and WriteMode compatibility checks if config.WAL.WalMode == "buffered" && config.WAL.WriteMode == "fsync" { sl.ReportError(config.WAL.WalMode, "WALMode", "WALMode", "incompatible", "walMode 'buffered' cannot be used with writeMode 'fsync'") diff --git a/dicedb.conf b/dicedb.conf index af4759337..0f8add99a 100644 --- a/dicedb.conf +++ b/dicedb.conf @@ -3,12 +3,12 @@ # Version version = "0.1.0" -# Async Server Configuration -async_server.addr = "0.0.0.0" -async_server.port = 7379 -async_server.keepalive = 300 -async_server.timeout = 300 -async_server.max_conn = 0 +# RESP Server Configuration +resp_server.addr = "0.0.0.0" +resp_server.port = 7379 +resp_server.keepalive = 300 +resp_server.timeout = 300 +resp_server.max_conn = 0 # HTTP Configuration http.enabled = false diff --git a/go.mod b/go.mod index dcf33b828..5d91d2165 100644 --- a/go.mod +++ b/go.mod @@ -49,7 +49,6 @@ require ( github.com/rs/zerolog v1.33.0 github.com/stretchr/testify v1.9.0 github.com/twmb/murmur3 v1.1.8 - github.com/xwb1989/sqlparser v0.0.0-20180606152119-120387863bf2 golang.org/x/crypto v0.29.0 golang.org/x/exp v0.0.0-20241108190413-2d47ceb2692f google.golang.org/protobuf v1.35.1 diff --git a/go.sum b/go.sum index 51567b272..8afad6d1c 100644 --- a/go.sum +++ b/go.sum @@ -103,8 +103,6 @@ github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08= github.com/twmb/murmur3 v1.1.8 h1:8Yt9taO/WN3l08xErzjeschgZU2QSrwm1kclYq+0aRg= github.com/twmb/murmur3 v1.1.8/go.mod h1:Qq/R7NUyOfr65zD+6Q5IHKsJLwP7exErjN6lyyq3OSQ= -github.com/xwb1989/sqlparser v0.0.0-20180606152119-120387863bf2 h1:zzrxE1FKn5ryBNl9eKOeqQ58Y/Qpo3Q9QNxKHX5uzzQ= -github.com/xwb1989/sqlparser v0.0.0-20180606152119-120387863bf2/go.mod h1:hzfGeIUDq/j97IG+FhNqkowIyEcD88LrW6fyU3K3WqY= golang.org/x/arch v0.11.0 h1:KXV8WWKCXm6tRpLirl2szsO5j/oOODwZf4hATmGVNs4= golang.org/x/arch v0.11.0/go.mod h1:FEVrYAQjsQXMVJ1nsMoVVXPZg6p2JE2mx8psSWTDQys= golang.org/x/crypto v0.29.0 h1:L5SG1JTTXupVV3n6sUqMTeWbjAyfPwoda2DLX8J8FrQ=