Honeycomb und Control-Patch

This commit is contained in:
2026-08-04 05:28:51 +02:00
parent 23339a8be3
commit 3af51bf888
21 changed files with 1222 additions and 79 deletions
+11 -2
View File
@@ -29,6 +29,7 @@ type GLPIKBConfig struct {
SyncInterval time.Duration
Source string
CachePath string
ShouldSync func() bool
}
type GLPIKBStatus struct {
@@ -81,7 +82,9 @@ func (s *GLPIKBSyncer) Start(ctx context.Context) {
}
_ = s.LoadCache()
go func() {
s.runSync(ctx, "startup")
if s.syncAllowed() {
s.runSync(ctx, "startup")
}
ticker := time.NewTicker(s.cfg.SyncInterval)
defer ticker.Stop()
for {
@@ -90,12 +93,18 @@ func (s *GLPIKBSyncer) Start(ctx context.Context) {
case <-ctx.Done():
return
case <-ticker.C:
s.runSync(ctx, "interval")
if s.syncAllowed() {
s.runSync(ctx, "interval")
}
}
}
}()
}
func (s *GLPIKBSyncer) syncAllowed() bool {
return s.cfg.ShouldSync == nil || s.cfg.ShouldSync()
}
func (s *GLPIKBSyncer) runSync(ctx context.Context, trigger string) {
timeout := s.cfg.SyncInterval / 2
if timeout < 30*time.Second {