chore: move defaults to constants

Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
This commit is contained in:
Ettore Di Giacinto
2025-12-16 17:40:51 +01:00
parent f3c70a96ba
commit b348a99b03
2 changed files with 7 additions and 4 deletions

View File

@@ -4,7 +4,10 @@ import (
"time"
)
const DefaultWatchdogInterval = 500 * time.Millisecond
const (
DefaultWatchdogInterval = 500 * time.Millisecond
DefaultMemoryReclaimerThreshold = 0.80
)
// WatchDogOptions contains all configuration for the WatchDog
type WatchDogOptions struct {
@@ -112,7 +115,7 @@ func DefaultWatchDogOptions() *WatchDogOptions {
idleCheck: false,
lruLimit: 0,
memoryReclaimerEnabled: false,
memoryReclaimerThreshold: 0.80,
memoryReclaimerThreshold: DefaultMemoryReclaimerThreshold,
}
}

View File

@@ -107,7 +107,7 @@ var _ = Describe("WatchDog", func() {
model.WithProcessManager(pm),
)
_, threshold := wd.GetMemoryReclaimerSettings()
Expect(threshold).To(Equal(0.95)) // default
Expect(threshold).To(Equal(model.DefaultMemoryReclaimerThreshold))
})
It("should allow updating memory reclaimer settings dynamically", func() {
@@ -318,7 +318,7 @@ var _ = Describe("WatchDog", func() {
enabled, threshold := wd.GetMemoryReclaimerSettings()
Expect(enabled).To(BeFalse())
Expect(threshold).To(Equal(0.95))
Expect(threshold).To(Equal(model.DefaultMemoryReclaimerThreshold))
})
It("should allow combining multiple options", func() {