| 1 | package daemon |
| 2 | |
| 3 | import ( |
| 4 | "context" |
| 5 | "errors" |
| 6 | "time" |
| 7 | ) |
| 8 | |
| 9 | // Network synchronization has its own lifecycle so an unavailable peer does |
| 10 | // not delay local retention, view publication or upload cleanup. |
| 11 | func (t *Tenant) runGitHistory(ctx context.Context) { |
| 12 | timer := time.NewTimer(time.Second) |
| 13 | defer timer.Stop() |
| 14 | for { |
| 15 | select { |
| 16 | case <-ctx.Done(): |
| 17 | return |
| 18 | case <-timer.C: |
| 19 | } |
| 20 | if t.gitLiveEnabled() { |
| 21 | opCtx, done, err := t.beginOperation(ctx) |
| 22 | if err == nil { |
| 23 | passCtx, cancel := context.WithTimeout(opCtx, 5*time.Minute) |
| 24 | err = t.git.GRASPService().Tick(passCtx) |
| 25 | cancel() |
| 26 | done() |
| 27 | } |
| 28 | if err != nil && !errors.Is(err, context.Canceled) { |
| 29 | t.app.telemetry.Logger().Error("Git synchronization failed" , "tenant" , t.meta.Name, "error" , err) |
| 30 | } |
| 31 | } |
| 32 | timer.Reset(time.Minute) |
| 33 | } |
| 34 | } |