Skip to content

Commit

Permalink
Merge branch 'main' into improve-grouping
Browse files Browse the repository at this point in the history
  • Loading branch information
bradengroom authored Oct 11, 2023
2 parents 7eb55ff + 786555c commit 4f0692f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 6 additions & 1 deletion internal/gateway/gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,19 @@ func NewHandler(ctx context.Context, upstreamAddr, upstreamTLSCertPath string) (
return nil, err
}

experimentalConn, err := registerHandler(ctx, gwMux, upstreamAddr, opts, v1.RegisterExperimentalServiceHandler)
if err != nil {
return nil, err
}

mux := http.NewServeMux()
mux.Handle("/openapi.json", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
_, _ = io.WriteString(w, proto.OpenAPISchema)
}))
mux.Handle("/", gwMux)

finalHandler := promhttp.InstrumentHandlerDuration(histogram, otelhttp.NewHandler(mux, "gateway"))
return newCloserHandler(finalHandler, schemaConn, permissionsConn, watchConn, healthConn), nil
return newCloserHandler(finalHandler, schemaConn, permissionsConn, watchConn, healthConn, experimentalConn), nil
}

// CloserHandler is a http.Handler and a io.Closer. Meant to keep track of resources to closer
Expand Down
4 changes: 2 additions & 2 deletions internal/gateway/gateway_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ func TestCloseConnections(t *testing.T) {

gatewayHandler, err := NewHandler(context.Background(), "192.0.2.0:4321", "")
require.NoError(t, err)
// 3 conns for permission+schema+watch services, 1 for health check
require.Len(t, gatewayHandler.closers, 4)
// 4 conns for permission+schema+watch+experimental services, 1 for health check
require.Len(t, gatewayHandler.closers, 5)

// if connections are not closed, goleak would detect it
require.NoError(t, gatewayHandler.Close())
Expand Down

0 comments on commit 4f0692f

Please sign in to comment.