timetable-mgr/vstp/handler.go

34 lines
791 B
Go

package vstp
import (
"time"
"git.fjla.uk/owlboard/timetable-mgr/log"
"github.com/go-stomp/stomp/v3"
"go.uber.org/zap"
)
var count uint64 = 0
func handle(msg *stomp.Message) {
start := time.Now()
count++
log.Info("Message received", zap.Uint64("total since startup", count))
schedule, err := unmarshalData(msg.Body)
if err != nil {
log.Error("Error unmarshalling VSTP Message", zap.Error(err))
}
err, convertedType := convertCifType(schedule)
if err != nil {
log.Error("Error converting VSTP to CIF", zap.Error(err))
return
}
err = processCifData(convertedType)
if err != nil {
log.Error("Error processing VSTP Schedule", zap.Error(err))
}
end := time.Now()
duration := start.Sub(end)
log.Info("Message processed", zap.Duration("processing-time", duration))
}