Fix lint
This commit is contained in:
parent
d2145bd1d9
commit
662e5d09ec
9 changed files with 22 additions and 15 deletions
|
@ -120,7 +120,10 @@ func New(cfg config.Alerting, opts ...AlertOption) Alerter {
|
||||||
|
|
||||||
// Go is the alerting loop. It does not start a goroutine.
|
// Go is the alerting loop. It does not start a goroutine.
|
||||||
func (as *alerter) Go(ctx context.Context) {
|
func (as *alerter) Go(ctx context.Context) {
|
||||||
as.startBackfill(ctx)
|
err := as.startBackfill(ctx)
|
||||||
|
if err != nil {
|
||||||
|
log.Error().Err(err).Msg("backfill")
|
||||||
|
}
|
||||||
|
|
||||||
as.score(time.Now())
|
as.score(time.Now())
|
||||||
ticker := time.NewTicker(alerterTickInterval)
|
ticker := time.NewTicker(alerterTickInterval)
|
||||||
|
@ -179,7 +182,7 @@ func (as *alerter) testNotifyHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
w.Write([]byte("Sent"))
|
_, _ = w.Write([]byte("Sent"))
|
||||||
}
|
}
|
||||||
|
|
||||||
// packedScoredTGs gets a packed list of TG IDs for DB use.
|
// packedScoredTGs gets a packed list of TG IDs for DB use.
|
||||||
|
@ -323,9 +326,9 @@ func (as *alerter) startBackfill(ctx context.Context) error {
|
||||||
log.Debug().Time("since", since).Msg("starting stats backfill")
|
log.Debug().Time("since", since).Msg("starting stats backfill")
|
||||||
count, err := as.backfill(ctx, since, now)
|
count, err := as.backfill(ctx, since, now)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("backfill failed: %w", err)
|
return err
|
||||||
}
|
}
|
||||||
log.Debug().Int("callsCount", count).Str("in", time.Now().Sub(now).String()).Int("tgCount", as.scorer.Score().Len()).Msg("backfill finished")
|
log.Debug().Int("callsCount", count).Str("in", time.Since(now).String()).Int("tgCount", as.scorer.Score().Len()).Msg("backfill finished")
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,7 +77,10 @@ func (s *Simulation) Simulate(ctx context.Context) trending.Scores[cl.Talkgroup]
|
||||||
sinceLookback := time.Time(scoreEnd).Add(-24 * time.Hour * time.Duration(s.LookbackDays))
|
sinceLookback := time.Time(scoreEnd).Add(-24 * time.Hour * time.Duration(s.LookbackDays))
|
||||||
|
|
||||||
// backfill from lookback start until score start
|
// backfill from lookback start until score start
|
||||||
s.backfill(ctx, sinceLookback, time.Time(s.ScoreStart))
|
_, err := s.backfill(ctx, sinceLookback, time.Time(s.ScoreStart))
|
||||||
|
if err != nil {
|
||||||
|
log.Error().Err(err).Msg("simulate backfill")
|
||||||
|
}
|
||||||
|
|
||||||
// initial score
|
// initial score
|
||||||
s.scores = s.scorer.Score()
|
s.scores = s.scorer.Score()
|
||||||
|
@ -94,7 +97,10 @@ func (s *Simulation) Simulate(ctx context.Context) trending.Scores[cl.Talkgroup]
|
||||||
|
|
||||||
// compute time since score start until now
|
// compute time since score start until now
|
||||||
// backfill from scorestart until now. sim is enabled, so scoring will be done by stepClock()
|
// backfill from scorestart until now. sim is enabled, so scoring will be done by stepClock()
|
||||||
s.backfill(ctx, time.Time(s.ScoreStart), scoreEnd)
|
_, err = s.backfill(ctx, time.Time(s.ScoreStart), scoreEnd)
|
||||||
|
if err != nil {
|
||||||
|
log.Error().Err(err).Msg("simulate backfill final")
|
||||||
|
}
|
||||||
|
|
||||||
s.lastScore = scoreEnd
|
s.lastScore = scoreEnd
|
||||||
sort.Sort(s.scores)
|
sort.Sort(s.scores)
|
||||||
|
|
|
@ -92,7 +92,7 @@ func pbServerInfo(ctx context.Context) *pb.ServerInfo {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *client) Hello(ctx context.Context) {
|
func (c *client) Hello(ctx context.Context) {
|
||||||
c.Send(&pb.Message{
|
_ = c.Send(&pb.Message{
|
||||||
ToClientMessage: &pb.Message_Hello{
|
ToClientMessage: &pb.Message_Hello{
|
||||||
Hello: &pb.Hello{
|
Hello: &pb.Hello{
|
||||||
ServerInfo: pbServerInfo(ctx),
|
ServerInfo: pbServerInfo(ctx),
|
||||||
|
|
|
@ -57,7 +57,7 @@ func (c *client) SendError(cmd *pb.Command, err error) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
c.Send(e)
|
_ = c.Send(e)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *client) Talkgroup(ctx context.Context, tg *pb.Talkgroup) error {
|
func (c *client) Talkgroup(ctx context.Context, tg *pb.Talkgroup) error {
|
||||||
|
@ -73,7 +73,7 @@ func (c *client) Talkgroup(ctx context.Context, tg *pb.Talkgroup) error {
|
||||||
var md *structpb.Struct
|
var md *structpb.Struct
|
||||||
if len(tgi.Metadata) > 0 {
|
if len(tgi.Metadata) > 0 {
|
||||||
m := make(map[string]interface{})
|
m := make(map[string]interface{})
|
||||||
err := json.Unmarshal(tgi.Metadata, m)
|
err := json.Unmarshal(tgi.Metadata, &m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error().Err(err).Int32("sys", tg.System).Int32("tg", tg.Talkgroup).Msg("unmarshal tg metadata")
|
log.Error().Err(err).Int32("sys", tg.System).Int32("tg", tg.Talkgroup).Msg("unmarshal tg metadata")
|
||||||
}
|
}
|
||||||
|
@ -95,7 +95,7 @@ func (c *client) Talkgroup(ctx context.Context, tg *pb.Talkgroup) error {
|
||||||
SystemName: tgi.SystemName,
|
SystemName: tgi.SystemName,
|
||||||
}
|
}
|
||||||
|
|
||||||
c.Send(&pb.Message{
|
_ = c.Send(&pb.Message{
|
||||||
ToClientMessage: &pb.Message_Response{
|
ToClientMessage: &pb.Message_Response{
|
||||||
Response: &pb.CommandResponse{
|
Response: &pb.CommandResponse{
|
||||||
CommandId: CommandID(ctx),
|
CommandId: CommandID(ctx),
|
||||||
|
|
|
@ -86,7 +86,7 @@ func (wm *wsManager) serveWS(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (conn *wsConn) Shutdown() {
|
func (conn *wsConn) Shutdown() {
|
||||||
conn.Conn.WriteControl(websocket.CloseMessage, websocket.FormatCloseMessage(websocket.CloseGoingAway, ""), time.Now().Add(writeWait))
|
_ = conn.Conn.WriteControl(websocket.CloseMessage, websocket.FormatCloseMessage(websocket.CloseGoingAway, ""), time.Now().Add(writeWait))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (conn *wsConn) readPump(ctx context.Context, reg Registry, c Client) {
|
func (conn *wsConn) readPump(ctx context.Context, reg Registry, c Client) {
|
||||||
|
|
|
@ -17,7 +17,6 @@ type Notifier interface {
|
||||||
|
|
||||||
type notifier struct {
|
type notifier struct {
|
||||||
*notify.Notify
|
*notify.Notify
|
||||||
cfg []config.NotifyService
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *notifier) buildSlackWebhookPayload(cfg config.NotifyService) func(string, string) any {
|
func (n *notifier) buildSlackWebhookPayload(cfg config.NotifyService) func(string, string) any {
|
||||||
|
|
|
@ -156,6 +156,7 @@ func RequestLogger() func(next http.Handler) http.Handler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//nolint:unused
|
||||||
const (
|
const (
|
||||||
colorBlack = iota + 30
|
colorBlack = iota + 30
|
||||||
colorRed
|
colorRed
|
||||||
|
|
|
@ -77,7 +77,7 @@ func (s *Server) clientRoute(r chi.Router, clientRoot fs.FS) {
|
||||||
func ServerHeaderAdd(next http.Handler) http.Handler {
|
func ServerHeaderAdd(next http.Handler) http.Handler {
|
||||||
serverString := version.HttpString("gordio")
|
serverString := version.HttpString("gordio")
|
||||||
hfn := func(w http.ResponseWriter, r *http.Request) {
|
hfn := func(w http.ResponseWriter, r *http.Request) {
|
||||||
w.Header().Set("Server", serverString)
|
w.Header().Set(serverHeader, serverString)
|
||||||
next.ServeHTTP(w, r)
|
next.ServeHTTP(w, r)
|
||||||
}
|
}
|
||||||
return http.HandlerFunc(hfn)
|
return http.HandlerFunc(hfn)
|
||||||
|
|
|
@ -47,8 +47,6 @@ func New(ctx context.Context, cfg *config.Config) (*Server, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx = database.CtxWithDB(ctx, db)
|
|
||||||
|
|
||||||
r := chi.NewRouter()
|
r := chi.NewRouter()
|
||||||
|
|
||||||
authenticator := auth.NewAuthenticator(cfg.Auth)
|
authenticator := auth.NewAuthenticator(cfg.Auth)
|
||||||
|
|
Loading…
Reference in a new issue