MCPcopy
hub / github.com/benbjohnson/litestream / monitorReplicaClient

Method monitorReplicaClient

vfs.go:2471–2496  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

2469}
2470
2471func (f *VFSFile) monitorReplicaClient(ctx context.Context) {
2472 ticker := time.NewTicker(f.PollInterval)
2473 defer ticker.Stop()
2474
2475 for {
2476 select {
2477 case <-ctx.Done():
2478 return
2479 case <-ticker.C:
2480 if f.hasTargetTime() {
2481 continue
2482 }
2483 if err := f.pollReplicaClient(ctx); err != nil {
2484 // Don't log context cancellation errors during shutdown
2485 if !errors.Is(err, context.Canceled) && !errors.Is(err, context.DeadlineExceeded) {
2486 f.logger.Error("cannot fetch new ltx files", "error", err)
2487 }
2488 } else {
2489 // Track successful poll time
2490 f.mu.Lock()
2491 f.lastPollSuccess = time.Now()
2492 f.mu.Unlock()
2493 }
2494 }
2495 }
2496}
2497
2498// pollReplicaClient fetches new LTX files from the replica client and updates
2499// the page index & the current position.

Callers 3

OpenMethod · 0.95
openNewDatabaseMethod · 0.95

Calls 7

hasTargetTimeMethod · 0.95
pollReplicaClientMethod · 0.95
StopMethod · 0.80
IsMethod · 0.80
ErrorMethod · 0.45
LockMethod · 0.45
UnlockMethod · 0.45

Tested by 1