update config generator to support nested structs, add cache configuration options

Signed-off-by: kim <grufwub@gmail.com>
This commit is contained in:
kim 2022-12-09 21:45:59 +00:00
parent 24b4f9b5d7
commit d155c50491
6 changed files with 945 additions and 87 deletions

63
internal/cache/gts.go vendored
View file

@ -19,9 +19,8 @@
package cache
import (
"time"
"codeberg.org/gruf/go-cache/v3/result"
"github.com/superseriousbusiness/gotosocial/internal/config"
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
)
@ -100,34 +99,34 @@ func (c *gtsCaches) Init() {
func (c *gtsCaches) Start() {
tryUntil("starting gtsmodel.Account cache", 5, func() bool {
return c.account.Start(time.Second * 10)
return c.account.Start(config.GetCacheAccountSweepFreq())
})
tryUntil("starting gtsmodel.Block cache", 5, func() bool {
return c.block.Start(time.Second * 10)
return c.block.Start(config.GetCacheBlockSweepFreq())
})
tryUntil("starting gtsmodel.DomainBlock cache", 5, func() bool {
return c.domainBlock.Start(time.Second * 10)
return c.domainBlock.Start(config.GetCacheDomainBlockSweepFreq())
})
tryUntil("starting gtsmodel.Emoji cache", 5, func() bool {
return c.emoji.Start(time.Second * 10)
return c.emoji.Start(config.GetCacheEmojiSweepFreq())
})
tryUntil("starting gtsmodel.EmojiCategory cache", 5, func() bool {
return c.emojiCategory.Start(time.Second * 10)
return c.emojiCategory.Start(config.GetCacheEmojiCategorySweepFreq())
})
tryUntil("starting gtsmodel.Mention cache", 5, func() bool {
return c.mention.Start(time.Second * 10)
return c.mention.Start(config.GetCacheMentionSweepFreq())
})
tryUntil("starting gtsmodel.Notification cache", 5, func() bool {
return c.notification.Start(time.Second * 10)
return c.notification.Start(config.GetCacheNotificationSweepFreq())
})
tryUntil("starting gtsmodel.Status cache", 5, func() bool {
return c.status.Start(time.Second * 10)
return c.status.Start(config.GetCacheStatusSweepFreq())
})
tryUntil("starting gtsmodel.Tombstone cache", 5, func() bool {
return c.tombstone.Start(time.Second * 10)
return c.tombstone.Start(config.GetCacheTombstoneSweepFreq())
})
tryUntil("starting gtsmodel.User cache", 5, func() bool {
return c.user.Start(time.Second * 10)
return c.user.Start(config.GetCacheUserSweepFreq())
})
}
@ -195,8 +194,8 @@ func (c *gtsCaches) initAccount() {
a2 := new(gtsmodel.Account)
*a2 = *a1
return a2
}, 1000)
c.account.SetTTL(time.Minute*5, false)
}, config.GetCacheAccountMaxSize())
c.account.SetTTL(config.GetCacheAccountTTL(), true)
}
func (c *gtsCaches) initBlock() {
@ -208,8 +207,8 @@ func (c *gtsCaches) initBlock() {
b2 := new(gtsmodel.Block)
*b2 = *b1
return b2
}, 1000)
c.block.SetTTL(time.Minute*5, false)
}, config.GetCacheBlockMaxSize())
c.block.SetTTL(config.GetCacheBlockTTL(), true)
}
func (c *gtsCaches) initDomainBlock() {
@ -219,8 +218,8 @@ func (c *gtsCaches) initDomainBlock() {
d2 := new(gtsmodel.DomainBlock)
*d2 = *d1
return d2
}, 1000)
c.domainBlock.SetTTL(time.Minute*5, false)
}, config.GetCacheDomainBlockMaxSize())
c.domainBlock.SetTTL(config.GetCacheDomainBlockTTL(), true)
}
func (c *gtsCaches) initEmoji() {
@ -233,8 +232,8 @@ func (c *gtsCaches) initEmoji() {
e2 := new(gtsmodel.Emoji)
*e2 = *e1
return e2
}, 1000)
c.emoji.SetTTL(time.Minute*5, false)
}, config.GetCacheEmojiMaxSize())
c.emoji.SetTTL(config.GetCacheEmojiTTL(), true)
}
func (c *gtsCaches) initEmojiCategory() {
@ -245,8 +244,8 @@ func (c *gtsCaches) initEmojiCategory() {
c2 := new(gtsmodel.EmojiCategory)
*c2 = *c1
return c2
}, 1000)
c.emojiCategory.SetTTL(time.Minute*5, false)
}, config.GetCacheEmojiCategoryMaxSize())
c.emojiCategory.SetTTL(config.GetCacheEmojiCategoryTTL(), true)
}
func (c *gtsCaches) initMention() {
@ -256,8 +255,8 @@ func (c *gtsCaches) initMention() {
m2 := new(gtsmodel.Mention)
*m2 = *m1
return m2
}, 1000)
c.mention.SetTTL(time.Minute*5, false)
}, config.GetCacheMentionMaxSize())
c.mention.SetTTL(config.GetCacheMentionTTL(), true)
}
func (c *gtsCaches) initNotification() {
@ -267,8 +266,8 @@ func (c *gtsCaches) initNotification() {
n2 := new(gtsmodel.Notification)
*n2 = *n1
return n2
}, 1000)
c.notification.SetTTL(time.Minute*5, false)
}, config.GetCacheNotificationMaxSize())
c.notification.SetTTL(config.GetCacheNotificationTTL(), true)
}
func (c *gtsCaches) initStatus() {
@ -280,8 +279,8 @@ func (c *gtsCaches) initStatus() {
s2 := new(gtsmodel.Status)
*s2 = *s1
return s2
}, 1000)
c.status.SetTTL(time.Minute*5, false)
}, config.GetCacheStatusMaxSize())
c.status.SetTTL(config.GetCacheStatusTTL(), true)
}
// initTombstone will initialize the gtsmodel.Tombstone cache.
@ -293,8 +292,8 @@ func (c *gtsCaches) initTombstone() {
t2 := new(gtsmodel.Tombstone)
*t2 = *t1
return t2
}, 100)
c.tombstone.SetTTL(time.Minute*5, false)
}, config.GetCacheTombstoneMaxSize())
c.tombstone.SetTTL(config.GetCacheTombstoneTTL(), true)
}
func (c *gtsCaches) initUser() {
@ -308,6 +307,6 @@ func (c *gtsCaches) initUser() {
u2 := new(gtsmodel.User)
*u2 = *u1
return u2
}, 1000)
c.user.SetTTL(time.Minute*5, false)
}, config.GetCacheUserMaxSize())
c.user.SetTTL(config.GetCacheUserTTL(), true)
}

View file

