pomerium/internal/zero/controller/mux_log.go
Denis Mishin 0503b41108
zero/connect: add re-run health checks command (#5219)
* zero/connect: add run health checks and shutdown commands

* fix proto

* trigger re-run on command

* add handler

* rename runPeriodicHealthChecksLeased
2024-08-22 16:17:53 -04:00

38 lines
1.2 KiB
Go

package controller
import (
"context"
"github.com/rs/zerolog"
"google.golang.org/protobuf/encoding/protojson"
"github.com/pomerium/pomerium/internal/log"
connect_mux "github.com/pomerium/pomerium/internal/zero/connect-mux"
"github.com/pomerium/pomerium/pkg/zero/connect"
)
func (c *controller) RunConnectLog(ctx context.Context) error {
logger := log.Ctx(ctx).With().Str("service", "connect-mux").Logger().Level(zerolog.InfoLevel)
return c.api.Watch(ctx,
connect_mux.WithOnConnected(func(_ context.Context) {
logger.Debug().Msg("connected")
}),
connect_mux.WithOnDisconnected(func(_ context.Context) {
logger.Debug().Msg("disconnected")
}),
connect_mux.WithOnBootstrapConfigUpdated(func(_ context.Context) {
logger.Debug().Msg("bootstrap config updated")
}),
connect_mux.WithOnBundleUpdated(func(_ context.Context, key string) {
logger.Debug().Str("key", key).Msg("bundle updated")
}),
connect_mux.WithOnRunHealthChecks(func(_ context.Context) {
logger.Debug().Msg("run health checks")
}),
connect_mux.WithOnTelemetryRequested(func(_ context.Context, req *connect.TelemetryRequest) {
data, _ := protojson.Marshal(req)
logger.Debug().RawJSON("request", data).Msg("telemetry requested")
}),
)
}