Fix linting errors

This commit is contained in:
Torjus Håkestad 2025-02-08 22:29:21 +01:00
parent 1cd56f1525
commit 558d0f4929
Signed by: torjus
SSH Key Fingerprint: SHA256:KjAds8wHfD2mBYK2H815s/+ABcSdcIHUndwHEdSxml4
3 changed files with 15 additions and 7 deletions

View File

@ -47,7 +47,9 @@ func (n *NotifyBus) ServerInfo() (*NotifyServerInfo, error) {
} }
srvInfo := &NotifyServerInfo{} srvInfo := &NotifyServerInfo{}
call.Store(&srvInfo.Name, &srvInfo.Vendor, &srvInfo.Version, &srvInfo.SpecVersion) if err := call.Store(&srvInfo.Name, &srvInfo.Vendor, &srvInfo.Version, &srvInfo.SpecVersion); err != nil {
return nil, err
}
return srvInfo, nil return srvInfo, nil
} }
@ -70,7 +72,9 @@ func (n *NotifyBus) Notify(notification BusNotification) (uint32, error) {
return ret, call.Err return ret, call.Err
} }
call.Store(&ret) if err := call.Store(&ret); err != nil {
return 0, err
}
return ret, nil return ret, nil
} }

View File

@ -147,7 +147,7 @@ func main() {
fmt.Printf("Error connecting to NATS: %s\n", err) fmt.Printf("Error connecting to NATS: %s\n", err)
return cli.Exit(err, 1) return cli.Exit(err, 1)
} }
defer nc.Drain() defer nc.Drain() // nolint: errcheck
data, err := json.Marshal(bn) data, err := json.Marshal(bn)
if err != nil { if err != nil {

View File

@ -23,8 +23,8 @@ func New(nc *nats.Conn, b *bus.NotifyBus) (*Server, error) {
return &Server{conn: nc, Subject: DefaultSubject, bus: b}, nil return &Server{conn: nc, Subject: DefaultSubject, bus: b}, nil
} }
func (s *Server) Close() { func (s *Server) Close() error {
s.conn.Drain() return s.conn.Drain()
} }
func (s *Server) Start() error { func (s *Server) Start() error {
@ -59,14 +59,18 @@ func (s *Server) Start() error {
if err := json.Unmarshal(msg.Data(), &bn); err != nil { if err := json.Unmarshal(msg.Data(), &bn); err != nil {
slog.Warn("Error unmarshalling message", "error", err) slog.Warn("Error unmarshalling message", "error", err)
msg.TermWithReason("failed to decode json") if err := msg.TermWithReason("failed to decode json"); err != nil {
slog.Error("Error terminating message", "error", err)
}
return return
} }
id, err := s.bus.Notify(bn) id, err := s.bus.Notify(bn)
if err != nil { if err != nil {
slog.Warn("Error sending notification", "error", err) slog.Warn("Error sending notification", "error", err)
msg.NakWithDelay(1 * time.Minute) if err := msg.NakWithDelay(1 * time.Minute); err != nil {
slog.Error("Error naking message", "error", err)
}
return return
} }
slog.Info("Sent notification", "id", id) slog.Info("Sent notification", "id", id)