MCPcopy Index your code
hub / github.com/InferCore/InferCore / Load

Function Load

internal/config/config.go:190–260  ·  view source on GitHub ↗
(path string)

Source from the content-addressed store, hash-verified

188}
189
190func Load(path string) (*Config, error) {
191 raw, err := os.ReadFile(path)
192 if err != nil {
193 return nil, fmt.Errorf("read config: %w", err)
194 }
195
196 expanded := expandEnvVars(string(raw))
197
198 var cfg Config
199 if err := yaml.Unmarshal([]byte(expanded), &cfg); err != nil {
200 return nil, fmt.Errorf("unmarshal yaml: %w", err)
201 }
202
203 if cfg.Server.Port == 0 {
204 cfg.Server.Port = 8080
205 }
206 if cfg.Server.RequestTimeoutMS <= 0 {
207 cfg.Server.RequestTimeoutMS = 3000
208 }
209 if cfg.Server.HealthCacheTTLMS <= 0 {
210 cfg.Server.HealthCacheTTLMS = 2000
211 }
212 if cfg.Server.HealthCheckPerMS <= 0 {
213 cfg.Server.HealthCheckPerMS = 1500
214 }
215 if cfg.Telemetry.LogLevel == "" {
216 cfg.Telemetry.LogLevel = "info"
217 }
218 if cfg.Telemetry.Exporter == "" {
219 if strings.TrimSpace(cfg.Telemetry.OTLPEndpoint) != "" {
220 cfg.Telemetry.Exporter = "otlp-http"
221 } else {
222 cfg.Telemetry.Exporter = "log"
223 }
224 }
225 if cfg.Telemetry.OTLPTimeoutMS <= 0 {
226 cfg.Telemetry.OTLPTimeoutMS = 1000
227 }
228 if cfg.Telemetry.OTLPRetries < 0 {
229 cfg.Telemetry.OTLPRetries = 0
230 }
231 if cfg.Telemetry.OTLPBatchSize <= 0 {
232 cfg.Telemetry.OTLPBatchSize = 10
233 }
234 if cfg.Telemetry.OTLPFlushMS <= 0 {
235 cfg.Telemetry.OTLPFlushMS = 1000
236 }
237 if cfg.Routing.DefaultBackend == "" && len(cfg.Backends) > 0 {
238 cfg.Routing.DefaultBackend = cfg.Backends[0].Name
239 }
240 if cfg.Reliability.Overload.QueueLimit <= 0 {
241 cfg.Reliability.Overload.QueueLimit = 200
242 }
243 if cfg.Reliability.Overload.Action == "" {
244 cfg.Reliability.Overload.Action = "degrade"
245 }
246 if cfg.SLO.MaxRecords <= 0 {
247 cfg.SLO.MaxRecords = 10000

Callers 15

serveCmdFunction · 0.92
traceCmdFunction · 0.92
replayCmdFunction · 0.92
ledgerCmdFunction · 0.92
TestLoad_ValidConfigFunction · 0.85

Calls 2

validateMethod · 0.95
expandEnvVarsFunction · 0.85