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.
()
| 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. |
| 121 | func 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 | } |
no test coverage detected