From b4ebdb6c4743ee1da2dd61c47972e52c0002e067 Mon Sep 17 00:00:00 2001 From: Abhijeet Singh Date: Fri, 4 Apr 2025 02:44:52 +0530 Subject: [PATCH 1/3] server configs in doc website --- config/config.go | 54 ++++++++--------- docs/astro.config.mjs | 4 ++ docs/src/content/docs/commands/GETSET.md | 34 +++++++++++ docs/src/content/docs/commands/HANDSHAKE.md | 4 +- docs/src/content/docs/commands/HGET.WATCH.md | 43 +++++++++++++ docs/src/content/docs/commands/KEYS.md | 40 +++++++++++++ docs/src/content/docs/commands/ZADD.md | 36 +++++++++++ .../content/docs/server-configs/EnableWAL.md | 35 +++++++++++ .../docs/server-configs/EnableWatch.md | 35 +++++++++++ .../src/content/docs/server-configs/Engine.md | 41 +++++++++++++ docs/src/content/docs/server-configs/Host.md | 35 +++++++++++ .../content/docs/server-configs/LogLevel.md | 35 +++++++++++ .../content/docs/server-configs/MaxClients.md | 35 +++++++++++ .../content/docs/server-configs/NumShards.md | 35 +++++++++++ .../content/docs/server-configs/Password.md | 30 ++++++++++ docs/src/content/docs/server-configs/Port.md | 35 +++++++++++ .../content/docs/server-configs/Username.md | 35 +++++++++++ .../docs/server-configs/WALBufferSizeMB.md | 35 +++++++++++ .../WALBufferSyncIntervalMillis.md | 35 +++++++++++ .../src/content/docs/server-configs/WALDir.md | 35 +++++++++++ .../docs/server-configs/WALMaxSegmentCount.md | 35 +++++++++++ .../WALMaxSegmentRetentionDurationSec.md | 35 +++++++++++ .../WALMaxSegmentRotationTimeSec.md | 35 +++++++++++ .../server-configs/WALMaxSegmentSizeMB.md | 35 +++++++++++ .../content/docs/server-configs/WALMode.md | 42 +++++++++++++ .../docs/server-configs/WALRecoveryMode.md | 43 +++++++++++++ .../docs/server-configs/WALRetentionMode.md | 43 +++++++++++++ .../docs/server-configs/WALRotationMode.md | 42 +++++++++++++ .../docs/server-configs/WALWriteMode.md | 42 +++++++++++++ scripts/generate-docs/main.go | 60 +++++++++++++++++++ scripts/generate-docs/server-config.tmpl | 41 +++++++++++++ 31 files changed, 1096 insertions(+), 28 deletions(-) create mode 100644 docs/src/content/docs/commands/GETSET.md create mode 100644 docs/src/content/docs/commands/HGET.WATCH.md create mode 100644 docs/src/content/docs/commands/KEYS.md create mode 100644 docs/src/content/docs/commands/ZADD.md create mode 100644 docs/src/content/docs/server-configs/EnableWAL.md create mode 100644 docs/src/content/docs/server-configs/EnableWatch.md create mode 100644 docs/src/content/docs/server-configs/Engine.md create mode 100644 docs/src/content/docs/server-configs/Host.md create mode 100644 docs/src/content/docs/server-configs/LogLevel.md create mode 100644 docs/src/content/docs/server-configs/MaxClients.md create mode 100644 docs/src/content/docs/server-configs/NumShards.md create mode 100644 docs/src/content/docs/server-configs/Password.md create mode 100644 docs/src/content/docs/server-configs/Port.md create mode 100644 docs/src/content/docs/server-configs/Username.md create mode 100644 docs/src/content/docs/server-configs/WALBufferSizeMB.md create mode 100644 docs/src/content/docs/server-configs/WALBufferSyncIntervalMillis.md create mode 100644 docs/src/content/docs/server-configs/WALDir.md create mode 100644 docs/src/content/docs/server-configs/WALMaxSegmentCount.md create mode 100644 docs/src/content/docs/server-configs/WALMaxSegmentRetentionDurationSec.md create mode 100644 docs/src/content/docs/server-configs/WALMaxSegmentRotationTimeSec.md create mode 100644 docs/src/content/docs/server-configs/WALMaxSegmentSizeMB.md create mode 100644 docs/src/content/docs/server-configs/WALMode.md create mode 100644 docs/src/content/docs/server-configs/WALRecoveryMode.md create mode 100644 docs/src/content/docs/server-configs/WALRetentionMode.md create mode 100644 docs/src/content/docs/server-configs/WALRotationMode.md create mode 100644 docs/src/content/docs/server-configs/WALWriteMode.md create mode 100644 scripts/generate-docs/server-config.tmpl diff --git a/config/config.go b/config/config.go index b35881384..6d42d235b 100644 --- a/config/config.go +++ b/config/config.go @@ -47,33 +47,33 @@ func init() { var Config *DiceDBConfig type DiceDBConfig struct { - Host string `mapstructure:"host" default:"0.0.0.0" description:"the host address to bind to"` - Port int `mapstructure:"port" default:"7379" description:"the port to bind to"` - - Username string `mapstructure:"username" default:"dicedb" description:"the username to use for authentication"` - Password string `mapstructure:"password" default:"" description:"the password to use for authentication"` - - LogLevel string `mapstructure:"log-level" default:"info" description:"the log level"` - - EnableWatch bool `mapstructure:"enable-watch" default:"false" description:"enable support for .WATCH commands and real-time reactivity"` - MaxClients int `mapstructure:"max-clients" default:"20000" description:"the maximum number of clients to accept"` - NumShards int `mapstructure:"num-shards" default:"-1" description:"number of shards to create. defaults to number of cores"` - - Engine string `mapstructure:"engine" default:"ironhawk" description:"the engine to use, values: ironhawk"` - - EnableWAL bool `mapstructure:"enable-wal" default:"false" description:"enable write-ahead logging"` - WALDir string `mapstructure:"wal-dir" default:"/var/log/dicedb" description:"the directory to store WAL segments"` - WALMode string `mapstructure:"wal-mode" default:"buffered" description:"wal mode to use, values: buffered, unbuffered"` - WALWriteMode string `mapstructure:"wal-write-mode" default:"default" description:"wal file write mode to use, values: default, fsync"` - WALBufferSizeMB int `mapstructure:"wal-buffer-size-mb" default:"1" description:"the size of the wal write buffer in megabytes"` - WALRotationMode string `mapstructure:"wal-rotation-mode" default:"segment-size" description:"wal rotation mode to use, values: segment-size, time"` - WALMaxSegmentSizeMB int `mapstructure:"wal-max-segment-size-mb" default:"16" description:"the maximum size of a wal segment file in megabytes before rotation"` - WALMaxSegmentRotationTimeSec int `mapstructure:"wal-max-segment-rotation-time-sec" default:"60" description:"the time interval (in seconds) after which wal a segment is rotated"` - WALBufferSyncIntervalMillis int `mapstructure:"wal-buffer-sync-interval-ms" default:"200" description:"the interval (in milliseconds) at which the wal write buffer is synced to disk"` - WALRetentionMode string `mapstructure:"wal-retention-mode" default:"num-segments" description:"the new horizon for wal segment post cleanup. values: num-segments, time, checkpoint"` - WALMaxSegmentCount int `mapstructure:"wal-max-segment-count" default:"10" description:"the maximum number of segments to retain, if the retention mode is 'num-segments'"` - WALMaxSegmentRetentionDurationSec int `mapstructure:"wal-max-segment-retention-duration-sec" default:"600" description:"the maximum duration (in seconds) for wal segments retention"` - WALRecoveryMode string `mapstructure:"wal-recovery-mode" default:"strict" description:"wal recovery mode in case of a corruption, values: strict, truncate, ignore"` + Host string `mapstructure:"host" default:"0.0.0.0" description:"The host address to Bind to"` + Port int `mapstructure:"port" default:"7379" description:"The port to bind to"` + + Username string `mapstructure:"username" default:"dicedb" description:"The username to use for authentication"` + Password string `mapstructure:"password" default:"" description:"The password to use for authentication"` + + LogLevel string `mapstructure:"log-level" default:"info" description:"The log level"` + + EnableWatch bool `mapstructure:"enable-watch" default:"false" description:"Enable support for .WATCH commands and real-time reactivity"` + MaxClients int `mapstructure:"max-clients" default:"20000" description:"The maximum number of clients to accept"` + NumShards int `mapstructure:"num-shards" default:"-1" description:"Number of shards to create. defaults to number of cores"` + + Engine string `mapstructure:"engine" default:"ironhawk" description:"The engine to use" values:"ironhawk"` + + EnableWAL bool `mapstructure:"enable-wal" default:"false" description:"Enable write-ahead logging"` + WALDir string `mapstructure:"wal-dir" default:"/var/log/dicedb" description:"The directory to store WAL segments"` + WALMode string `mapstructure:"wal-mode" default:"buffered" description:"WAL mode to use" values:"buffered, unbuffered"` + WALWriteMode string `mapstructure:"wal-write-mode" default:"default" description:"WAL write mode to use" values:"default, fsync"` + WALBufferSizeMB int `mapstructure:"wal-buffer-size-mb" default:"1" description:"The size of the WAL write buffer in megabytes"` + WALRotationMode string `mapstructure:"wal-rotation-mode" default:"segment-size" description:"WAL rotation mode to use" values:"segment-size, time"` + WALMaxSegmentSizeMB int `mapstructure:"wal-max-segment-size-mb" default:"16" description:"The maximum size of a WAL segment file in megabytes before rotation"` + WALMaxSegmentRotationTimeSec int `mapstructure:"wal-max-segment-rotation-time-sec" default:"60" description:"The time interval (in seconds) after which WAL a segment is rotated"` + WALBufferSyncIntervalMillis int `mapstructure:"wal-buffer-sync-interval-ms" default:"200" description:"The interval (in milliseconds) at which The WAL write buffer is synced to disk"` + WALRetentionMode string `mapstructure:"wal-retention-mode" default:"num-segments" description:"The new horizon for WAL segment post cleanup" values:"num-segments, time, checkpoint"` + WALMaxSegmentCount int `mapstructure:"wal-max-segment-count" default:"10" description:"The maximum number of segments to retain, if The retention mode is 'num-segments'"` + WALMaxSegmentRetentionDurationSec int `mapstructure:"wal-max-segment-retention-duration-sec" default:"600" description:"The maximum duration (in seconds) for WAL segments retention"` + WALRecoveryMode string `mapstructure:"wal-recovery-mode" default:"strict" description:"WAL recovery mode in case of a corruption" values:"strict, truncate, ignore"` } func Load(flags *pflag.FlagSet) { diff --git a/docs/astro.config.mjs b/docs/astro.config.mjs index 32f8e5bd8..230b71b34 100644 --- a/docs/astro.config.mjs +++ b/docs/astro.config.mjs @@ -33,6 +33,10 @@ export default defineConfig({ label: "Get started", autogenerate: { directory: "get-started" }, }, + { + label: "Server Configuration", + autogenerate: { directory: "server-configs" }, + }, { label: "SDK", autogenerate: { directory: "sdk" }, diff --git a/docs/src/content/docs/commands/GETSET.md b/docs/src/content/docs/commands/GETSET.md new file mode 100644 index 000000000..a2c494d12 --- /dev/null +++ b/docs/src/content/docs/commands/GETSET.md @@ -0,0 +1,34 @@ +--- +title: GETSET +description: GETSET sets the value for the key and returns the old value +--- + + + +#### Syntax + +``` +GETSET key value +``` + + +GETSET sets the value for the key and returns the old value. + +The command returns (nil) if the key does not exist. + + +#### Examples + +``` + +localhost:7379> SET k1 v1 +OK OK +localhost:7379> GETSET k1 v2 +OK v1 +localhost:7379> GET k1 +OK v2 + +``` diff --git a/docs/src/content/docs/commands/HANDSHAKE.md b/docs/src/content/docs/commands/HANDSHAKE.md index c19528f75..6dec6e603 100644 --- a/docs/src/content/docs/commands/HANDSHAKE.md +++ b/docs/src/content/docs/commands/HANDSHAKE.md @@ -14,6 +14,7 @@ description: HANDSHAKE tells the server the purpose of the connection HANDSHAKE client_id execution_mode ``` + HANDSHAKE is used to tell the DiceDB server the purpose of the connection. It registers the client_id and execution_mode. @@ -27,6 +28,7 @@ The execution_mode is the mode of the connection, it can be one of the following If you use DiceDB SDK or CLI then this HANDSHAKE command is automatically sent when the connection is established or when you establish a subscription. + #### Examples @@ -34,5 +36,5 @@ or when you establish a subscription. localhost:7379> HANDSHAKE 4c9d0411-6b28-4ee5-b78a-e7e258afa52f command OK OK - + ``` diff --git a/docs/src/content/docs/commands/HGET.WATCH.md b/docs/src/content/docs/commands/HGET.WATCH.md new file mode 100644 index 000000000..ea817641a --- /dev/null +++ b/docs/src/content/docs/commands/HGET.WATCH.md @@ -0,0 +1,43 @@ +--- +title: HGET.WATCH +description: HGET.WATCH creates a query subscription over the HGET command +--- + + + +#### Syntax + +``` +HGET.WATCH key field +``` + + +HGET.WATCH creates a query subscription over the HGET command. The client invoking the command +will receive the output of the HGET command (not just the notification) whenever the value against +the key and field is updated. + +You can update the key in any other client. The HGET.WATCH client will receive the updated value. + + +#### Examples + +``` + +client1:7379> HSET k1 f1 v1 +OK 1 +client1:7379> HGET.WATCH k1 f1 +entered the watch mode for HGET.WATCH k1 f1 + + +client2:7379> HSET k1 f1 v2 +OK 0 + + +client1:7379> ... +entered the watch mode for HGET.WATCH k1 f1 +OK [fingerprint=3432795955] v2 + +``` diff --git a/docs/src/content/docs/commands/KEYS.md b/docs/src/content/docs/commands/KEYS.md new file mode 100644 index 000000000..872ad74f9 --- /dev/null +++ b/docs/src/content/docs/commands/KEYS.md @@ -0,0 +1,40 @@ +--- +title: KEYS +description: KEYS returns all keys matching the pattern +--- + + + +#### Syntax + +``` +KEYS pattern +``` + + +KEYS returns all keys matching the pattern. + +The pattern can contain the following special characters to match multiple keys. +Supports glob-style patterns: +- *: matches any sequence of characters +- ?: matches any single character + +#### Examples + +``` + +localhost:7379> SET k1 v1 +OK OK +localhost:7379> SET k2 v2 +OK OK +localhost:7379> KEYS k? +OK k1 k2 +localhost:7379> KEYS k* +OK k1 k2 +localhost:7379> KEYS * +OK k1 k2 + +``` diff --git a/docs/src/content/docs/commands/ZADD.md b/docs/src/content/docs/commands/ZADD.md new file mode 100644 index 000000000..c964a2869 --- /dev/null +++ b/docs/src/content/docs/commands/ZADD.md @@ -0,0 +1,36 @@ +--- +title: ZADD +description: Adds all the specified members with the specified scores to the sorted set stored at key +--- + + + +#### Syntax + +``` +ZADD key [NX | XX] [GT | LT] [CH] [INCR] score member [score member...] +``` + + +Adds all the specified members with the specified scores to the sorted set stored at key +Options: NX, XX, CH, INCR, GT, LT, CH +- NX: Only add new elements and do not update existing elements +- XX: Only update existing elements and do not add new elements +- CH: Modify the return value from the number of new elements added, to the total number of elements changed +- INCR: When this option is specified, the elements are treated as increments to the score of the existing elements +- GT: Only add new elements if the score is greater than the existing score +- LT: Only add new elements if the score is less than the existing score +Returns the number of elements added to the sorted set, not including elements already existing for which the score was updated. + + +#### Examples + +``` + +localhost:7379> ZADD mySortedSet 1 foo 2 bar +OK 2 + +``` diff --git a/docs/src/content/docs/server-configs/EnableWAL.md b/docs/src/content/docs/server-configs/EnableWAL.md new file mode 100644 index 000000000..5d5034f1c --- /dev/null +++ b/docs/src/content/docs/server-configs/EnableWAL.md @@ -0,0 +1,35 @@ +--- +title: EnableWAL +description: Enable write-ahead logging +sidebar: + order: 9 +--- + + + +#### Description + +Enable write-ahead logging + +#### CLI Command + +``` +--enable-wal false +``` + + +#### Default Value +``` +false +``` + + + + +#### Data Type +``` +Boolean +``` diff --git a/docs/src/content/docs/server-configs/EnableWatch.md b/docs/src/content/docs/server-configs/EnableWatch.md new file mode 100644 index 000000000..68d7d9fa2 --- /dev/null +++ b/docs/src/content/docs/server-configs/EnableWatch.md @@ -0,0 +1,35 @@ +--- +title: EnableWatch +description: Enable support for .WATCH commands and real-time reactivity +sidebar: + order: 5 +--- + + + +#### Description + +Enable support for .WATCH commands and real-time reactivity + +#### CLI Command + +``` +--enable-watch false +``` + + +#### Default Value +``` +false +``` + + + + +#### Data Type +``` +Boolean +``` diff --git a/docs/src/content/docs/server-configs/Engine.md b/docs/src/content/docs/server-configs/Engine.md new file mode 100644 index 000000000..1ec92d5c9 --- /dev/null +++ b/docs/src/content/docs/server-configs/Engine.md @@ -0,0 +1,41 @@ +--- +title: Engine +description: The engine to use +sidebar: + order: 8 +--- + + + +#### Description + +The engine to use + +#### CLI Command + +``` +--engine ironhawk +``` + + +#### Default Value +``` +ironhawk +``` + + + +#### Possible Values +``` +- ironhawk + +``` + + +#### Data Type +``` +String +``` diff --git a/docs/src/content/docs/server-configs/Host.md b/docs/src/content/docs/server-configs/Host.md new file mode 100644 index 000000000..e0426c2bc --- /dev/null +++ b/docs/src/content/docs/server-configs/Host.md @@ -0,0 +1,35 @@ +--- +title: Host +description: The host address to Bind to +sidebar: + order: 0 +--- + + + +#### Description + +The host address to Bind to + +#### CLI Command + +``` +--host 0.0.0.0 +``` + + +#### Default Value +``` +0.0.0.0 +``` + + + + +#### Data Type +``` +String +``` diff --git a/docs/src/content/docs/server-configs/LogLevel.md b/docs/src/content/docs/server-configs/LogLevel.md new file mode 100644 index 000000000..c531d4d67 --- /dev/null +++ b/docs/src/content/docs/server-configs/LogLevel.md @@ -0,0 +1,35 @@ +--- +title: LogLevel +description: The log level +sidebar: + order: 4 +--- + + + +#### Description + +The log level + +#### CLI Command + +``` +--log-level info +``` + + +#### Default Value +``` +info +``` + + + + +#### Data Type +``` +String +``` diff --git a/docs/src/content/docs/server-configs/MaxClients.md b/docs/src/content/docs/server-configs/MaxClients.md new file mode 100644 index 000000000..4e0110831 --- /dev/null +++ b/docs/src/content/docs/server-configs/MaxClients.md @@ -0,0 +1,35 @@ +--- +title: MaxClients +description: The maximum number of clients to accept +sidebar: + order: 6 +--- + + + +#### Description + +The maximum number of clients to accept + +#### CLI Command + +``` +--max-clients 20000 +``` + + +#### Default Value +``` +20000 +``` + + + + +#### Data Type +``` +Integer +``` diff --git a/docs/src/content/docs/server-configs/NumShards.md b/docs/src/content/docs/server-configs/NumShards.md new file mode 100644 index 000000000..5e48bb872 --- /dev/null +++ b/docs/src/content/docs/server-configs/NumShards.md @@ -0,0 +1,35 @@ +--- +title: NumShards +description: Number of shards to create. defaults to number of cores +sidebar: + order: 7 +--- + + + +#### Description + +Number of shards to create. defaults to number of cores + +#### CLI Command + +``` +--num-shards -1 +``` + + +#### Default Value +``` +-1 +``` + + + + +#### Data Type +``` +Integer +``` diff --git a/docs/src/content/docs/server-configs/Password.md b/docs/src/content/docs/server-configs/Password.md new file mode 100644 index 000000000..b13ca7099 --- /dev/null +++ b/docs/src/content/docs/server-configs/Password.md @@ -0,0 +1,30 @@ +--- +title: Password +description: The password to use for authentication +sidebar: + order: 3 +--- + + + +#### Description + +The password to use for authentication + +#### CLI Command + +``` +--password +``` + + + + + +#### Data Type +``` +String +``` diff --git a/docs/src/content/docs/server-configs/Port.md b/docs/src/content/docs/server-configs/Port.md new file mode 100644 index 000000000..8cd350941 --- /dev/null +++ b/docs/src/content/docs/server-configs/Port.md @@ -0,0 +1,35 @@ +--- +title: Port +description: The port to bind to +sidebar: + order: 1 +--- + + + +#### Description + +The port to bind to + +#### CLI Command + +``` +--port 7379 +``` + + +#### Default Value +``` +7379 +``` + + + + +#### Data Type +``` +Integer +``` diff --git a/docs/src/content/docs/server-configs/Username.md b/docs/src/content/docs/server-configs/Username.md new file mode 100644 index 000000000..b7dc26c5f --- /dev/null +++ b/docs/src/content/docs/server-configs/Username.md @@ -0,0 +1,35 @@ +--- +title: Username +description: The username to use for authentication +sidebar: + order: 2 +--- + + + +#### Description + +The username to use for authentication + +#### CLI Command + +``` +--username dicedb +``` + + +#### Default Value +``` +dicedb +``` + + + + +#### Data Type +``` +String +``` diff --git a/docs/src/content/docs/server-configs/WALBufferSizeMB.md b/docs/src/content/docs/server-configs/WALBufferSizeMB.md new file mode 100644 index 000000000..c7d4e1ea8 --- /dev/null +++ b/docs/src/content/docs/server-configs/WALBufferSizeMB.md @@ -0,0 +1,35 @@ +--- +title: WALBufferSizeMB +description: The size of the WAL write buffer in megabytes +sidebar: + order: 13 +--- + + + +#### Description + +The size of the WAL write buffer in megabytes + +#### CLI Command + +``` +--wal-buffer-size-mb 1 +``` + + +#### Default Value +``` +1 +``` + + + + +#### Data Type +``` +Integer +``` diff --git a/docs/src/content/docs/server-configs/WALBufferSyncIntervalMillis.md b/docs/src/content/docs/server-configs/WALBufferSyncIntervalMillis.md new file mode 100644 index 000000000..0b1373c80 --- /dev/null +++ b/docs/src/content/docs/server-configs/WALBufferSyncIntervalMillis.md @@ -0,0 +1,35 @@ +--- +title: WALBufferSyncIntervalMillis +description: The interval (in milliseconds) at which The WAL write buffer is synced to disk +sidebar: + order: 17 +--- + + + +#### Description + +The interval (in milliseconds) at which The WAL write buffer is synced to disk + +#### CLI Command + +``` +--wal-buffer-sync-interval-ms 200 +``` + + +#### Default Value +``` +200 +``` + + + + +#### Data Type +``` +Integer +``` diff --git a/docs/src/content/docs/server-configs/WALDir.md b/docs/src/content/docs/server-configs/WALDir.md new file mode 100644 index 000000000..9d4af4753 --- /dev/null +++ b/docs/src/content/docs/server-configs/WALDir.md @@ -0,0 +1,35 @@ +--- +title: WALDir +description: The directory to store WAL segments +sidebar: + order: 10 +--- + + + +#### Description + +The directory to store WAL segments + +#### CLI Command + +``` +--wal-dir /var/log/dicedb +``` + + +#### Default Value +``` +/var/log/dicedb +``` + + + + +#### Data Type +``` +String +``` diff --git a/docs/src/content/docs/server-configs/WALMaxSegmentCount.md b/docs/src/content/docs/server-configs/WALMaxSegmentCount.md new file mode 100644 index 000000000..5fea74c83 --- /dev/null +++ b/docs/src/content/docs/server-configs/WALMaxSegmentCount.md @@ -0,0 +1,35 @@ +--- +title: WALMaxSegmentCount +description: The maximum number of segments to retain, if The retention mode is 'num-segments' +sidebar: + order: 19 +--- + + + +#### Description + +The maximum number of segments to retain, if The retention mode is 'num-segments' + +#### CLI Command + +``` +--wal-max-segment-count 10 +``` + + +#### Default Value +``` +10 +``` + + + + +#### Data Type +``` +Integer +``` diff --git a/docs/src/content/docs/server-configs/WALMaxSegmentRetentionDurationSec.md b/docs/src/content/docs/server-configs/WALMaxSegmentRetentionDurationSec.md new file mode 100644 index 000000000..d20e4c40d --- /dev/null +++ b/docs/src/content/docs/server-configs/WALMaxSegmentRetentionDurationSec.md @@ -0,0 +1,35 @@ +--- +title: WALMaxSegmentRetentionDurationSec +description: The maximum duration (in seconds) for WAL segments retention +sidebar: + order: 20 +--- + + + +#### Description + +The maximum duration (in seconds) for WAL segments retention + +#### CLI Command + +``` +--wal-max-segment-retention-duration-sec 600 +``` + + +#### Default Value +``` +600 +``` + + + + +#### Data Type +``` +Integer +``` diff --git a/docs/src/content/docs/server-configs/WALMaxSegmentRotationTimeSec.md b/docs/src/content/docs/server-configs/WALMaxSegmentRotationTimeSec.md new file mode 100644 index 000000000..cb770e635 --- /dev/null +++ b/docs/src/content/docs/server-configs/WALMaxSegmentRotationTimeSec.md @@ -0,0 +1,35 @@ +--- +title: WALMaxSegmentRotationTimeSec +description: The time interval (in seconds) after which WAL a segment is rotated +sidebar: + order: 16 +--- + + + +#### Description + +The time interval (in seconds) after which WAL a segment is rotated + +#### CLI Command + +``` +--wal-max-segment-rotation-time-sec 60 +``` + + +#### Default Value +``` +60 +``` + + + + +#### Data Type +``` +Integer +``` diff --git a/docs/src/content/docs/server-configs/WALMaxSegmentSizeMB.md b/docs/src/content/docs/server-configs/WALMaxSegmentSizeMB.md new file mode 100644 index 000000000..abf9508fd --- /dev/null +++ b/docs/src/content/docs/server-configs/WALMaxSegmentSizeMB.md @@ -0,0 +1,35 @@ +--- +title: WALMaxSegmentSizeMB +description: The maximum size of a WAL segment file in megabytes before rotation +sidebar: + order: 15 +--- + + + +#### Description + +The maximum size of a WAL segment file in megabytes before rotation + +#### CLI Command + +``` +--wal-max-segment-size-mb 16 +``` + + +#### Default Value +``` +16 +``` + + + + +#### Data Type +``` +Integer +``` diff --git a/docs/src/content/docs/server-configs/WALMode.md b/docs/src/content/docs/server-configs/WALMode.md new file mode 100644 index 000000000..3c8a8924f --- /dev/null +++ b/docs/src/content/docs/server-configs/WALMode.md @@ -0,0 +1,42 @@ +--- +title: WALMode +description: WAL mode to use +sidebar: + order: 11 +--- + + + +#### Description + +WAL mode to use + +#### CLI Command + +``` +--wal-mode buffered +``` + + +#### Default Value +``` +buffered +``` + + + +#### Possible Values +``` +- buffered +- unbuffered + +``` + + +#### Data Type +``` +String +``` diff --git a/docs/src/content/docs/server-configs/WALRecoveryMode.md b/docs/src/content/docs/server-configs/WALRecoveryMode.md new file mode 100644 index 000000000..12092cf77 --- /dev/null +++ b/docs/src/content/docs/server-configs/WALRecoveryMode.md @@ -0,0 +1,43 @@ +--- +title: WALRecoveryMode +description: WAL recovery mode in case of a corruption +sidebar: + order: 21 +--- + + + +#### Description + +WAL recovery mode in case of a corruption + +#### CLI Command + +``` +--wal-recovery-mode strict +``` + + +#### Default Value +``` +strict +``` + + + +#### Possible Values +``` +- strict +- truncate +- ignore + +``` + + +#### Data Type +``` +String +``` diff --git a/docs/src/content/docs/server-configs/WALRetentionMode.md b/docs/src/content/docs/server-configs/WALRetentionMode.md new file mode 100644 index 000000000..6c5ddd8f5 --- /dev/null +++ b/docs/src/content/docs/server-configs/WALRetentionMode.md @@ -0,0 +1,43 @@ +--- +title: WALRetentionMode +description: The new horizon for WAL segment post cleanup +sidebar: + order: 18 +--- + + + +#### Description + +The new horizon for WAL segment post cleanup + +#### CLI Command + +``` +--wal-retention-mode num-segments +``` + + +#### Default Value +``` +num-segments +``` + + + +#### Possible Values +``` +- num-segments +- time +- checkpoint + +``` + + +#### Data Type +``` +String +``` diff --git a/docs/src/content/docs/server-configs/WALRotationMode.md b/docs/src/content/docs/server-configs/WALRotationMode.md new file mode 100644 index 000000000..b76375980 --- /dev/null +++ b/docs/src/content/docs/server-configs/WALRotationMode.md @@ -0,0 +1,42 @@ +--- +title: WALRotationMode +description: WAL rotation mode to use +sidebar: + order: 14 +--- + + + +#### Description + +WAL rotation mode to use + +#### CLI Command + +``` +--wal-rotation-mode segment-size +``` + + +#### Default Value +``` +segment-size +``` + + + +#### Possible Values +``` +- segment-size +- time + +``` + + +#### Data Type +``` +String +``` diff --git a/docs/src/content/docs/server-configs/WALWriteMode.md b/docs/src/content/docs/server-configs/WALWriteMode.md new file mode 100644 index 000000000..f6c962934 --- /dev/null +++ b/docs/src/content/docs/server-configs/WALWriteMode.md @@ -0,0 +1,42 @@ +--- +title: WALWriteMode +description: WAL write mode to use +sidebar: + order: 12 +--- + + + +#### Description + +WAL write mode to use + +#### CLI Command + +``` +--wal-write-mode default +``` + + +#### Default Value +``` +default +``` + + + +#### Possible Values +``` +- default +- fsync + +``` + + +#### Data Type +``` +String +``` diff --git a/scripts/generate-docs/main.go b/scripts/generate-docs/main.go index 10199ddd9..05684325e 100644 --- a/scripts/generate-docs/main.go +++ b/scripts/generate-docs/main.go @@ -6,12 +6,43 @@ package main import ( "fmt" "os" + "reflect" + "strings" "text/template" + "github.com/dicedb/dice/config" "github.com/dicedb/dice/internal/cmd" ) const DocsCommandsDirectory = "docs/src/content/docs/commands" +const ServerConfigDirectory = "docs/src/content/docs/server-configs" + +type ServerConfigMeta struct { + Order int + Name string + Description string + CLICommand string + Default string + Type string + Values []string +} + +func mapType(goType string) string { + switch goType { + case "int", "int8", "int16", "int32", "int64": + return "Integer" + case "uint", "uint8", "uint16", "uint32", "uint64": + return "Unsigned Integer" + case "float32", "float64": + return "Float" + case "bool": + return "Boolean" + case "string": + return "String" + default: + return goType + } +} func generateDocs(tmpl *template.Template, c *cmd.CommandMeta) { docFile, err := os.Create(fmt.Sprintf("%s/%s.md", DocsCommandsDirectory, c.Name)) @@ -26,6 +57,33 @@ func generateDocs(tmpl *template.Template, c *cmd.CommandMeta) { } } +func generateServerParamtersDocs(tmpl *template.Template) { + typeOf := reflect.TypeOf(&config.DiceDBConfig{}).Elem() + for i := 0; i < typeOf.NumField(); i++ { + field := typeOf.Field(i) + description := field.Tag.Get("description") + mapstructure := field.Tag.Get("mapstructure") + defaultValue := field.Tag.Get("default") + values := strings.Split(field.Tag.Get("values"), ", ") + if len(values) == 1 && values[0] == "" { + values = []string{} + } + + docFile, err := os.Create(fmt.Sprintf("%s/%s.md", ServerConfigDirectory, field.Name)) + if err != nil { + fmt.Printf("ERR: error creating file: %v\n", err) + } + defer docFile.Close() + + err = tmpl.Execute(docFile, ServerConfigMeta{i, field.Name, description, "--"+mapstructure, defaultValue, mapType(field.Type.String()), values}) + if err != nil { + fmt.Printf("ERR: error executing template: %v\n", err) + } + } +} + + + func main() { tmpl := template.Must(template.ParseFiles("scripts/generate-docs/doc.tmpl")) for _, c := range cmd.CommandRegistry.CommandMetas { @@ -35,4 +93,6 @@ func main() { generateDocs(tmpl, c) } + sctmpl := template.Must(template.ParseFiles("scripts/generate-docs/server-config.tmpl")) + generateServerParamtersDocs(sctmpl) } diff --git a/scripts/generate-docs/server-config.tmpl b/scripts/generate-docs/server-config.tmpl new file mode 100644 index 000000000..09bf92252 --- /dev/null +++ b/scripts/generate-docs/server-config.tmpl @@ -0,0 +1,41 @@ +--- +title: {{ .Name }} +description: {{ .Description }} +sidebar: + order: {{ .Order }} +--- + + + +#### Description + +{{ .Description }} + +#### CLI Command + +``` +{{ .CLICommand }} {{ .Default }} +``` + +{{ if .Default }} +#### Default Value +``` +{{ .Default }} +``` +{{ end }} + +{{ if .Values }} +#### Possible Values +``` +{{range .Values}}- {{.}} +{{end}} +``` +{{ end }} + +#### Data Type +``` +{{ .Type }} +``` From 495c02f0eef8bb6eaf5d8165d1836e30fa67b118 Mon Sep 17 00:00:00 2001 From: Abhijeet Singh Date: Fri, 4 Apr 2025 02:54:31 +0530 Subject: [PATCH 2/3] server configs in doc website --- config/config.go | 4 ++-- docs/astro.config.mjs | 2 +- docs/src/content/docs/server-configs/Host.md | 4 ++-- docs/src/content/docs/server-configs/WALMaxSegmentCount.md | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/config/config.go b/config/config.go index 6d42d235b..00a76897e 100644 --- a/config/config.go +++ b/config/config.go @@ -47,7 +47,7 @@ func init() { var Config *DiceDBConfig type DiceDBConfig struct { - Host string `mapstructure:"host" default:"0.0.0.0" description:"The host address to Bind to"` + Host string `mapstructure:"host" default:"0.0.0.0" description:"The host address to bind to"` Port int `mapstructure:"port" default:"7379" description:"The port to bind to"` Username string `mapstructure:"username" default:"dicedb" description:"The username to use for authentication"` @@ -71,7 +71,7 @@ type DiceDBConfig struct { WALMaxSegmentRotationTimeSec int `mapstructure:"wal-max-segment-rotation-time-sec" default:"60" description:"The time interval (in seconds) after which WAL a segment is rotated"` WALBufferSyncIntervalMillis int `mapstructure:"wal-buffer-sync-interval-ms" default:"200" description:"The interval (in milliseconds) at which The WAL write buffer is synced to disk"` WALRetentionMode string `mapstructure:"wal-retention-mode" default:"num-segments" description:"The new horizon for WAL segment post cleanup" values:"num-segments, time, checkpoint"` - WALMaxSegmentCount int `mapstructure:"wal-max-segment-count" default:"10" description:"The maximum number of segments to retain, if The retention mode is 'num-segments'"` + WALMaxSegmentCount int `mapstructure:"wal-max-segment-count" default:"10" description:"The maximum number of segments to retain, if the retention mode is 'num-segments'"` WALMaxSegmentRetentionDurationSec int `mapstructure:"wal-max-segment-retention-duration-sec" default:"600" description:"The maximum duration (in seconds) for WAL segments retention"` WALRecoveryMode string `mapstructure:"wal-recovery-mode" default:"strict" description:"WAL recovery mode in case of a corruption" values:"strict, truncate, ignore"` } diff --git a/docs/astro.config.mjs b/docs/astro.config.mjs index 230b71b34..60dc14356 100644 --- a/docs/astro.config.mjs +++ b/docs/astro.config.mjs @@ -34,7 +34,7 @@ export default defineConfig({ autogenerate: { directory: "get-started" }, }, { - label: "Server Configuration", + label: "Server Configurations", autogenerate: { directory: "server-configs" }, }, { diff --git a/docs/src/content/docs/server-configs/Host.md b/docs/src/content/docs/server-configs/Host.md index e0426c2bc..42d6f73db 100644 --- a/docs/src/content/docs/server-configs/Host.md +++ b/docs/src/content/docs/server-configs/Host.md @@ -1,6 +1,6 @@ --- title: Host -description: The host address to Bind to +description: The host address to bind to sidebar: order: 0 --- @@ -12,7 +12,7 @@ sidebar: #### Description -The host address to Bind to +The host address to bind to #### CLI Command diff --git a/docs/src/content/docs/server-configs/WALMaxSegmentCount.md b/docs/src/content/docs/server-configs/WALMaxSegmentCount.md index 5fea74c83..99025cc54 100644 --- a/docs/src/content/docs/server-configs/WALMaxSegmentCount.md +++ b/docs/src/content/docs/server-configs/WALMaxSegmentCount.md @@ -1,6 +1,6 @@ --- title: WALMaxSegmentCount -description: The maximum number of segments to retain, if The retention mode is 'num-segments' +description: The maximum number of segments to retain, if the retention mode is 'num-segments' sidebar: order: 19 --- @@ -12,7 +12,7 @@ sidebar: #### Description -The maximum number of segments to retain, if The retention mode is 'num-segments' +The maximum number of segments to retain, if the retention mode is 'num-segments' #### CLI Command From d1082f9bc446278f4b6500addfb9bd1b8363e06a Mon Sep 17 00:00:00 2001 From: Abhijeet Singh Date: Fri, 11 Apr 2025 10:09:09 +0530 Subject: [PATCH 3/3] updated to single file --- docs/src/content/docs/commands/KEYS.md | 16 ++++- docs/src/content/docs/commands/SET.md | 2 +- docs/src/content/docs/commands/ZADD.md | 27 ++++++--- docs/src/content/docs/commands/ZCOUNT.md | 47 +++++++++++++++ docs/src/content/docs/commands/ZRANGE.md | 31 ++++++++++ .../docs/server-configs/Configuration.md | 58 +++++++++++++++++++ .../content/docs/server-configs/EnableWAL.md | 35 ----------- .../docs/server-configs/EnableWatch.md | 35 ----------- .../src/content/docs/server-configs/Engine.md | 41 ------------- docs/src/content/docs/server-configs/Host.md | 35 ----------- .../content/docs/server-configs/LogLevel.md | 35 ----------- .../content/docs/server-configs/MaxClients.md | 35 ----------- .../content/docs/server-configs/NumShards.md | 35 ----------- .../content/docs/server-configs/Password.md | 30 ---------- docs/src/content/docs/server-configs/Port.md | 35 ----------- .../content/docs/server-configs/Username.md | 35 ----------- .../docs/server-configs/WALBufferSizeMB.md | 35 ----------- .../WALBufferSyncIntervalMillis.md | 35 ----------- .../src/content/docs/server-configs/WALDir.md | 35 ----------- .../docs/server-configs/WALMaxSegmentCount.md | 35 ----------- .../WALMaxSegmentRetentionDurationSec.md | 35 ----------- .../WALMaxSegmentRotationTimeSec.md | 35 ----------- .../server-configs/WALMaxSegmentSizeMB.md | 35 ----------- .../content/docs/server-configs/WALMode.md | 42 -------------- .../docs/server-configs/WALRecoveryMode.md | 43 -------------- .../docs/server-configs/WALRetentionMode.md | 43 -------------- .../docs/server-configs/WALRotationMode.md | 42 -------------- .../docs/server-configs/WALWriteMode.md | 42 -------------- scripts/generate-docs/main.go | 58 ++++--------------- scripts/generate-docs/server-config.tmpl | 34 ++--------- 30 files changed, 186 insertions(+), 895 deletions(-) create mode 100644 docs/src/content/docs/commands/ZCOUNT.md create mode 100644 docs/src/content/docs/commands/ZRANGE.md create mode 100644 docs/src/content/docs/server-configs/Configuration.md delete mode 100644 docs/src/content/docs/server-configs/EnableWAL.md delete mode 100644 docs/src/content/docs/server-configs/EnableWatch.md delete mode 100644 docs/src/content/docs/server-configs/Engine.md delete mode 100644 docs/src/content/docs/server-configs/Host.md delete mode 100644 docs/src/content/docs/server-configs/LogLevel.md delete mode 100644 docs/src/content/docs/server-configs/MaxClients.md delete mode 100644 docs/src/content/docs/server-configs/NumShards.md delete mode 100644 docs/src/content/docs/server-configs/Password.md delete mode 100644 docs/src/content/docs/server-configs/Port.md delete mode 100644 docs/src/content/docs/server-configs/Username.md delete mode 100644 docs/src/content/docs/server-configs/WALBufferSizeMB.md delete mode 100644 docs/src/content/docs/server-configs/WALBufferSyncIntervalMillis.md delete mode 100644 docs/src/content/docs/server-configs/WALDir.md delete mode 100644 docs/src/content/docs/server-configs/WALMaxSegmentCount.md delete mode 100644 docs/src/content/docs/server-configs/WALMaxSegmentRetentionDurationSec.md delete mode 100644 docs/src/content/docs/server-configs/WALMaxSegmentRotationTimeSec.md delete mode 100644 docs/src/content/docs/server-configs/WALMaxSegmentSizeMB.md delete mode 100644 docs/src/content/docs/server-configs/WALMode.md delete mode 100644 docs/src/content/docs/server-configs/WALRecoveryMode.md delete mode 100644 docs/src/content/docs/server-configs/WALRetentionMode.md delete mode 100644 docs/src/content/docs/server-configs/WALRotationMode.md delete mode 100644 docs/src/content/docs/server-configs/WALWriteMode.md diff --git a/docs/src/content/docs/commands/KEYS.md b/docs/src/content/docs/commands/KEYS.md index 872ad74f9..f9d958b75 100644 --- a/docs/src/content/docs/commands/KEYS.md +++ b/docs/src/content/docs/commands/KEYS.md @@ -30,11 +30,21 @@ localhost:7379> SET k1 v1 OK OK localhost:7379> SET k2 v2 OK OK +localhost:7379> SET k33 v33 +OK OK localhost:7379> KEYS k? -OK k1 k2 +OK +1) "k1" +2) "k2" localhost:7379> KEYS k* -OK k1 k2 +OK +1) "k1" +2) "k2" +3) "k33" localhost:7379> KEYS * -OK k1 k2 +OK +1) "k1" +2) "k2" +3) "k33" ``` diff --git a/docs/src/content/docs/commands/SET.md b/docs/src/content/docs/commands/SET.md index 8f0320122..e40441792 100644 --- a/docs/src/content/docs/commands/SET.md +++ b/docs/src/content/docs/commands/SET.md @@ -11,7 +11,7 @@ description: SET puts or updates an existing pair #### Syntax ``` -SET key value [EX seconds] [PX milliseconds] [EXAT timestamp] [PXAT timestamp] [XX] [NX] [KEEPTTL] +SET key value [EX seconds] [PX milliseconds] [EXAT timestamp] [PXAT timestamp] [XX] [NX] [KEEPTTL] [GET] ``` diff --git a/docs/src/content/docs/commands/ZADD.md b/docs/src/content/docs/commands/ZADD.md index c964a2869..bb4b6a912 100644 --- a/docs/src/content/docs/commands/ZADD.md +++ b/docs/src/content/docs/commands/ZADD.md @@ -1,6 +1,6 @@ --- title: ZADD -description: Adds all the specified members with the specified scores to the sorted set stored at key +description: ZADD adds all the specified members with the specified scores to the sorted set stored at key --- + +#### Syntax + +``` +ZCOUNT key min max +``` + + +ZCOUNT counts the number of members in a sorted set between min and max (both inclusive) + +If you want to use unbounded ranges, use -inf and +inf for min and max respectively. +The command returns the count of members in a sorted set between min and max (both inclusive). Returns 0 if the key does not exist. + + +#### Examples + +``` + +localhost:7379> ZADD k 10 k1 +OK 1 +localhost:7379> ZADD k 20 k2 +OK 1 +localhost:7379> ZADD k 30 k3 +OK 1 +localhost:7379> ZCOUNT k 10 20 +OK 2 +localhost:7379> ZCOUNT k 10 30 +OK 3 +localhost:7379> ZCOUNT k 10 40 +OK 3 +localhost:7379> ZCOUNT k 1 2 +OK 0 +localhost:7379> ZCOUNT k -inf +inf +OK 3 +localhost:7379> ZCOUNT k 10 10 +OK 1 + +``` diff --git a/docs/src/content/docs/commands/ZRANGE.md b/docs/src/content/docs/commands/ZRANGE.md new file mode 100644 index 000000000..9873f0a85 --- /dev/null +++ b/docs/src/content/docs/commands/ZRANGE.md @@ -0,0 +1,31 @@ +--- +title: ZRANGE +description: Returns the specified range of elements in the sorted set stored at . +--- + + + +#### Syntax + +``` +ZRANGE key start stop [REV] [WITHSCORES] +``` + + +Returns the specified range of elements in the sorted set stored at key. +The elements are considered to be ordered from the lowest to the highest score. +Both start and stop are 0-based indexes, where 0 is the first element, 1 is the next element and so on. +These indexes can also be negative numbers indicating offsets from the end of the sorted set, with -1 being the last element of the sorted set, -2 the penultimate element and so on. +Returns the specified range of elements in the sorted set. + + +#### Examples + +``` + +localhost:7379> ZRANGE mySortedSet 1 3 + +``` diff --git a/docs/src/content/docs/server-configs/Configuration.md b/docs/src/content/docs/server-configs/Configuration.md new file mode 100644 index 000000000..b2f43f206 --- /dev/null +++ b/docs/src/content/docs/server-configs/Configuration.md @@ -0,0 +1,58 @@ +--- +title: Configuration +description: Configuration options for the server. +--- + + + +#### Server Config + +``` + EnableWAL = mapstructure:"enable-wal" default:"false" description:"Enable write-ahead logging" + + EnableWatch = mapstructure:"enable-watch" default:"false" description:"Enable support for .WATCH commands and real-time reactivity" + + Engine = mapstructure:"engine" default:"ironhawk" description:"The engine to use" values:"ironhawk" + + Host = mapstructure:"host" default:"0.0.0.0" description:"The host address to bind to" + + LogLevel = mapstructure:"log-level" default:"info" description:"The log level" + + MaxClients = mapstructure:"max-clients" default:"20000" description:"The maximum number of clients to accept" + + NumShards = mapstructure:"num-shards" default:"-1" description:"Number of shards to create. defaults to number of cores" + + Password = mapstructure:"password" default:"" description:"The password to use for authentication" + + Port = mapstructure:"port" default:"7379" description:"The port to bind to" + + Username = mapstructure:"username" default:"dicedb" description:"The username to use for authentication" + + WALBufferSizeMB = mapstructure:"wal-buffer-size-mb" default:"1" description:"The size of the WAL write buffer in megabytes" + + WALBufferSyncIntervalMillis = mapstructure:"wal-buffer-sync-interval-ms" default:"200" description:"The interval (in milliseconds) at which The WAL write buffer is synced to disk" + + WALDir = mapstructure:"wal-dir" default:"/var/log/dicedb" description:"The directory to store WAL segments" + + WALMaxSegmentCount = mapstructure:"wal-max-segment-count" default:"10" description:"The maximum number of segments to retain, if the retention mode is 'num-segments'" + + WALMaxSegmentRetentionDurationSec = mapstructure:"wal-max-segment-retention-duration-sec" default:"600" description:"The maximum duration (in seconds) for WAL segments retention" + + WALMaxSegmentRotationTimeSec = mapstructure:"wal-max-segment-rotation-time-sec" default:"60" description:"The time interval (in seconds) after which WAL a segment is rotated" + + WALMaxSegmentSizeMB = mapstructure:"wal-max-segment-size-mb" default:"16" description:"The maximum size of a WAL segment file in megabytes before rotation" + + WALMode = mapstructure:"wal-mode" default:"buffered" description:"WAL mode to use" values:"buffered, unbuffered" + + WALRecoveryMode = mapstructure:"wal-recovery-mode" default:"strict" description:"WAL recovery mode in case of a corruption" values:"strict, truncate, ignore" + + WALRetentionMode = mapstructure:"wal-retention-mode" default:"num-segments" description:"The new horizon for WAL segment post cleanup" values:"num-segments, time, checkpoint" + + WALRotationMode = mapstructure:"wal-rotation-mode" default:"segment-size" description:"WAL rotation mode to use" values:"segment-size, time" + + WALWriteMode = mapstructure:"wal-write-mode" default:"default" description:"WAL write mode to use" values:"default, fsync" + +``` diff --git a/docs/src/content/docs/server-configs/EnableWAL.md b/docs/src/content/docs/server-configs/EnableWAL.md deleted file mode 100644 index 5d5034f1c..000000000 --- a/docs/src/content/docs/server-configs/EnableWAL.md +++ /dev/null @@ -1,35 +0,0 @@ ---- -title: EnableWAL -description: Enable write-ahead logging -sidebar: - order: 9 ---- - - - -#### Description - -Enable write-ahead logging - -#### CLI Command - -``` ---enable-wal false -``` - - -#### Default Value -``` -false -``` - - - - -#### Data Type -``` -Boolean -``` diff --git a/docs/src/content/docs/server-configs/EnableWatch.md b/docs/src/content/docs/server-configs/EnableWatch.md deleted file mode 100644 index 68d7d9fa2..000000000 --- a/docs/src/content/docs/server-configs/EnableWatch.md +++ /dev/null @@ -1,35 +0,0 @@ ---- -title: EnableWatch -description: Enable support for .WATCH commands and real-time reactivity -sidebar: - order: 5 ---- - - - -#### Description - -Enable support for .WATCH commands and real-time reactivity - -#### CLI Command - -``` ---enable-watch false -``` - - -#### Default Value -``` -false -``` - - - - -#### Data Type -``` -Boolean -``` diff --git a/docs/src/content/docs/server-configs/Engine.md b/docs/src/content/docs/server-configs/Engine.md deleted file mode 100644 index 1ec92d5c9..000000000 --- a/docs/src/content/docs/server-configs/Engine.md +++ /dev/null @@ -1,41 +0,0 @@ ---- -title: Engine -description: The engine to use -sidebar: - order: 8 ---- - - - -#### Description - -The engine to use - -#### CLI Command - -``` ---engine ironhawk -``` - - -#### Default Value -``` -ironhawk -``` - - - -#### Possible Values -``` -- ironhawk - -``` - - -#### Data Type -``` -String -``` diff --git a/docs/src/content/docs/server-configs/Host.md b/docs/src/content/docs/server-configs/Host.md deleted file mode 100644 index 42d6f73db..000000000 --- a/docs/src/content/docs/server-configs/Host.md +++ /dev/null @@ -1,35 +0,0 @@ ---- -title: Host -description: The host address to bind to -sidebar: - order: 0 ---- - - - -#### Description - -The host address to bind to - -#### CLI Command - -``` ---host 0.0.0.0 -``` - - -#### Default Value -``` -0.0.0.0 -``` - - - - -#### Data Type -``` -String -``` diff --git a/docs/src/content/docs/server-configs/LogLevel.md b/docs/src/content/docs/server-configs/LogLevel.md deleted file mode 100644 index c531d4d67..000000000 --- a/docs/src/content/docs/server-configs/LogLevel.md +++ /dev/null @@ -1,35 +0,0 @@ ---- -title: LogLevel -description: The log level -sidebar: - order: 4 ---- - - - -#### Description - -The log level - -#### CLI Command - -``` ---log-level info -``` - - -#### Default Value -``` -info -``` - - - - -#### Data Type -``` -String -``` diff --git a/docs/src/content/docs/server-configs/MaxClients.md b/docs/src/content/docs/server-configs/MaxClients.md deleted file mode 100644 index 4e0110831..000000000 --- a/docs/src/content/docs/server-configs/MaxClients.md +++ /dev/null @@ -1,35 +0,0 @@ ---- -title: MaxClients -description: The maximum number of clients to accept -sidebar: - order: 6 ---- - - - -#### Description - -The maximum number of clients to accept - -#### CLI Command - -``` ---max-clients 20000 -``` - - -#### Default Value -``` -20000 -``` - - - - -#### Data Type -``` -Integer -``` diff --git a/docs/src/content/docs/server-configs/NumShards.md b/docs/src/content/docs/server-configs/NumShards.md deleted file mode 100644 index 5e48bb872..000000000 --- a/docs/src/content/docs/server-configs/NumShards.md +++ /dev/null @@ -1,35 +0,0 @@ ---- -title: NumShards -description: Number of shards to create. defaults to number of cores -sidebar: - order: 7 ---- - - - -#### Description - -Number of shards to create. defaults to number of cores - -#### CLI Command - -``` ---num-shards -1 -``` - - -#### Default Value -``` --1 -``` - - - - -#### Data Type -``` -Integer -``` diff --git a/docs/src/content/docs/server-configs/Password.md b/docs/src/content/docs/server-configs/Password.md deleted file mode 100644 index b13ca7099..000000000 --- a/docs/src/content/docs/server-configs/Password.md +++ /dev/null @@ -1,30 +0,0 @@ ---- -title: Password -description: The password to use for authentication -sidebar: - order: 3 ---- - - - -#### Description - -The password to use for authentication - -#### CLI Command - -``` ---password -``` - - - - - -#### Data Type -``` -String -``` diff --git a/docs/src/content/docs/server-configs/Port.md b/docs/src/content/docs/server-configs/Port.md deleted file mode 100644 index 8cd350941..000000000 --- a/docs/src/content/docs/server-configs/Port.md +++ /dev/null @@ -1,35 +0,0 @@ ---- -title: Port -description: The port to bind to -sidebar: - order: 1 ---- - - - -#### Description - -The port to bind to - -#### CLI Command - -``` ---port 7379 -``` - - -#### Default Value -``` -7379 -``` - - - - -#### Data Type -``` -Integer -``` diff --git a/docs/src/content/docs/server-configs/Username.md b/docs/src/content/docs/server-configs/Username.md deleted file mode 100644 index b7dc26c5f..000000000 --- a/docs/src/content/docs/server-configs/Username.md +++ /dev/null @@ -1,35 +0,0 @@ ---- -title: Username -description: The username to use for authentication -sidebar: - order: 2 ---- - - - -#### Description - -The username to use for authentication - -#### CLI Command - -``` ---username dicedb -``` - - -#### Default Value -``` -dicedb -``` - - - - -#### Data Type -``` -String -``` diff --git a/docs/src/content/docs/server-configs/WALBufferSizeMB.md b/docs/src/content/docs/server-configs/WALBufferSizeMB.md deleted file mode 100644 index c7d4e1ea8..000000000 --- a/docs/src/content/docs/server-configs/WALBufferSizeMB.md +++ /dev/null @@ -1,35 +0,0 @@ ---- -title: WALBufferSizeMB -description: The size of the WAL write buffer in megabytes -sidebar: - order: 13 ---- - - - -#### Description - -The size of the WAL write buffer in megabytes - -#### CLI Command - -``` ---wal-buffer-size-mb 1 -``` - - -#### Default Value -``` -1 -``` - - - - -#### Data Type -``` -Integer -``` diff --git a/docs/src/content/docs/server-configs/WALBufferSyncIntervalMillis.md b/docs/src/content/docs/server-configs/WALBufferSyncIntervalMillis.md deleted file mode 100644 index 0b1373c80..000000000 --- a/docs/src/content/docs/server-configs/WALBufferSyncIntervalMillis.md +++ /dev/null @@ -1,35 +0,0 @@ ---- -title: WALBufferSyncIntervalMillis -description: The interval (in milliseconds) at which The WAL write buffer is synced to disk -sidebar: - order: 17 ---- - - - -#### Description - -The interval (in milliseconds) at which The WAL write buffer is synced to disk - -#### CLI Command - -``` ---wal-buffer-sync-interval-ms 200 -``` - - -#### Default Value -``` -200 -``` - - - - -#### Data Type -``` -Integer -``` diff --git a/docs/src/content/docs/server-configs/WALDir.md b/docs/src/content/docs/server-configs/WALDir.md deleted file mode 100644 index 9d4af4753..000000000 --- a/docs/src/content/docs/server-configs/WALDir.md +++ /dev/null @@ -1,35 +0,0 @@ ---- -title: WALDir -description: The directory to store WAL segments -sidebar: - order: 10 ---- - - - -#### Description - -The directory to store WAL segments - -#### CLI Command - -``` ---wal-dir /var/log/dicedb -``` - - -#### Default Value -``` -/var/log/dicedb -``` - - - - -#### Data Type -``` -String -``` diff --git a/docs/src/content/docs/server-configs/WALMaxSegmentCount.md b/docs/src/content/docs/server-configs/WALMaxSegmentCount.md deleted file mode 100644 index 99025cc54..000000000 --- a/docs/src/content/docs/server-configs/WALMaxSegmentCount.md +++ /dev/null @@ -1,35 +0,0 @@ ---- -title: WALMaxSegmentCount -description: The maximum number of segments to retain, if the retention mode is 'num-segments' -sidebar: - order: 19 ---- - - - -#### Description - -The maximum number of segments to retain, if the retention mode is 'num-segments' - -#### CLI Command - -``` ---wal-max-segment-count 10 -``` - - -#### Default Value -``` -10 -``` - - - - -#### Data Type -``` -Integer -``` diff --git a/docs/src/content/docs/server-configs/WALMaxSegmentRetentionDurationSec.md b/docs/src/content/docs/server-configs/WALMaxSegmentRetentionDurationSec.md deleted file mode 100644 index d20e4c40d..000000000 --- a/docs/src/content/docs/server-configs/WALMaxSegmentRetentionDurationSec.md +++ /dev/null @@ -1,35 +0,0 @@ ---- -title: WALMaxSegmentRetentionDurationSec -description: The maximum duration (in seconds) for WAL segments retention -sidebar: - order: 20 ---- - - - -#### Description - -The maximum duration (in seconds) for WAL segments retention - -#### CLI Command - -``` ---wal-max-segment-retention-duration-sec 600 -``` - - -#### Default Value -``` -600 -``` - - - - -#### Data Type -``` -Integer -``` diff --git a/docs/src/content/docs/server-configs/WALMaxSegmentRotationTimeSec.md b/docs/src/content/docs/server-configs/WALMaxSegmentRotationTimeSec.md deleted file mode 100644 index cb770e635..000000000 --- a/docs/src/content/docs/server-configs/WALMaxSegmentRotationTimeSec.md +++ /dev/null @@ -1,35 +0,0 @@ ---- -title: WALMaxSegmentRotationTimeSec -description: The time interval (in seconds) after which WAL a segment is rotated -sidebar: - order: 16 ---- - - - -#### Description - -The time interval (in seconds) after which WAL a segment is rotated - -#### CLI Command - -``` ---wal-max-segment-rotation-time-sec 60 -``` - - -#### Default Value -``` -60 -``` - - - - -#### Data Type -``` -Integer -``` diff --git a/docs/src/content/docs/server-configs/WALMaxSegmentSizeMB.md b/docs/src/content/docs/server-configs/WALMaxSegmentSizeMB.md deleted file mode 100644 index abf9508fd..000000000 --- a/docs/src/content/docs/server-configs/WALMaxSegmentSizeMB.md +++ /dev/null @@ -1,35 +0,0 @@ ---- -title: WALMaxSegmentSizeMB -description: The maximum size of a WAL segment file in megabytes before rotation -sidebar: - order: 15 ---- - - - -#### Description - -The maximum size of a WAL segment file in megabytes before rotation - -#### CLI Command - -``` ---wal-max-segment-size-mb 16 -``` - - -#### Default Value -``` -16 -``` - - - - -#### Data Type -``` -Integer -``` diff --git a/docs/src/content/docs/server-configs/WALMode.md b/docs/src/content/docs/server-configs/WALMode.md deleted file mode 100644 index 3c8a8924f..000000000 --- a/docs/src/content/docs/server-configs/WALMode.md +++ /dev/null @@ -1,42 +0,0 @@ ---- -title: WALMode -description: WAL mode to use -sidebar: - order: 11 ---- - - - -#### Description - -WAL mode to use - -#### CLI Command - -``` ---wal-mode buffered -``` - - -#### Default Value -``` -buffered -``` - - - -#### Possible Values -``` -- buffered -- unbuffered - -``` - - -#### Data Type -``` -String -``` diff --git a/docs/src/content/docs/server-configs/WALRecoveryMode.md b/docs/src/content/docs/server-configs/WALRecoveryMode.md deleted file mode 100644 index 12092cf77..000000000 --- a/docs/src/content/docs/server-configs/WALRecoveryMode.md +++ /dev/null @@ -1,43 +0,0 @@ ---- -title: WALRecoveryMode -description: WAL recovery mode in case of a corruption -sidebar: - order: 21 ---- - - - -#### Description - -WAL recovery mode in case of a corruption - -#### CLI Command - -``` ---wal-recovery-mode strict -``` - - -#### Default Value -``` -strict -``` - - - -#### Possible Values -``` -- strict -- truncate -- ignore - -``` - - -#### Data Type -``` -String -``` diff --git a/docs/src/content/docs/server-configs/WALRetentionMode.md b/docs/src/content/docs/server-configs/WALRetentionMode.md deleted file mode 100644 index 6c5ddd8f5..000000000 --- a/docs/src/content/docs/server-configs/WALRetentionMode.md +++ /dev/null @@ -1,43 +0,0 @@ ---- -title: WALRetentionMode -description: The new horizon for WAL segment post cleanup -sidebar: - order: 18 ---- - - - -#### Description - -The new horizon for WAL segment post cleanup - -#### CLI Command - -``` ---wal-retention-mode num-segments -``` - - -#### Default Value -``` -num-segments -``` - - - -#### Possible Values -``` -- num-segments -- time -- checkpoint - -``` - - -#### Data Type -``` -String -``` diff --git a/docs/src/content/docs/server-configs/WALRotationMode.md b/docs/src/content/docs/server-configs/WALRotationMode.md deleted file mode 100644 index b76375980..000000000 --- a/docs/src/content/docs/server-configs/WALRotationMode.md +++ /dev/null @@ -1,42 +0,0 @@ ---- -title: WALRotationMode -description: WAL rotation mode to use -sidebar: - order: 14 ---- - - - -#### Description - -WAL rotation mode to use - -#### CLI Command - -``` ---wal-rotation-mode segment-size -``` - - -#### Default Value -``` -segment-size -``` - - - -#### Possible Values -``` -- segment-size -- time - -``` - - -#### Data Type -``` -String -``` diff --git a/docs/src/content/docs/server-configs/WALWriteMode.md b/docs/src/content/docs/server-configs/WALWriteMode.md deleted file mode 100644 index f6c962934..000000000 --- a/docs/src/content/docs/server-configs/WALWriteMode.md +++ /dev/null @@ -1,42 +0,0 @@ ---- -title: WALWriteMode -description: WAL write mode to use -sidebar: - order: 12 ---- - - - -#### Description - -WAL write mode to use - -#### CLI Command - -``` ---wal-write-mode default -``` - - -#### Default Value -``` -default -``` - - - -#### Possible Values -``` -- default -- fsync - -``` - - -#### Data Type -``` -String -``` diff --git a/scripts/generate-docs/main.go b/scripts/generate-docs/main.go index 05684325e..0416d3163 100644 --- a/scripts/generate-docs/main.go +++ b/scripts/generate-docs/main.go @@ -7,7 +7,6 @@ import ( "fmt" "os" "reflect" - "strings" "text/template" "github.com/dicedb/dice/config" @@ -17,33 +16,6 @@ import ( const DocsCommandsDirectory = "docs/src/content/docs/commands" const ServerConfigDirectory = "docs/src/content/docs/server-configs" -type ServerConfigMeta struct { - Order int - Name string - Description string - CLICommand string - Default string - Type string - Values []string -} - -func mapType(goType string) string { - switch goType { - case "int", "int8", "int16", "int32", "int64": - return "Integer" - case "uint", "uint8", "uint16", "uint32", "uint64": - return "Unsigned Integer" - case "float32", "float64": - return "Float" - case "bool": - return "Boolean" - case "string": - return "String" - default: - return goType - } -} - func generateDocs(tmpl *template.Template, c *cmd.CommandMeta) { docFile, err := os.Create(fmt.Sprintf("%s/%s.md", DocsCommandsDirectory, c.Name)) if err != nil { @@ -59,26 +31,21 @@ func generateDocs(tmpl *template.Template, c *cmd.CommandMeta) { func generateServerParamtersDocs(tmpl *template.Template) { typeOf := reflect.TypeOf(&config.DiceDBConfig{}).Elem() + serverConifigMeta := make(map[string]string) for i := 0; i < typeOf.NumField(); i++ { field := typeOf.Field(i) - description := field.Tag.Get("description") - mapstructure := field.Tag.Get("mapstructure") - defaultValue := field.Tag.Get("default") - values := strings.Split(field.Tag.Get("values"), ", ") - if len(values) == 1 && values[0] == "" { - values = []string{} - } - - docFile, err := os.Create(fmt.Sprintf("%s/%s.md", ServerConfigDirectory, field.Name)) - if err != nil { - fmt.Printf("ERR: error creating file: %v\n", err) - } - defer docFile.Close() + serverConifigMeta[field.Name] = string(field.Tag) + } - err = tmpl.Execute(docFile, ServerConfigMeta{i, field.Name, description, "--"+mapstructure, defaultValue, mapType(field.Type.String()), values}) - if err != nil { - fmt.Printf("ERR: error executing template: %v\n", err) - } + docFile, err := os.Create(fmt.Sprintf("%s/%s.md", ServerConfigDirectory, "Configuration")) + if err != nil { + fmt.Printf("ERR: error creating file: %v\n", err) + } + defer docFile.Close() + + err = tmpl.Execute(docFile, serverConifigMeta) + if err != nil { + fmt.Printf("ERR: error executing template: %v\n", err) } } @@ -90,7 +57,6 @@ func main() { if c.HelpLong == "" { continue } - generateDocs(tmpl, c) } sctmpl := template.Must(template.ParseFiles("scripts/generate-docs/server-config.tmpl")) diff --git a/scripts/generate-docs/server-config.tmpl b/scripts/generate-docs/server-config.tmpl index 09bf92252..2306963f8 100644 --- a/scripts/generate-docs/server-config.tmpl +++ b/scripts/generate-docs/server-config.tmpl @@ -1,8 +1,6 @@ --- -title: {{ .Name }} -description: {{ .Description }} -sidebar: - order: {{ .Order }} +title: Configuration +description: Configuration options for the server. --- -#### Description +#### Server Config -{{ .Description }} - -#### CLI Command - -``` -{{ .CLICommand }} {{ .Default }} -``` - -{{ if .Default }} -#### Default Value -``` -{{ .Default }} ``` -{{ end }} - -{{ if .Values }} -#### Possible Values -``` -{{range .Values}}- {{.}} +{{- range $key, $value := . }} + {{$key}} = {{$value}} {{end}} ``` -{{ end }} - -#### Data Type -``` -{{ .Type }} -```