refactor: use Options struct in aibridgedserver.NewServer (#27200)

Refactor `aibridgedserver.NewServer` to take an `Options` struct instead
of a long list of positional arguments. Follow-up to review feedback in
https://github.com/coder/coder/pull/27117#discussion_r3571535760
This commit is contained in:
Susana Ferreira
2026-07-16 16:09:25 +01:00
committed by GitHub
parent 77582be805
commit 101aee8ee0
5 changed files with 219 additions and 64 deletions
+11 -12
View File
@@ -134,18 +134,17 @@ func (api *API) aiGatewayServe(rw http.ResponseWriter, r *http.Request) {
go aiGatewayCheckEntitlementAndTrackKeyUsage(connCtx, keyCtxCancel, api, gatewayKey.ID, logger)
mux := drpcmux.New()
srv, err := aibridgedserver.NewServer(
connCtx,
api.Database,
api.AGPL.Pubsub,
logger,
api.AccessURL.String(),
api.DeploymentValues.AI.BridgeConfig,
api.ExternalAuthConfigs,
api.AGPL.Experiments,
api.AGPL.AISeatTracker,
api.AGPL.Clock,
)
srv, err := aibridgedserver.NewServer(connCtx, aibridgedserver.Options{
Store: api.Database,
Pubsub: api.AGPL.Pubsub,
AISeatTracker: api.AGPL.AISeatTracker,
AccessURL: api.AccessURL.String(),
GatewayCfg: api.DeploymentValues.AI.BridgeConfig,
ExternalAuthConfigs: api.ExternalAuthConfigs,
Experiments: api.AGPL.Experiments,
Logger: logger,
Clock: api.AGPL.Clock,
})
if err != nil {
if !xerrors.Is(err, context.Canceled) {
logger.Error(connCtx, "server creation failed", slog.Error(err))