| 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. |
| 94 | type fetchResult struct { |
| 95 | size int64 |
| 96 | contentType string // origin Content-Type ("" for peer fetches and hits) |
| 97 | source string // "peer" or "miss" |
| 98 | } |
| 99 | |
| 100 | const ( |
| 101 | defaultOriginTimeout = 60 * time.Second |
| 102 | defaultOriginRetryMaxAttempts = 4 |
| 103 | defaultOriginRetryInitialBackoff = 100 * time.Millisecond |
| 104 | defaultOriginRetryMaxBackoff = 1 * time.Second |
| 105 | ) |
| 106 | |
| 107 | type singleFlight struct { |
| 108 | mu sync.Mutex |
| 109 | m map[string]*call |
| 110 | } |
| 111 | |
| 112 | type call struct { |
| 113 | wg sync.WaitGroup |