gateway: fix diagnostics/prefixwatcher HTTP endpoint
GitOrigin-RevId:
@@ -89,7 +89,8 @@ func (wf *WatcherFactory) New(
) control.Runner {
pather := wf.PathMonitor.Register(remote, wf.Policies, "gateway-watcher")
- watcher := &control.GatewayWatcher{
+ return &watcherWrapper{
+ GatewayWatcher: control.GatewayWatcher{
Remote: remote,
Discoverer: controlgrpc.Discoverer{
Remote: remote,
@@ -104,16 +105,18 @@ func (wf *WatcherFactory) New(
},
},
Metrics: metrics,
+ },
+ pather: pather,
}
- return runnerFunc(func(ctx context.Context) error {
- err := watcher.Run(ctx)
- pather.Close()
- return err
- })
}
-type runnerFunc func(ctx context.Context) error
+type watcherWrapper struct {
+ control.GatewayWatcher
+ pather control.PathMonitorRegistration
+}
-func (f runnerFunc) Run(ctx context.Context) error {
- return f(ctx)
+func (w *watcherWrapper) Run(ctx context.Context) error {
+ err := w.GatewayWatcher.Run(ctx)
+ w.pather.Close()
+ return err
}
