refreshProxyProviders classifies every ai_providers row as enabled, disabled, or error so the proxy router and any observers see the full configured set. Disabled rows are excluded from routing; errored rows are excluded from routing and surface their failure reason for metrics and logs.
(db database.Store)
| 94 | // are excluded from routing and surface their failure reason for |
| 95 | // metrics and logs. |
| 96 | func refreshProxyProviders(db database.Store) aibridgeproxyd.RefreshProvidersFunc { |
| 97 | return func(ctx context.Context) (aibridgeproxyd.ProviderReload, error) { |
| 98 | //nolint:gocritic // AsAIProviderMetadataReader is the correct subject for routing-only access. |
| 99 | rows, err := db.GetAIProviders(dbauthz.AsAIProviderMetadataReader(ctx), database.GetAIProvidersParams{ |
| 100 | IncludeDisabled: true, |
| 101 | }) |
| 102 | if err != nil { |
| 103 | return aibridgeproxyd.ProviderReload{}, xerrors.Errorf("load ai providers: %w", err) |
| 104 | } |
| 105 | reload := aibridgeproxyd.ProviderReload{ |
| 106 | Providers: make([]aibridgeproxyd.ReloadedProvider, 0, len(rows)), |
| 107 | } |
| 108 | seenHost := make(map[string]string, len(rows)) |
| 109 | for _, row := range rows { |
| 110 | reload.Providers = append(reload.Providers, classifyProviderRow(row, seenHost)) |
| 111 | } |
| 112 | return reload, nil |
| 113 | } |
| 114 | } |
| 115 | |
| 116 | // classifyProviderRow evaluates a single ai_providers row for routing. |
| 117 | // seenHost is mutated to track the first provider that claimed each |
no test coverage detected