feat: Implement notification rate limiting mechanism

- Add in-memory and Redis-based notification rate limiting
- Create configurable hourly notification limits
- Implement notification limit checking for user notifications
- Add environment variables for customizing notification limits
This commit is contained in:
1808837298@qq.com
2025-02-18 15:30:43 +08:00
parent 9d9c461c48
commit 56f6b2ab56
4 changed files with 138 additions and 1 deletions

View File

@@ -356,6 +356,13 @@ func CompletionRatio2JSONString() string {
return string(jsonBytes)
}
func UpdateCompletionRatioByJSONString(jsonStr string) error {
CompletionRatioMutex.Lock()
defer CompletionRatioMutex.Unlock()
CompletionRatio = make(map[string]float64)
return json.Unmarshal([]byte(jsonStr), &CompletionRatio)
}
func GetCompletionRatio(name string) float64 {
GetCompletionRatioMap()