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

Method Do

cmd/cache-proxy/proxy.go:87–110  ·  view source on GitHub ↗
(key string, fn func() (fetchResult, error))

Source from the content-addressed store, hash-verified

85 // lets subsequent requests in the same process emit precise range headers
86 // and reject starts beyond EOF without another origin request.
87 objectSizes sync.Map // map[string]int64, keyed by full object URL
88}
89
90// fetchResult describes a body that fetchDedup has materialized onto local
91// disk under its cache key. It deliberately carries no body bytes — the data
92// lives on NVMe and is served by streaming straight from the file, so a flood
93// of concurrent fetches no longer pins one buffer per request in memory.
94type fetchResult struct {
95 size int64
96 contentType string // origin Content-Type ("" for peer fetches and hits)
97 source string // "peer" or "miss"
98}
99
100const (
101 defaultOriginTimeout = 60 * time.Second
102 defaultOriginRetryMaxAttempts = 4
103 defaultOriginRetryInitialBackoff = 100 * time.Millisecond
104 defaultOriginRetryMaxBackoff = 1 * time.Second
105)
106
107type singleFlight struct {
108 mu sync.Mutex
109 m map[string]*call
110}
111
112type call struct {
113 wg sync.WaitGroup

Calls 2

fnFunction · 0.85
AddMethod · 0.80