@ -20,6 +20,7 @@ package config
import (
"reflect"
"time"
"codeberg.org/gruf/go-bytesize"
"github.com/mitchellh/mapstructure"
@ -129,6 +130,9 @@ type Configuration struct {
AdvancedCookiesSamesite string `name:"advanced-cookies-samesite" usage:"'strict' or 'lax', see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie/SameSite"`
AdvancedRateLimitRequests int `name:"advanced-rate-limit-requests" usage:"Amount of HTTP requests to permit within a 5 minute window. 0 or less turns rate limiting off."`
// Cache configuration vars.
Cache CacheConfig `name:"cache"`
// TODO: move these elsewhere, these are more ephemeral vs long-running flags like above
AdminAccountUsername string `name:"username" usage:"the username to create/delete/etc"`
AdminAccountEmail string `name:"email" usage:"the email address of this account"`
@ -137,6 +141,48 @@ type Configuration struct {
AdminMediaPruneDryRun bool `name:"dry-run" usage:"perform a dry run and only log number of items eligible for pruning"`
}
type CacheConfig struct {
AccountMaxSize int `name:"account-max-size"`
AccountTTL time.Duration `name:"account-ttl"`
AccountSweepFreq time.Duration `name:"account-sweep-freq"`
BlockMaxSize int `name:"block-max-size"`
BlockTTL time.Duration `name:"block-ttl"`
BlockSweepFreq time.Duration `name:"block-sweep-freq"`
DomainBlockMaxSize int `name:"domain-block-max-size"`
DomainBlockTTL time.Duration `name:"domain-block-ttl"`
DomainBlockSweepFreq time.Duration `name:"domain-block-sweep-freq"`
EmojiMaxSize int `name:"emoji-max-size"`
EmojiTTL time.Duration `name:"emoji-ttl"`
EmojiSweepFreq time.Duration `name:"emoji-sweep-freq"`
EmojiCategoryMaxSize int `name:"emoji-category-max-size"`
EmojiCategoryTTL time.Duration `name:"emoji-category-ttl"`
EmojiCategorySweepFreq time.Duration `name:"emoji-category-sweep-freq"`
MentionMaxSize int `name:"mention-max-size"`
MentionTTL time.Duration `name:"mention-ttl"`
MentionSweepFreq time.Duration `name:"mention-sweep-freq"`
NotificationMaxSize int `name:"notification-max-size"`
NotificationTTL time.Duration `name:"notification-ttl"`
NotificationSweepFreq time.Duration `name:"notification-sweep-freq"`
StatusMaxSize int `name:"status-max-size"`
StatusTTL time.Duration `name:"status-ttl"`
StatusSweepFreq time.Duration `name:"status-sweep-freq"`
TombstoneMaxSize int `name:"tombstone-max-size"`
TombstoneTTL time.Duration `name:"tombstone-ttl"`
TombstoneSweepFreq time.Duration `name:"tombstone-sweep-freq"`
UserMaxSize int `name:"user-max-size"`
UserTTL time.Duration `name:"user-ttl"`
UserSweepFreq time.Duration `name:"user-sweep-freq"`
}
// MarshalMap will marshal current Configuration into a map structure (useful for JSON).
func (cfg *Configuration) MarshalMap() (map[string]interface{}, error) {
var dst map[string]interface{}

View file

@ -18,7 +18,12 @@
package config
import "github.com/coreos/go-oidc/v3/oidc"
import (
"time"
"codeberg.org/gruf/go-bytesize"
"github.com/coreos/go-oidc/v3/oidc"
)
// Defaults contains a populated Configuration with reasonable defaults. Note that
// if you use this, you will still need to set Host, and, if desired, ConfigPath.
@ -56,13 +61,13 @@ var Defaults = Configuration{
AccountsReasonRequired: true,
AccountsAllowCustomCSS: false,
MediaImageMaxSize: 10485760, // 10mb
MediaVideoMaxSize: 41943040, // 40mb
MediaImageMaxSize: 10 * bytesize.MiB,
MediaVideoMaxSize: 40 * bytesize.MiB,
MediaDescriptionMinChars: 0,
MediaDescriptionMaxChars: 500,
MediaRemoteCacheDays: 30,
MediaEmojiLocalMaxSize: 51200, // 50kb
MediaEmojiRemoteMaxSize: 102400, // 100kb
MediaEmojiLocalMaxSize: 50 * bytesize.KiB,
MediaEmojiRemoteMaxSize: 100 * bytesize.KiB,
StorageBackend: "local",
StorageLocalBasePath: "/gotosocial/storage",
@ -101,4 +106,46 @@ var Defaults = Configuration{
AdvancedCookiesSamesite: "lax",
AdvancedRateLimitRequests: 1000, // per 5 minutes
Cache: CacheConfig{
AccountMaxSize: 100,
AccountTTL: time.Minute * 5,
AccountSweepFreq: time.Second * 10,
BlockMaxSize: 100,
BlockTTL: time.Minute * 5,
BlockSweepFreq: time.Second * 10,
DomainBlockMaxSize: 1000,
DomainBlockTTL: time.Hour * 24,
DomainBlockSweepFreq: time.Minute,
EmojiMaxSize: 500,
EmojiTTL: time.Minute * 5,
EmojiSweepFreq: time.Second * 10,
EmojiCategoryMaxSize: 100,
EmojiCategoryTTL: time.Minute * 5,
EmojiCategorySweepFreq: time.Second * 10,
MentionMaxSize: 500,
MentionTTL: time.Minute * 5,
MentionSweepFreq: time.Second * 10,
NotificationMaxSize: 500,
NotificationTTL: time.Minute * 5,
NotificationSweepFreq: time.Second * 10,
StatusMaxSize: 500,
StatusTTL: time.Minute * 5,
StatusSweepFreq: time.Second * 10,
TombstoneMaxSize: 100,
TombstoneTTL: time.Minute * 5,
TombstoneSweepFreq: time.Second * 10,
UserMaxSize: 100,
UserTTL: time.Minute * 5,
UserSweepFreq: time.Second * 10,
},
}

View file

@ -21,9 +21,11 @@ package main
import (
"flag"
"fmt"
"io"
"os"
"os/exec"
"reflect"
"strings"
"github.com/superseriousbusiness/gotosocial/internal/config"
)
@ -48,14 +50,10 @@ const license = `/*
`
func main() {
var (
out string
gen string
)
var out string
// Load runtime config flags
flag.StringVar(&out, "out", "", "Generated file output path")
flag.StringVar(&gen, "gen", "helpers", "Type of file to generate (helpers)")
flag.Parse()
// Open output file path
@ -64,50 +62,61 @@ func main() {
panic(err)
}
switch gen {
// Generate config field helper methods
case "helpers":
fmt.Fprint(output, "// THIS IS A GENERATED FILE, DO NOT EDIT BY HAND\n")
fmt.Fprint(output, license)
fmt.Fprint(output, "package config\n\n")
fmt.Fprint(output, "import \"codeberg.org/gruf/go-bytesize\"\n\n")
t := reflect.TypeOf(config.Configuration{})
for i := 0; i < t.NumField(); i++ {
field := t.Field(i)
fmt.Fprint(output, "// THIS IS A GENERATED FILE, DO NOT EDIT BY HAND\n")
fmt.Fprint(output, license)
fmt.Fprint(output, "package config\n\n")
fmt.Fprint(output, "import \"codeberg.org/gruf/go-bytesize\"\n\n")
generateFields(output, nil, reflect.TypeOf(config.Configuration{}))
_ = output.Close()
_ = exec.Command("gofumports", "-w", out).Run()
// ConfigState structure helper methods
fmt.Fprintf(output, "// Get%s safely fetches the Configuration value for state's '%s' field\n", field.Name, field.Name)
fmt.Fprintf(output, "func (st *ConfigState) Get%s() (v %s) {\n", field.Name, field.Type.String())
fmt.Fprintf(output, "\tst.mutex.Lock()\n")
fmt.Fprintf(output, "\tv = st.config.%s\n", field.Name)
fmt.Fprintf(output, "\tst.mutex.Unlock()\n")
fmt.Fprintf(output, "\treturn\n")
fmt.Fprintf(output, "}\n\n")
fmt.Fprintf(output, "// Set%s safely sets the Configuration value for state's '%s' field\n", field.Name, field.Name)
fmt.Fprintf(output, "func (st *ConfigState) Set%s(v %s) {\n", field.Name, field.Type.String())
fmt.Fprintf(output, "\tst.mutex.Lock()\n")
fmt.Fprintf(output, "\tdefer st.mutex.Unlock()\n")
fmt.Fprintf(output, "\tst.config.%s = v\n", field.Name)
fmt.Fprintf(output, "\tst.reloadToViper()\n")
fmt.Fprintf(output, "}\n\n")
// Global ConfigState helper methods
// TODO: remove when we pass around a ConfigState{}
fmt.Fprintf(output, "// %sFlag returns the flag name for the '%s' field\n", field.Name, field.Name)
fmt.Fprintf(output, "func %sFlag() string { return \"%s\" }\n\n", field.Name, field.Tag.Get("name"))
fmt.Fprintf(output, "// Get%s safely fetches the value for global configuration '%s' field\n", field.Name, field.Name)
fmt.Fprintf(output, "func Get%[1]s() %[2]s { return global.Get%[1]s() }\n\n", field.Name, field.Type.String())
fmt.Fprintf(output, "// Set%s safely sets the value for global configuration '%s' field\n", field.Name, field.Name)
fmt.Fprintf(output, "func Set%[1]s(v %[2]s) { global.Set%[1]s(v) }\n\n", field.Name, field.Type.String())
}
_ = output.Close()
_ = exec.Command("gofumports", "-w", out).Run()
// The plain here is that eventually we might be able
// The plan here is that eventually we might be able
// to generate an example configuration from struct tags
}
// Unknown type
default:
panic("unknown generation type: " + gen)
func generateFields(output io.Writer, prefixes []string, t reflect.Type) {
for i := 0; i < t.NumField(); i++ {
field := t.Field(i)
if ft := field.Type; ft.Kind() == reflect.Struct {
// This is a struct field containing further nested config vars.
generateFields(output, append(prefixes, field.Name), ft)
continue
}
// Get prefixed config variable name
name := strings.Join(prefixes, "") + field.Name
// Get period-separated (if nested) config variable "path"
fieldPath := strings.Join(append(prefixes, field.Name), ".")
// Get dash-separated config variable CLI flag "path"
flagPath := strings.Join(append(prefixes, field.Tag.Get("name")), "-")
flagPath = strings.ToLower(flagPath)
// ConfigState structure helper methods
fmt.Fprintf(output, "// Get%s safely fetches the Configuration value for state's '%s' field\n", name, fieldPath)
fmt.Fprintf(output, "func (st *ConfigState) Get%s() (v %s) {\n", name, field.Type.String())
fmt.Fprintf(output, "\tst.mutex.Lock()\n")
fmt.Fprintf(output, "\tv = st.config.%s\n", fieldPath)
fmt.Fprintf(output, "\tst.mutex.Unlock()\n")
fmt.Fprintf(output, "\treturn\n")
fmt.Fprintf(output, "}\n\n")
fmt.Fprintf(output, "// Set%s safely sets the Configuration value for state's '%s' field\n", name, fieldPath)
fmt.Fprintf(output, "func (st *ConfigState) Set%s(v %s) {\n", name, field.Type.String())
fmt.Fprintf(output, "\tst.mutex.Lock()\n")
fmt.Fprintf(output, "\tdefer st.mutex.Unlock()\n")
fmt.Fprintf(output, "\tst.config.%s = v\n", fieldPath)
fmt.Fprintf(output, "\tst.reloadToViper()\n")
fmt.Fprintf(output, "}\n\n")
// Global ConfigState helper methods
// TODO: remove when we pass around a ConfigState{}
fmt.Fprintf(output, "// %sFlag returns the flag name for the '%s' field\n", name, fieldPath)
fmt.Fprintf(output, "func %sFlag() string { return \"%s\" }\n\n", name, flagPath)
fmt.Fprintf(output, "// Get%s safely fetches the value for global configuration '%s' field\n", name, fieldPath)
fmt.Fprintf(output, "func Get%[1]s() %[2]s { return global.Get%[1]s() }\n\n", name, field.Type.String())
fmt.Fprintf(output, "// Set%s safely sets the value for global configuration '%s' field\n", name, fieldPath)
fmt.Fprintf(output, "func Set%[1]s(v %[2]s) { global.Set%[1]s(v) }\n\n", name, field.Type.String())
}
}

View file

@ -18,7 +18,11 @@
*/
package config
import "codeberg.org/gruf/go-bytesize"
import (
"time"
"codeberg.org/gruf/go-bytesize"
)
// GetLogLevel safely fetches the Configuration value for state's 'LogLevel' field
func (st *ConfigState) GetLogLevel() (v string) {
@ -1820,6 +1824,756 @@ func GetAdvancedRateLimitRequests() int { return global.GetAdvancedRateLimitRequ
// SetAdvancedRateLimitRequests safely sets the value for global configuration 'AdvancedRateLimitRequests' field
func SetAdvancedRateLimitRequests(v int) { global.SetAdvancedRateLimitRequests(v) }
// GetCacheAccountMaxSize safely fetches the Configuration value for state's 'Cache.AccountMaxSize' field
func (st *ConfigState) GetCacheAccountMaxSize() (v int) {
st.mutex.Lock()
v = st.config.Cache.AccountMaxSize
st.mutex.Unlock()
return
}
// SetCacheAccountMaxSize safely sets the Configuration value for state's 'Cache.AccountMaxSize' field
func (st *ConfigState) SetCacheAccountMaxSize(v int) {
st.mutex.Lock()
defer st.mutex.Unlock()
st.config.Cache.AccountMaxSize = v
st.reloadToViper()
}
// CacheAccountMaxSizeFlag returns the flag name for the 'Cache.AccountMaxSize' field
func CacheAccountMaxSizeFlag() string { return "cache-account-max-size" }
// GetCacheAccountMaxSize safely fetches the value for global configuration 'Cache.AccountMaxSize' field
func GetCacheAccountMaxSize() int { return global.GetCacheAccountMaxSize() }
// SetCacheAccountMaxSize safely sets the value for global configuration 'Cache.AccountMaxSize' field
func SetCacheAccountMaxSize(v int) { global.SetCacheAccountMaxSize(v) }
// GetCacheAccountTTL safely fetches the Configuration value for state's 'Cache.AccountTTL' field
func (st *ConfigState) GetCacheAccountTTL() (v time.Duration) {
st.mutex.Lock()
v = st.config.Cache.AccountTTL
st.mutex.Unlock()
return
}
// SetCacheAccountTTL safely sets the Configuration value for state's 'Cache.AccountTTL' field
func (st *ConfigState) SetCacheAccountTTL(v time.Duration) {
st.mutex.Lock()
defer st.mutex.Unlock()
st.config.Cache.AccountTTL = v
st.reloadToViper()
}
// CacheAccountTTLFlag returns the flag name for the 'Cache.AccountTTL' field
func CacheAccountTTLFlag() string { return "cache-account-ttl" }
// GetCacheAccountTTL safely fetches the value for global configuration 'Cache.AccountTTL' field
func GetCacheAccountTTL() time.Duration { return global.GetCacheAccountTTL() }
// SetCacheAccountTTL safely sets the value for global configuration 'Cache.AccountTTL' field
func SetCacheAccountTTL(v time.Duration) { global.SetCacheAccountTTL(v) }
// GetCacheAccountSweepFreq safely fetches the Configuration value for state's 'Cache.AccountSweepFreq' field
func (st *ConfigState) GetCacheAccountSweepFreq() (v time.Duration) {
st.mutex.Lock()
v = st.config.Cache.AccountSweepFreq
st.mutex.Unlock()
return
}
// SetCacheAccountSweepFreq safely sets the Configuration value for state's 'Cache.AccountSweepFreq' field
func (st *ConfigState) SetCacheAccountSweepFreq(v time.Duration) {
st.mutex.Lock()
defer st.mutex.Unlock()
st.config.Cache.AccountSweepFreq = v
st.reloadToViper()
}
// CacheAccountSweepFreqFlag returns the flag name for the 'Cache.AccountSweepFreq' field
func CacheAccountSweepFreqFlag() string { return "cache-account-sweep-freq" }
// GetCacheAccountSweepFreq safely fetches the value for global configuration 'Cache.AccountSweepFreq' field
func GetCacheAccountSweepFreq() time.Duration { return global.GetCacheAccountSweepFreq() }
// SetCacheAccountSweepFreq safely sets the value for global configuration 'Cache.AccountSweepFreq' field
func SetCacheAccountSweepFreq(v time.Duration) { global.SetCacheAccountSweepFreq(v) }
// GetCacheBlockMaxSize safely fetches the Configuration value for state's 'Cache.BlockMaxSize' field
func (st *ConfigState) GetCacheBlockMaxSize() (v int) {
st.mutex.Lock()
v = st.config.Cache.BlockMaxSize
st.mutex.Unlock()
return
}
// SetCacheBlockMaxSize safely sets the Configuration value for state's 'Cache.BlockMaxSize' field
func (st *ConfigState) SetCacheBlockMaxSize(v int) {
st.mutex.Lock()
defer st.mutex.Unlock()
st.config.Cache.BlockMaxSize = v
st.reloadToViper()
}
// CacheBlockMaxSizeFlag returns the flag name for the 'Cache.BlockMaxSize' field
func CacheBlockMaxSizeFlag() string { return "cache-block-max-size" }
// GetCacheBlockMaxSize safely fetches the value for global configuration 'Cache.BlockMaxSize' field
func GetCacheBlockMaxSize() int { return global.GetCacheBlockMaxSize() }
// SetCacheBlockMaxSize safely sets the value for global configuration 'Cache.BlockMaxSize' field
func SetCacheBlockMaxSize(v int) { global.SetCacheBlockMaxSize(v) }
// GetCacheBlockTTL safely fetches the Configuration value for state's 'Cache.BlockTTL' field
func (st *ConfigState) GetCacheBlockTTL() (v time.Duration) {
st.mutex.Lock()
v = st.config.Cache.BlockTTL
st.mutex.Unlock()
return
}
// SetCacheBlockTTL safely sets the Configuration value for state's 'Cache.BlockTTL' field
func (st *ConfigState) SetCacheBlockTTL(v time.Duration) {
st.mutex.Lock()
defer st.mutex.Unlock()
st.config.Cache.BlockTTL = v
st.reloadToViper()
}
// CacheBlockTTLFlag returns the flag name for the 'Cache.BlockTTL' field
func CacheBlockTTLFlag() string { return "cache-block-ttl" }
// GetCacheBlockTTL safely fetches the value for global configuration 'Cache.BlockTTL' field
func GetCacheBlockTTL() time.Duration { return global.GetCacheBlockTTL() }
// SetCacheBlockTTL safely sets the value for global configuration 'Cache.BlockTTL' field
func SetCacheBlockTTL(v time.Duration) { global.SetCacheBlockTTL(v) }
// GetCacheBlockSweepFreq safely fetches the Configuration value for state's 'Cache.BlockSweepFreq' field
func (st *ConfigState) GetCacheBlockSweepFreq() (v time.Duration) {
st.mutex.Lock()
v = st.config.Cache.BlockSweepFreq
st.mutex.Unlock()
return
}
// SetCacheBlockSweepFreq safely sets the Configuration value for state's 'Cache.BlockSweepFreq' field
func (st *ConfigState) SetCacheBlockSweepFreq(v time.Duration) {
st.mutex.Lock()
defer st.mutex.Unlock()
st.config.Cache.BlockSweepFreq = v
st.reloadToViper()
}
// CacheBlockSweepFreqFlag returns the flag name for the 'Cache.BlockSweepFreq' field
func CacheBlockSweepFreqFlag() string { return "cache-block-sweep-freq" }
// GetCacheBlockSweepFreq safely fetches the value for global configuration 'Cache.BlockSweepFreq' field
func GetCacheBlockSweepFreq() time.Duration { return global.GetCacheBlockSweepFreq() }
// SetCacheBlockSweepFreq safely sets the value for global configuration 'Cache.BlockSweepFreq' field
func SetCacheBlockSweepFreq(v time.Duration) { global.SetCacheBlockSweepFreq(v) }
// GetCacheDomainBlockMaxSize safely fetches the Configuration value for state's 'Cache.DomainBlockMaxSize' field
func (st *ConfigState) GetCacheDomainBlockMaxSize() (v int) {
st.mutex.Lock()
v = st.config.Cache.DomainBlockMaxSize
st.mutex.Unlock()
return
}
// SetCacheDomainBlockMaxSize safely sets the Configuration value for state's 'Cache.DomainBlockMaxSize' field
func (st *ConfigState) SetCacheDomainBlockMaxSize(v int) {
st.mutex.Lock()
defer st.mutex.Unlock()
st.config.Cache.DomainBlockMaxSize = v
st.reloadToViper()
}
// CacheDomainBlockMaxSizeFlag returns the flag name for the 'Cache.DomainBlockMaxSize' field
func CacheDomainBlockMaxSizeFlag() string { return "cache-domain-block-max-size" }
// GetCacheDomainBlockMaxSize safely fetches the value for global configuration 'Cache.DomainBlockMaxSize' field
func GetCacheDomainBlockMaxSize() int { return global.GetCacheDomainBlockMaxSize() }
// SetCacheDomainBlockMaxSize safely sets the value for global configuration 'Cache.DomainBlockMaxSize' field
func SetCacheDomainBlockMaxSize(v int) { global.SetCacheDomainBlockMaxSize(v) }
// GetCacheDomainBlockTTL safely fetches the Configuration value for state's 'Cache.DomainBlockTTL' field
func (st *ConfigState) GetCacheDomainBlockTTL() (v time.Duration) {
st.mutex.Lock()
v = st.config.Cache.DomainBlockTTL
st.mutex.Unlock()
return
}
// SetCacheDomainBlockTTL safely sets the Configuration value for state's 'Cache.DomainBlockTTL' field
func (st *ConfigState) SetCacheDomainBlockTTL(v time.Duration) {
st.mutex.Lock()
defer st.mutex.Unlock()
st.config.Cache.DomainBlockTTL = v
st.reloadToViper()
}
// CacheDomainBlockTTLFlag returns the flag name for the 'Cache.DomainBlockTTL' field
func CacheDomainBlockTTLFlag() string { return "cache-domain-block-ttl" }
// GetCacheDomainBlockTTL safely fetches the value for global configuration 'Cache.DomainBlockTTL' field
func GetCacheDomainBlockTTL() time.Duration { return global.GetCacheDomainBlockTTL() }
// SetCacheDomainBlockTTL safely sets the value for global configuration 'Cache.DomainBlockTTL' field
func SetCacheDomainBlockTTL(v time.Duration) { global.SetCacheDomainBlockTTL(v) }
// GetCacheDomainBlockSweepFreq safely fetches the Configuration value for state's 'Cache.DomainBlockSweepFreq' field
func (st *ConfigState) GetCacheDomainBlockSweepFreq() (v time.Duration) {
st.mutex.Lock()
v = st.config.Cache.DomainBlockSweepFreq
st.mutex.Unlock()
return
}
// SetCacheDomainBlockSweepFreq safely sets the Configuration value for state's 'Cache.DomainBlockSweepFreq' field
func (st *ConfigState) SetCacheDomainBlockSweepFreq(v time.Duration) {
st.mutex.Lock()
defer st.mutex.Unlock()
st.config.Cache.DomainBlockSweepFreq = v
st.reloadToViper()
}
// CacheDomainBlockSweepFreqFlag returns the flag name for the 'Cache.DomainBlockSweepFreq' field
func CacheDomainBlockSweepFreqFlag() string { return "cache-domain-block-sweep-freq" }
// GetCacheDomainBlockSweepFreq safely fetches the value for global configuration 'Cache.DomainBlockSweepFreq' field
func GetCacheDomainBlockSweepFreq() time.Duration { return global.GetCacheDomainBlockSweepFreq() }
// SetCacheDomainBlockSweepFreq safely sets the value for global configuration 'Cache.DomainBlockSweepFreq' field
func SetCacheDomainBlockSweepFreq(v time.Duration) { global.SetCacheDomainBlockSweepFreq(v) }
// GetCacheEmojiMaxSize safely fetches the Configuration value for state's 'Cache.EmojiMaxSize' field
func (st *ConfigState) GetCacheEmojiMaxSize() (v int) {
st.mutex.Lock()
v = st.config.Cache.EmojiMaxSize
st.mutex.Unlock()
return
}
// SetCacheEmojiMaxSize safely sets the Configuration value for state's 'Cache.EmojiMaxSize' field
func (st *ConfigState) SetCacheEmojiMaxSize(v int) {
st.mutex.Lock()
defer st.mutex.Unlock()
st.config.Cache.EmojiMaxSize = v
st.reloadToViper()
}
// CacheEmojiMaxSizeFlag returns the flag name for the 'Cache.EmojiMaxSize' field
func CacheEmojiMaxSizeFlag() string { return "cache-emoji-max-size" }
// GetCacheEmojiMaxSize safely fetches the value for global configuration 'Cache.EmojiMaxSize' field
func GetCacheEmojiMaxSize() int { return global.GetCacheEmojiMaxSize() }
// SetCacheEmojiMaxSize safely sets the value for global configuration 'Cache.EmojiMaxSize' field
func SetCacheEmojiMaxSize(v int) { global.SetCacheEmojiMaxSize(v) }
// GetCacheEmojiTTL safely fetches the Configuration value for state's 'Cache.EmojiTTL' field
func (st *ConfigState) GetCacheEmojiTTL() (v time.Duration) {
st.mutex.Lock()
v = st.config.Cache.EmojiTTL
st.mutex.Unlock()
return
}
// SetCacheEmojiTTL safely sets the Configuration value for state's 'Cache.EmojiTTL' field
func (st *ConfigState) SetCacheEmojiTTL(v time.Duration) {
st.mutex.Lock()
defer st.mutex.Unlock()
st.config.Cache.EmojiTTL = v
st.reloadToViper()
}
// CacheEmojiTTLFlag returns the flag name for the 'Cache.EmojiTTL' field
func CacheEmojiTTLFlag() string { return "cache-emoji-ttl" }
// GetCacheEmojiTTL safely fetches the value for global configuration 'Cache.EmojiTTL' field
func GetCacheEmojiTTL() time.Duration { return global.GetCacheEmojiTTL() }
// SetCacheEmojiTTL safely sets the value for global configuration 'Cache.EmojiTTL' field
func SetCacheEmojiTTL(v time.Duration) { global.SetCacheEmojiTTL(v) }
// GetCacheEmojiSweepFreq safely fetches the Configuration value for state's 'Cache.EmojiSweepFreq' field
func (st *ConfigState) GetCacheEmojiSweepFreq() (v time.Duration) {
st.mutex.Lock()
v = st.config.Cache.EmojiSweepFreq
st.mutex.Unlock()
return
}
// SetCacheEmojiSweepFreq safely sets the Configuration value for state's 'Cache.EmojiSweepFreq' field
func (st *ConfigState) SetCacheEmojiSweepFreq(v time.Duration) {
st.mutex.Lock()
defer st.mutex.Unlock()
st.config.Cache.EmojiSweepFreq = v
st.reloadToViper()
}
// CacheEmojiSweepFreqFlag returns the flag name for the 'Cache.EmojiSweepFreq' field
func CacheEmojiSweepFreqFlag() string { return "cache-emoji-sweep-freq" }
// GetCacheEmojiSweepFreq safely fetches the value for global configuration 'Cache.EmojiSweepFreq' field
func GetCacheEmojiSweepFreq() time.Duration { return global.GetCacheEmojiSweepFreq() }
// SetCacheEmojiSweepFreq safely sets the value for global configuration 'Cache.EmojiSweepFreq' field
func SetCacheEmojiSweepFreq(v time.Duration) { global.SetCacheEmojiSweepFreq(v) }
// GetCacheEmojiCategoryMaxSize safely fetches the Configuration value for state's 'Cache.EmojiCategoryMaxSize' field
func (st *ConfigState) GetCacheEmojiCategoryMaxSize() (v int) {
st.mutex.Lock()
v = st.config.Cache.EmojiCategoryMaxSize
st.mutex.Unlock()
return
}
// SetCacheEmojiCategoryMaxSize safely sets the Configuration value for state's 'Cache.EmojiCategoryMaxSize' field
func (st *ConfigState) SetCacheEmojiCategoryMaxSize(v int) {
st.mutex.Lock()
defer st.mutex.Unlock()
st.config.Cache.EmojiCategoryMaxSize = v
st.reloadToViper()
}
// CacheEmojiCategoryMaxSizeFlag returns the flag name for the 'Cache.EmojiCategoryMaxSize' field
func CacheEmojiCategoryMaxSizeFlag() string { return "cache-emoji-category-max-size" }
// GetCacheEmojiCategoryMaxSize safely fetches the value for global configuration 'Cache.EmojiCategoryMaxSize' field
func GetCacheEmojiCategoryMaxSize() int { return global.GetCacheEmojiCategoryMaxSize() }
// SetCacheEmojiCategoryMaxSize safely sets the value for global configuration 'Cache.EmojiCategoryMaxSize' field
func SetCacheEmojiCategoryMaxSize(v int) { global.SetCacheEmojiCategoryMaxSize(v) }
// GetCacheEmojiCategoryTTL safely fetches the Configuration value for state's 'Cache.EmojiCategoryTTL' field
func (st *ConfigState) GetCacheEmojiCategoryTTL() (v time.Duration) {
st.mutex.Lock()
v = st.config.Cache.EmojiCategoryTTL
st.mutex.Unlock()
return
}
// SetCacheEmojiCategoryTTL safely sets the Configuration value for state's 'Cache.EmojiCategoryTTL' field
func (st *ConfigState) SetCacheEmojiCategoryTTL(v time.Duration) {
st.mutex.Lock()
defer st.mutex.Unlock()
st.config.Cache.EmojiCategoryTTL = v
st.reloadToViper()
}
// CacheEmojiCategoryTTLFlag returns the flag name for the 'Cache.EmojiCategoryTTL' field
func CacheEmojiCategoryTTLFlag() string { return "cache-emoji-category-ttl" }
// GetCacheEmojiCategoryTTL safely fetches the value for global configuration 'Cache.EmojiCategoryTTL' field
func GetCacheEmojiCategoryTTL() time.Duration { return global.GetCacheEmojiCategoryTTL() }
// SetCacheEmojiCategoryTTL safely sets the value for global configuration 'Cache.EmojiCategoryTTL' field
func SetCacheEmojiCategoryTTL(v time.Duration) { global.SetCacheEmojiCategoryTTL(v) }
// GetCacheEmojiCategorySweepFreq safely fetches the Configuration value for state's 'Cache.EmojiCategorySweepFreq' field
func (st *ConfigState) GetCacheEmojiCategorySweepFreq() (v time.Duration) {
st.mutex.Lock()
v = st.config.Cache.EmojiCategorySweepFreq
st.mutex.Unlock()
return
}
// SetCacheEmojiCategorySweepFreq safely sets the Configuration value for state's 'Cache.EmojiCategorySweepFreq' field
func (st *ConfigState) SetCacheEmojiCategorySweepFreq(v time.Duration) {
st.mutex.Lock()
defer st.mutex.Unlock()
st.config.Cache.EmojiCategorySweepFreq = v
st.reloadToViper()
}
// CacheEmojiCategorySweepFreqFlag returns the flag name for the 'Cache.EmojiCategorySweepFreq' field
func CacheEmojiCategorySweepFreqFlag() string { return "cache-emoji-category-sweep-freq" }
// GetCacheEmojiCategorySweepFreq safely fetches the value for global configuration 'Cache.EmojiCategorySweepFreq' field
func GetCacheEmojiCategorySweepFreq() time.Duration { return global.GetCacheEmojiCategorySweepFreq() }
// SetCacheEmojiCategorySweepFreq safely sets the value for global configuration 'Cache.EmojiCategorySweepFreq' field
func SetCacheEmojiCategorySweepFreq(v time.Duration) { global.SetCacheEmojiCategorySweepFreq(v) }
// GetCacheMentionMaxSize safely fetches the Configuration value for state's 'Cache.MentionMaxSize' field
func (st *ConfigState) GetCacheMentionMaxSize() (v int) {
st.mutex.Lock()
v = st.config.Cache.MentionMaxSize
st.mutex.Unlock()
return
}
// SetCacheMentionMaxSize safely sets the Configuration value for state's 'Cache.MentionMaxSize' field
func (st *ConfigState) SetCacheMentionMaxSize(v int) {
st.mutex.Lock()
defer st.mutex.Unlock()
st.config.Cache.MentionMaxSize = v
st.reloadToViper()
}
// CacheMentionMaxSizeFlag returns the flag name for the 'Cache.MentionMaxSize' field
func CacheMentionMaxSizeFlag() string { return "cache-mention-max-size" }
// GetCacheMentionMaxSize safely fetches the value for global configuration 'Cache.MentionMaxSize' field
func GetCacheMentionMaxSize() int { return global.GetCacheMentionMaxSize() }
// SetCacheMentionMaxSize safely sets the value for global configuration 'Cache.MentionMaxSize' field
func SetCacheMentionMaxSize(v int) { global.SetCacheMentionMaxSize(v) }
// GetCacheMentionTTL safely fetches the Configuration value for state's 'Cache.MentionTTL' field
func (st *ConfigState) GetCacheMentionTTL() (v time.Duration) {
st.mutex.Lock()
v = st.config.Cache.MentionTTL
st.mutex.Unlock()
return
}
// SetCacheMentionTTL safely sets the Configuration value for state's 'Cache.MentionTTL' field
func (st *ConfigState) SetCacheMentionTTL(v time.Duration) {
st.mutex.Lock()
defer st.mutex.Unlock()
st.config.Cache.MentionTTL = v
st.reloadToViper()
}
// CacheMentionTTLFlag returns the flag name for the 'Cache.MentionTTL' field
func CacheMentionTTLFlag() string { return "cache-mention-ttl" }
// GetCacheMentionTTL safely fetches the value for global configuration 'Cache.MentionTTL' field
func GetCacheMentionTTL() time.Duration { return global.GetCacheMentionTTL() }
// SetCacheMentionTTL safely sets the value for global configuration 'Cache.MentionTTL' field
func SetCacheMentionTTL(v time.Duration) { global.SetCacheMentionTTL(v) }
// GetCacheMentionSweepFreq safely fetches the Configuration value for state's 'Cache.MentionSweepFreq' field
func (st *ConfigState) GetCacheMentionSweepFreq() (v time.Duration) {
st.mutex.Lock()
v = st.config.Cache.MentionSweepFreq
st.mutex.Unlock()
return
}
// SetCacheMentionSweepFreq safely sets the Configuration value for state's 'Cache.MentionSweepFreq' field
func (st *ConfigState) SetCacheMentionSweepFreq(v time.Duration) {
st.mutex.Lock()
defer st.mutex.Unlock()
st.config.Cache.MentionSweepFreq = v
st.reloadToViper()
}
// CacheMentionSweepFreqFlag returns the flag name for the 'Cache.MentionSweepFreq' field
func CacheMentionSweepFreqFlag() string { return "cache-mention-sweep-freq" }
// GetCacheMentionSweepFreq safely fetches the value for global configuration 'Cache.MentionSweepFreq' field
func GetCacheMentionSweepFreq() time.Duration { return global.GetCacheMentionSweepFreq() }
// SetCacheMentionSweepFreq safely sets the value for global configuration 'Cache.MentionSweepFreq' field
func SetCacheMentionSweepFreq(v time.Duration) { global.SetCacheMentionSweepFreq(v) }
// GetCacheNotificationMaxSize safely fetches the Configuration value for state's 'Cache.NotificationMaxSize' field
func (st *ConfigState) GetCacheNotificationMaxSize() (v int) {
st.mutex.Lock()
v = st.config.Cache.NotificationMaxSize
st.mutex.Unlock()
return
}
// SetCacheNotificationMaxSize safely sets the Configuration value for state's 'Cache.NotificationMaxSize' field
func (st *ConfigState) SetCacheNotificationMaxSize(v int) {
st.mutex.Lock()
defer st.mutex.Unlock()
st.config.Cache.NotificationMaxSize = v
st.reloadToViper()
}
// CacheNotificationMaxSizeFlag returns the flag name for the 'Cache.NotificationMaxSize' field
func CacheNotificationMaxSizeFlag() string { return "cache-notification-max-size" }
// GetCacheNotificationMaxSize safely fetches the value for global configuration 'Cache.NotificationMaxSize' field
func GetCacheNotificationMaxSize() int { return global.GetCacheNotificationMaxSize() }
// SetCacheNotificationMaxSize safely sets the value for global configuration 'Cache.NotificationMaxSize' field
func SetCacheNotificationMaxSize(v int) { global.SetCacheNotificationMaxSize(v) }
// GetCacheNotificationTTL safely fetches the Configuration value for state's 'Cache.NotificationTTL' field
func (st *ConfigState) GetCacheNotificationTTL() (v time.Duration) {
st.mutex.Lock()
v = st.config.Cache.NotificationTTL
st.mutex.Unlock()
return
}
// SetCacheNotificationTTL safely sets the Configuration value for state's 'Cache.NotificationTTL' field
func (st *ConfigState) SetCacheNotificationTTL(v time.Duration) {
st.mutex.Lock()
defer st.mutex.Unlock()
st.config.Cache.NotificationTTL = v
st.reloadToViper()
}
// CacheNotificationTTLFlag returns the flag name for the 'Cache.NotificationTTL' field
func CacheNotificationTTLFlag() string { return "cache-notification-ttl" }
// GetCacheNotificationTTL safely fetches the value for global configuration 'Cache.NotificationTTL' field
func GetCacheNotificationTTL() time.Duration { return global.GetCacheNotificationTTL() }
// SetCacheNotificationTTL safely sets the value for global configuration 'Cache.NotificationTTL' field
func SetCacheNotificationTTL(v time.Duration) { global.SetCacheNotificationTTL(v) }
// GetCacheNotificationSweepFreq safely fetches the Configuration value for state's 'Cache.NotificationSweepFreq' field
func (st *ConfigState) GetCacheNotificationSweepFreq() (v time.Duration) {
st.mutex.Lock()
v = st.config.Cache.NotificationSweepFreq
st.mutex.Unlock()
return
}
// SetCacheNotificationSweepFreq safely sets the Configuration value for state's 'Cache.NotificationSweepFreq' field
func (st *ConfigState) SetCacheNotificationSweepFreq(v time.Duration) {
st.mutex.Lock()
defer st.mutex.Unlock()
st.config.Cache.NotificationSweepFreq = v
st.reloadToViper()
}
// CacheNotificationSweepFreqFlag returns the flag name for the 'Cache.NotificationSweepFreq' field
func CacheNotificationSweepFreqFlag() string { return "cache-notification-sweep-freq" }
// GetCacheNotificationSweepFreq safely fetches the value for global configuration 'Cache.NotificationSweepFreq' field
func GetCacheNotificationSweepFreq() time.Duration { return global.GetCacheNotificationSweepFreq() }
// SetCacheNotificationSweepFreq safely sets the value for global configuration 'Cache.NotificationSweepFreq' field
func SetCacheNotificationSweepFreq(v time.Duration) { global.SetCacheNotificationSweepFreq(v) }
// GetCacheStatusMaxSize safely fetches the Configuration value for state's 'Cache.StatusMaxSize' field
func (st *ConfigState) GetCacheStatusMaxSize() (v int) {
st.mutex.Lock()
v = st.config.Cache.StatusMaxSize
st.mutex.Unlock()
return
}
// SetCacheStatusMaxSize safely sets the Configuration value for state's 'Cache.StatusMaxSize' field
func (st *ConfigState) SetCacheStatusMaxSize(v int) {
st.mutex.Lock()
defer st.mutex.Unlock()
st.config.Cache.StatusMaxSize = v
st.reloadToViper()
}
// CacheStatusMaxSizeFlag returns the flag name for the 'Cache.StatusMaxSize' field
func CacheStatusMaxSizeFlag() string { return "cache-status-max-size" }
// GetCacheStatusMaxSize safely fetches the value for global configuration 'Cache.StatusMaxSize' field
func GetCacheStatusMaxSize() int { return global.GetCacheStatusMaxSize() }
// SetCacheStatusMaxSize safely sets the value for global configuration 'Cache.StatusMaxSize' field
func SetCacheStatusMaxSize(v int) { global.SetCacheStatusMaxSize(v) }
// GetCacheStatusTTL safely fetches the Configuration value for state's 'Cache.StatusTTL' field
func (st *ConfigState) GetCacheStatusTTL() (v time.Duration) {
st.mutex.Lock()
v = st.config.Cache.StatusTTL
st.mutex.Unlock()
return
}
// SetCacheStatusTTL safely sets the Configuration value for state's 'Cache.StatusTTL' field
func (st *ConfigState) SetCacheStatusTTL(v time.Duration) {
st.mutex.Lock()
defer st.mutex.Unlock()
st.config.Cache.StatusTTL = v
st.reloadToViper()
}
// CacheStatusTTLFlag returns the flag name for the 'Cache.StatusTTL' field
func CacheStatusTTLFlag() string { return "cache-status-ttl" }
// GetCacheStatusTTL safely fetches the value for global configuration 'Cache.StatusTTL' field
func GetCacheStatusTTL() time.Duration { return global.GetCacheStatusTTL() }
// SetCacheStatusTTL safely sets the value for global configuration 'Cache.StatusTTL' field
func SetCacheStatusTTL(v time.Duration) { global.SetCacheStatusTTL(v) }
// GetCacheStatusSweepFreq safely fetches the Configuration value for state's 'Cache.StatusSweepFreq' field
func (st *ConfigState) GetCacheStatusSweepFreq() (v time.Duration) {
st.mutex.Lock()
v = st.config.Cache.StatusSweepFreq
st.mutex.Unlock()
return
}
// SetCacheStatusSweepFreq safely sets the Configuration value for state's 'Cache.StatusSweepFreq' field
func (st *ConfigState) SetCacheStatusSweepFreq(v time.Duration) {
st.mutex.Lock()
defer st.mutex.Unlock()
st.config.Cache.StatusSweepFreq = v
st.reloadToViper()
}
// CacheStatusSweepFreqFlag returns the flag name for the 'Cache.StatusSweepFreq' field
func CacheStatusSweepFreqFlag() string { return "cache-status-sweep-freq" }
// GetCacheStatusSweepFreq safely fetches the value for global configuration 'Cache.StatusSweepFreq' field
func GetCacheStatusSweepFreq() time.Duration { return global.GetCacheStatusSweepFreq() }
// SetCacheStatusSweepFreq safely sets the value for global configuration 'Cache.StatusSweepFreq' field
func SetCacheStatusSweepFreq(v time.Duration) { global.SetCacheStatusSweepFreq(v) }
// GetCacheTombstoneMaxSize safely fetches the Configuration value for state's 'Cache.TombstoneMaxSize' field
func (st *ConfigState) GetCacheTombstoneMaxSize() (v int) {
st.mutex.Lock()
v = st.config.Cache.TombstoneMaxSize
st.mutex.Unlock()
return
}
// SetCacheTombstoneMaxSize safely sets the Configuration value for state's 'Cache.TombstoneMaxSize' field
func (st *ConfigState) SetCacheTombstoneMaxSize(v int) {
st.mutex.Lock()
defer st.mutex.Unlock()
st.config.Cache.TombstoneMaxSize = v
st.reloadToViper()
}
// CacheTombstoneMaxSizeFlag returns the flag name for the 'Cache.TombstoneMaxSize' field
func CacheTombstoneMaxSizeFlag() string { return "cache-tombstone-max-size" }
// GetCacheTombstoneMaxSize safely fetches the value for global configuration 'Cache.TombstoneMaxSize' field
func GetCacheTombstoneMaxSize() int { return global.GetCacheTombstoneMaxSize() }
// SetCacheTombstoneMaxSize safely sets the value for global configuration 'Cache.TombstoneMaxSize' field
func SetCacheTombstoneMaxSize(v int) { global.SetCacheTombstoneMaxSize(v) }
// GetCacheTombstoneTTL safely fetches the Configuration value for state's 'Cache.TombstoneTTL' field
func (st *ConfigState) GetCacheTombstoneTTL() (v time.Duration) {
st.mutex.Lock()
v = st.config.Cache.TombstoneTTL
st.mutex.Unlock()
return
}
// SetCacheTombstoneTTL safely sets the Configuration value for state's 'Cache.TombstoneTTL' field
func (st *ConfigState) SetCacheTombstoneTTL(v time.Duration) {
st.mutex.Lock()
defer st.mutex.Unlock()
st.config.Cache.TombstoneTTL = v
st.reloadToViper()
}
// CacheTombstoneTTLFlag returns the flag name for the 'Cache.TombstoneTTL' field
func CacheTombstoneTTLFlag() string { return "cache-tombstone-ttl" }
// GetCacheTombstoneTTL safely fetches the value for global configuration 'Cache.TombstoneTTL' field
func GetCacheTombstoneTTL() time.Duration { return global.GetCacheTombstoneTTL() }
// SetCacheTombstoneTTL safely sets the value for global configuration 'Cache.TombstoneTTL' field
func SetCacheTombstoneTTL(v time.Duration) { global.SetCacheTombstoneTTL(v) }
// GetCacheTombstoneSweepFreq safely fetches the Configuration value for state's 'Cache.TombstoneSweepFreq' field
func (st *ConfigState) GetCacheTombstoneSweepFreq() (v time.Duration) {
st.mutex.Lock()
v = st.config.Cache.TombstoneSweepFreq
st.mutex.Unlock()
return
}
// SetCacheTombstoneSweepFreq safely sets the Configuration value for state's 'Cache.TombstoneSweepFreq' field
func (st *ConfigState) SetCacheTombstoneSweepFreq(v time.Duration) {
st.mutex.Lock()
defer st.mutex.Unlock()
st.config.Cache.TombstoneSweepFreq = v
st.reloadToViper()
}
// CacheTombstoneSweepFreqFlag returns the flag name for the 'Cache.TombstoneSweepFreq' field
func CacheTombstoneSweepFreqFlag() string { return "cache-tombstone-sweep-freq" }
// GetCacheTombstoneSweepFreq safely fetches the value for global configuration 'Cache.TombstoneSweepFreq' field
func GetCacheTombstoneSweepFreq() time.Duration { return global.GetCacheTombstoneSweepFreq() }
// SetCacheTombstoneSweepFreq safely sets the value for global configuration 'Cache.TombstoneSweepFreq' field
func SetCacheTombstoneSweepFreq(v time.Duration) { global.SetCacheTombstoneSweepFreq(v) }
// GetCacheUserMaxSize safely fetches the Configuration value for state's 'Cache.UserMaxSize' field
func (st *ConfigState) GetCacheUserMaxSize() (v int) {
st.mutex.Lock()
v = st.config.Cache.UserMaxSize
st.mutex.Unlock()
return
}
// SetCacheUserMaxSize safely sets the Configuration value for state's 'Cache.UserMaxSize' field
func (st *ConfigState) SetCacheUserMaxSize(v int) {
st.mutex.Lock()
defer st.mutex.Unlock()
st.config.Cache.UserMaxSize = v
st.reloadToViper()
}
// CacheUserMaxSizeFlag returns the flag name for the 'Cache.UserMaxSize' field
func CacheUserMaxSizeFlag() string { return "cache-user-max-size" }
// GetCacheUserMaxSize safely fetches the value for global configuration 'Cache.UserMaxSize' field
func GetCacheUserMaxSize() int { return global.GetCacheUserMaxSize() }
// SetCacheUserMaxSize safely sets the value for global configuration 'Cache.UserMaxSize' field
func SetCacheUserMaxSize(v int) { global.SetCacheUserMaxSize(v) }
// GetCacheUserTTL safely fetches the Configuration value for state's 'Cache.UserTTL' field
func (st *ConfigState) GetCacheUserTTL() (v time.Duration) {
st.mutex.Lock()
v = st.config.Cache.UserTTL
st.mutex.Unlock()
return
}
// SetCacheUserTTL safely sets the Configuration value for state's 'Cache.UserTTL' field
func (st *ConfigState) SetCacheUserTTL(v time.Duration) {
st.mutex.Lock()
defer st.mutex.Unlock()
st.config.Cache.UserTTL = v
st.reloadToViper()
}
// CacheUserTTLFlag returns the flag name for the 'Cache.UserTTL' field
func CacheUserTTLFlag() string { return "cache-user-ttl" }
// GetCacheUserTTL safely fetches the value for global configuration 'Cache.UserTTL' field
func GetCacheUserTTL() time.Duration { return global.GetCacheUserTTL() }
// SetCacheUserTTL safely sets the value for global configuration 'Cache.UserTTL' field
func SetCacheUserTTL(v time.Duration) { global.SetCacheUserTTL(v) }
// GetCacheUserSweepFreq safely fetches the Configuration value for state's 'Cache.UserSweepFreq' field
func (st *ConfigState) GetCacheUserSweepFreq() (v time.Duration) {
st.mutex.Lock()
v = st.config.Cache.UserSweepFreq
st.mutex.Unlock()
return
}
// SetCacheUserSweepFreq safely sets the Configuration value for state's 'Cache.UserSweepFreq' field
func (st *ConfigState) SetCacheUserSweepFreq(v time.Duration) {
st.mutex.Lock()
defer st.mutex.Unlock()
st.config.Cache.UserSweepFreq = v
st.reloadToViper()
}
// CacheUserSweepFreqFlag returns the flag name for the 'Cache.UserSweepFreq' field
func CacheUserSweepFreqFlag() string { return "cache-user-sweep-freq" }
// GetCacheUserSweepFreq safely fetches the value for global configuration 'Cache.UserSweepFreq' field
func GetCacheUserSweepFreq() time.Duration { return global.GetCacheUserSweepFreq() }
// SetCacheUserSweepFreq safely sets the value for global configuration 'Cache.UserSweepFreq' field
func SetCacheUserSweepFreq(v time.Duration) { global.SetCacheUserSweepFreq(v) }
// GetAdminAccountUsername safely fetches the Configuration value for state's 'AdminAccountUsername' field
func (st *ConfigState) GetAdminAccountUsername() (v string) {
st.mutex.Lock()
@ -1944,4 +2698,3 @@ func GetAdminMediaPruneDryRun() bool { return global.GetAdminMediaPruneDryRun()
// SetAdminMediaPruneDryRun safely sets the value for global configuration 'AdminMediaPruneDryRun' field
func SetAdminMediaPruneDryRun(v bool) { global.SetAdminMediaPruneDryRun(v) }

View file

@ -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,