MCPcopy Index your code
hub / github.com/coder/coder / refreshProxyProviders

Function refreshProxyProviders

enterprise/cli/aibridgeproxyd.go:96–114  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

94// are excluded from routing and surface their failure reason for
95// metrics and logs.
96func 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

Callers 1

newAIBridgeProxyDaemonFunction · 0.85

Calls 4

classifyProviderRowFunction · 0.85
GetAIProvidersMethod · 0.65
ErrorfMethod · 0.45

Tested by

no test coverage detected