-
Notifications
You must be signed in to change notification settings - Fork 24.4k
Description
Problem Statement
At AWS we use modules internally to build out functionality outside of the main Redis engine, and we imagine that other managed services/users do this as well. One of the drawbacks of this is that we don't have a single mechanism for configuring redis engine features and features provided by the module. So we would like to propose the following improvement:
Proposal
- Add 4 (bool, sds, enum, numeric) new Redis Module functions for dynamically creating standard configurations for the module. This needs to be called in the onLoad function of the Module. These functions will look like RM_RegisterConfig*.
- “moduleName:” is added to the module config’s name on creation to forcefully maintain a naming pattern. (We'll use this later as well.)
- Pointers to the variables in the module are passed as pointers to the new Module config register function to use for the standard config value address.
- Enum configs will take an array of keys and values to define them.
- Dynamically grow the standard config array - During the onLoad of the module, new configurations will be added to the standard config array in config.c
- On Module Unload - The standard configurations are searched for and removed by default using the module configuration naming pattern.
- On Redis Server Startup - Defer the loading of both modules and module configs until all of the config file has been loaded. This is possible because module names have a defined syntax with the ":":
- Module configs will also be able to register the update and is_valid callbacks, these will be optional.
Example
An example, if we have a module, we'll call it replication-manager and it wants to register a config called repl-batch-size that is a numeric type. When the module loads, it will register the config repl-batch-size using RM_RegisterConfigLongLong("repl-batch-size", flags, long long **pointer, <constraints>, callbacks);. You would be able to update this config by calling config set replication-manager:repl-batch-size 12.
Why not use argv
Using the argv only works on startup, and we want to be able to tune existing values.
Why not use a new command
That's a lot of work to have a "config" command per module. You can make the argument that you can use filtering to make it transparent to the caller, but that is a lot of work to maintain separate infrastructure in lots of different modules.