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

Function NewFromConfig

internal/requests/factory.go:11–34  ·  view source on GitHub ↗

NewFromConfig returns a ledger Store or nil when ledger is disabled.

(cfg *config.Config)

Source from the content-addressed store, hash-verified

9
10// NewFromConfig returns a ledger Store or nil when ledger is disabled.
11func NewFromConfig(cfg *config.Config) (Store, error) {
12 if cfg == nil || !cfg.Ledger.Enabled {
13 return nil, nil
14 }
15 d := strings.ToLower(strings.TrimSpace(cfg.Ledger.Driver))
16 switch d {
17 case "", "memory":
18 return NewMemoryStore(), nil
19 case "sqlite":
20 path := strings.TrimSpace(cfg.Ledger.Path)
21 if path == "" {
22 return nil, fmt.Errorf("ledger: sqlite path is empty")
23 }
24 return NewSQLiteStore(path)
25 case "postgres":
26 dsn := strings.TrimSpace(cfg.Ledger.DSN)
27 if dsn == "" {
28 return nil, fmt.Errorf("ledger: postgres dsn is empty")
29 }
30 return NewPostgresStore(dsn)
31 default:
32 return nil, fmt.Errorf("ledger: unsupported driver %q", cfg.Ledger.Driver)
33 }
34}

Callers 4

NewWithDependenciesFunction · 0.92
traceCmdFunction · 0.92
replayCmdFunction · 0.92
ledgerCmdFunction · 0.92

Calls 3

NewMemoryStoreFunction · 0.85
NewSQLiteStoreFunction · 0.85
NewPostgresStoreFunction · 0.85

Tested by

no test coverage detected