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

Function waitForCacheProxy

duckdbservice/cache_proxy.go:112–133  ·  view source on GitHub ↗

waitForCacheProxy blocks until the local cache proxy responds healthy. When the cache is disabled, returns immediately (no-op). If the worker starts before the proxy is ready, DuckDB's first S3 requests would fail. Block startup until the proxy is up.

()

Source from the content-addressed store, hash-verified

110 region = "us-east-1"
111 }
112 cfg.S3Endpoint = "s3." + region + ".amazonaws.com"
113 }
114 cfg.HTTPProxy = proxyURL
115 cfg.S3UseSSL = false
116}
117
118// cacheProxyConnectTimeout is deliberately configurable because a node may
119// need a little time to mount NVMe after a restart. It is always bounded: the
120// cache is an optimization, not a worker-startup dependency.
121func cacheProxyConnectTimeout() time.Duration {
122 value := os.Getenv("DUCKGRES_CACHE_PROXY_CONNECT_TIMEOUT")
123 if value == "" {
124 return defaultCacheProxyConnectTimeout
125 }
126 timeout, err := time.ParseDuration(value)
127 if err != nil || timeout <= 0 {
128 slog.Warn("Invalid DUCKGRES_CACHE_PROXY_CONNECT_TIMEOUT; using default.",
129 "value", value, "default", defaultCacheProxyConnectTimeout, "error", err)
130 return defaultCacheProxyConnectTimeout
131 }
132 if timeout > maxCacheProxyConnectTimeout {
133 slog.Warn("DUCKGRES_CACHE_PROXY_CONNECT_TIMEOUT exceeds the safe maximum; clamping.",
134 "value", timeout, "maximum", maxCacheProxyConnectTimeout)
135 return maxCacheProxyConnectTimeout
136 }

Callers 1

WarmupMethod · 0.85

Calls 4

cacheProxyHealthURLFunction · 0.85
NowMethod · 0.80
CloseMethod · 0.65
GetMethod · 0.45

Tested by

no test coverage detected