MCPcopy Create free account
hub / github.com/PostHog/duckgres / snapshot

Method snapshot

server/recent_errors.go:64–81  ·  view source on GitHub ↗

snapshot returns up to limit most-recent errors, newest first (limit <= 0 returns all retained).

(limit int)

Source from the content-addressed store, hash-verified

62// snapshot returns up to limit most-recent errors, newest first (limit <= 0
63// returns all retained).
64func (r *recentErrorRing) snapshot(limit int) []RecentError {
65 if r == nil {
66 return nil
67 }
68 r.mu.Lock()
69 defer r.mu.Unlock()
70 count := r.n
71 if limit > 0 && limit < count {
72 count = limit
73 }
74 out := make([]RecentError, 0, count)
75 idx := (r.next - 1 + len(r.buf)) % len(r.buf)
76 for i := 0; i < count; i++ {
77 out = append(out, r.buf[idx])
78 idx = (idx - 1 + len(r.buf)) % len(r.buf)
79 }
80 return out
81}
82
83// recordRecentError adds a redacted error to the server's ring (nil-safe).
84func (s *Server) recordRecentError(e RecentError) {

Callers 3

RecentErrorsMethod · 0.45

Calls

no outgoing calls