timetable-mgr/vstp/handler.go

29 lines
657 B
Go
Raw Normal View History

2023-07-19 21:31:00 +01:00
package vstp
import (
2024-04-15 20:36:33 +01:00
"time"
"git.fjla.uk/owlboard/timetable-mgr/log"
2023-07-19 21:31:00 +01:00
"github.com/go-stomp/stomp/v3"
2024-04-14 19:03:13 +01:00
"go.uber.org/zap"
2023-07-19 21:31:00 +01:00
)
var count uint64 = 0
func handle(msg *stomp.Message) {
2024-04-15 20:36:33 +01:00
start := time.Now()
2023-07-19 21:31:00 +01:00
count++
2024-04-14 19:03:13 +01:00
log.Info("Message received", zap.Uint64("total since startup", count))
schedule, err := unmarshalData(string(msg.Body))
if err != nil {
log.Error("Error unmarshalling VSTP Message", zap.Error(err))
}
err = processCifData(schedule)
if err != nil {
log.Error("Error processing VSTP Schedule", zap.Error(err))
}
2024-04-15 20:36:33 +01:00
end := time.Now()
duration := start.Sub(end)
log.Info("Message processed", zap.Duration("processing-time", duration))
2023-07-19 21:31:00 +01:00
}