mirror of
https://github.com/superseriousbusiness/gotosocial
synced 2025-06-05 21:59:39 +02:00
[feature] support configuring database caches (#1246)
* update config generator to support nested structs, add cache configuration options * update envparsing test * add cache configuration to config parse tests * set cache configuration in testrig * move caches to sub-cache "gts" namespace, update envparsing, add cache config docs to example config Signed-off-by: kim <grufwub@gmail.com>
This commit is contained in:
@@ -41,8 +41,8 @@ func NewState() *ConfigState {
|
||||
viper := viper.New()
|
||||
|
||||
// Flag 'some-flag-name' becomes env var 'GTS_SOME_FLAG_NAME'
|
||||
viper.SetEnvPrefix("gts")
|
||||
viper.SetEnvKeyReplacer(strings.NewReplacer("-", "_"))
|
||||
viper.SetEnvPrefix("gts")
|
||||
|
||||
// Load appropriate named vals from env
|
||||
viper.AutomaticEnv()
|
||||
@@ -132,9 +132,13 @@ func (st *ConfigState) reloadToViper() {
|
||||
func (st *ConfigState) reloadFromViper() {
|
||||
if err := st.viper.Unmarshal(&st.config, func(c *mapstructure.DecoderConfig) {
|
||||
c.TagName = "name"
|
||||
c.ZeroFields = true // empty the config struct before we marshal values into it
|
||||
|
||||
// empty config before marshaling
|
||||
c.ZeroFields = true
|
||||
|
||||
oldhook := c.DecodeHook
|
||||
|
||||
// Use the TextUnmarshaler interface when decoding.
|
||||
c.DecodeHook = mapstructure.ComposeDecodeHookFunc(
|
||||
mapstructure.TextUnmarshallerHookFunc(),
|
||||
oldhook,
|
||||
|
Reference in New Issue
Block a user