summaryrefslogtreecommitdiff
path: root/internal/config
diff options
context:
space:
mode:
authorLibravatar Vyr Cossont <VyrCossont@users.noreply.github.com>2024-03-06 02:15:58 -0800
committerLibravatar GitHub <noreply@github.com>2024-03-06 11:15:58 +0100
commit61a2b91f454a6eb0dd383fc8614fee154654fa08 (patch)
treefcf6159f00c3a0833e6647dd00cd03d03774e2b2 /internal/config
parent[chore]: Bump github.com/stretchr/testify from 1.8.4 to 1.9.0 (#2714) (diff)
downloadgotosocial-61a2b91f454a6eb0dd383fc8614fee154654fa08.tar.xz
[feature] Filters v1 (#2594)
* Implement client-side v1 filters * Exclude linter false positives * Update test/envparsing.sh * Fix minor Swagger, style, and Bun usage issues * Regenerate Swagger * De-generify filter keywords * Remove updating filter statuses This is an operation that the Mastodon v2 filter API doesn't actually have, because filter statuses, unlike keywords, don't have options: the only info they contain is the status ID to be filtered. * Add a test for filter statuses specifically * De-generify filter statuses * Inline FilterEntry * Use vertical style for Bun operations consistently * Add comment on Filter DB interface * Remove GoLand linter control comments Our existing linters should catch these, or they don't matter very much * Reduce memory ratio for filters
Diffstat (limited to 'internal/config')
-rw-r--r--internal/config/config.go3
-rw-r--r--internal/config/defaults.go3
-rw-r--r--internal/config/helpers.gen.go75
3 files changed, 81 insertions, 0 deletions
diff --git a/internal/config/config.go b/internal/config/config.go
index c810222a1..ea84a4af7 100644
--- a/internal/config/config.go
+++ b/internal/config/config.go
@@ -201,6 +201,9 @@ type CacheConfiguration struct {
BoostOfIDsMemRatio float64 `name:"boost-of-ids-mem-ratio"`
EmojiMemRatio float64 `name:"emoji-mem-ratio"`
EmojiCategoryMemRatio float64 `name:"emoji-category-mem-ratio"`
+ FilterMemRatio float64 `name:"filter-mem-ratio"`
+ FilterKeywordMemRatio float64 `name:"filter-keyword-mem-ratio"`
+ FilterStatusMemRatio float64 `name:"filter-status-mem-ratio"`
FollowMemRatio float64 `name:"follow-mem-ratio"`
FollowIDsMemRatio float64 `name:"follow-ids-mem-ratio"`
FollowRequestMemRatio float64 `name:"follow-request-mem-ratio"`
diff --git a/internal/config/defaults.go b/internal/config/defaults.go
index 78474539f..c98b54b0b 100644
--- a/internal/config/defaults.go
+++ b/internal/config/defaults.go
@@ -165,6 +165,9 @@ var Defaults = Configuration{
BoostOfIDsMemRatio: 3,
EmojiMemRatio: 3,
EmojiCategoryMemRatio: 0.1,
+ FilterMemRatio: 0.5,
+ FilterKeywordMemRatio: 0.5,
+ FilterStatusMemRatio: 0.5,
FollowMemRatio: 2,
FollowIDsMemRatio: 4,
FollowRequestMemRatio: 2,
diff --git a/internal/config/helpers.gen.go b/internal/config/helpers.gen.go
index f458074b1..c5d4c992b 100644
--- a/internal/config/helpers.gen.go
+++ b/internal/config/helpers.gen.go
@@ -2975,6 +2975,81 @@ func GetCacheEmojiCategoryMemRatio() float64 { return global.GetCacheEmojiCatego
// SetCacheEmojiCategoryMemRatio safely sets the value for global configuration 'Cache.EmojiCategoryMemRatio' field
func SetCacheEmojiCategoryMemRatio(v float64) { global.SetCacheEmojiCategoryMemRatio(v) }
+// GetCacheFilterMemRatio safely fetches the Configuration value for state's 'Cache.FilterMemRatio' field
+func (st *ConfigState) GetCacheFilterMemRatio() (v float64) {
+ st.mutex.RLock()
+ v = st.config.Cache.FilterMemRatio
+ st.mutex.RUnlock()
+ return
+}
+
+// SetCacheFilterMemRatio safely sets the Configuration value for state's 'Cache.FilterMemRatio' field
+func (st *ConfigState) SetCacheFilterMemRatio(v float64) {
+ st.mutex.Lock()
+ defer st.mutex.Unlock()
+ st.config.Cache.FilterMemRatio = v
+ st.reloadToViper()
+}
+
+// CacheFilterMemRatioFlag returns the flag name for the 'Cache.FilterMemRatio' field
+func CacheFilterMemRatioFlag() string { return "cache-filter-mem-ratio" }
+
+// GetCacheFilterMemRatio safely fetches the value for global configuration 'Cache.FilterMemRatio' field
+func GetCacheFilterMemRatio() float64 { return global.GetCacheFilterMemRatio() }
+
+// SetCacheFilterMemRatio safely sets the value for global configuration 'Cache.FilterMemRatio' field
+func SetCacheFilterMemRatio(v float64) { global.SetCacheFilterMemRatio(v) }
+
+// GetCacheFilterKeywordMemRatio safely fetches the Configuration value for state's 'Cache.FilterKeywordMemRatio' field
+func (st *ConfigState) GetCacheFilterKeywordMemRatio() (v float64) {
+ st.mutex.RLock()
+ v = st.config.Cache.FilterKeywordMemRatio
+ st.mutex.RUnlock()
+ return
+}
+
+// SetCacheFilterKeywordMemRatio safely sets the Configuration value for state's 'Cache.FilterKeywordMemRatio' field
+func (st *ConfigState) SetCacheFilterKeywordMemRatio(v float64) {
+ st.mutex.Lock()
+ defer st.mutex.Unlock()
+ st.config.Cache.FilterKeywordMemRatio = v
+ st.reloadToViper()
+}
+
+// CacheFilterKeywordMemRatioFlag returns the flag name for the 'Cache.FilterKeywordMemRatio' field
+func CacheFilterKeywordMemRatioFlag() string { return "cache-filter-keyword-mem-ratio" }
+
+// GetCacheFilterKeywordMemRatio safely fetches the value for global configuration 'Cache.FilterKeywordMemRatio' field
+func GetCacheFilterKeywordMemRatio() float64 { return global.GetCacheFilterKeywordMemRatio() }
+
+// SetCacheFilterKeywordMemRatio safely sets the value for global configuration 'Cache.FilterKeywordMemRatio' field
+func SetCacheFilterKeywordMemRatio(v float64) { global.SetCacheFilterKeywordMemRatio(v) }
+
+// GetCacheFilterStatusMemRatio safely fetches the Configuration value for state's 'Cache.FilterStatusMemRatio' field
+func (st *ConfigState) GetCacheFilterStatusMemRatio() (v float64) {
+ st.mutex.RLock()
+ v = st.config.Cache.FilterStatusMemRatio
+ st.mutex.RUnlock()
+ return
+}
+
+// SetCacheFilterStatusMemRatio safely sets the Configuration value for state's 'Cache.FilterStatusMemRatio' field
+func (st *ConfigState) SetCacheFilterStatusMemRatio(v float64) {
+ st.mutex.Lock()
+ defer st.mutex.Unlock()
+ st.config.Cache.FilterStatusMemRatio = v
+ st.reloadToViper()
+}
+
+// CacheFilterStatusMemRatioFlag returns the flag name for the 'Cache.FilterStatusMemRatio' field
+func CacheFilterStatusMemRatioFlag() string { return "cache-filter-status-mem-ratio" }
+
+// GetCacheFilterStatusMemRatio safely fetches the value for global configuration 'Cache.FilterStatusMemRatio' field
+func GetCacheFilterStatusMemRatio() float64 { return global.GetCacheFilterStatusMemRatio() }
+
+// SetCacheFilterStatusMemRatio safely sets the value for global configuration 'Cache.FilterStatusMemRatio' field
+func SetCacheFilterStatusMemRatio(v float64) { global.SetCacheFilterStatusMemRatio(v) }
+
// GetCacheFollowMemRatio safely fetches the Configuration value for state's 'Cache.FollowMemRatio' field
func (st *ConfigState) GetCacheFollowMemRatio() (v float64) {
st.mutex.RLock()