It is required to control general behaviour of Stork server via some settings, eg. pulling period for collecting lease stats.
settings should be stored in database
settings should have default values if possible
when a setting is changed then it should be immediately used by the server (ie. no restart should be required)
Settings are stored in database, in setting table. One setting occupy one row. The columns in the table are:
value type, it can be integer, bool, string, password
value, encoded as string using strconv module
Reading and writing functions are taking into account value type. So when given setting is being queried or stored its name and type has to be indicated. Reading functions are: GetSettingInt(name), etc; writing: SetSettingInt(name, value), etc.
Settings are storing only global values. If there is a need a setting per machine or app then it needs to be stored elsewhere (e.g. in machine table in case of machines).
The functionality is implemented in backend/server/database/model/setting.go file.
To not bother db for each settings access cache them in memory. Access must be serialized so goroutines will not get into conflicts. Some caching library can be used: https://blog.dgraph.io/post/caching-in-go/.