|
|
It is required to control general behaviour of Stork server via some settings, eg. pulling period for collecting lease stats.
|
|
|
|
|
|
# Requirements
|
|
|
1. settings should be stored in database
|
|
|
1. settings should have default values if possible
|
|
|
2. when a setting is changed then it should be immediately used by the server (ie. no restart should be required)
|
|
|
|
|
|
# Design
|
|
|
|
|
|
Settings are stored in database, in setting table. One setting occupy one row. The columns in the table are:
|
|
|
- name (string)
|
|
|
- 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).
|
|
|
|
|
|
# Implementation
|
|
|
Issue: https://gitlab.isc.org/isc-projects/stork/issues/169
|
|
|
|
|
|
The functionality is implemented in `backend/server/database/model/setting.go` file.
|
|
|
|
|
|
# Future improvements
|
|
|
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/.
|
|
|
|