timetable-mgr/vstp/handler.go
Fred Boniface 45b23b4cf0
All checks were successful
Go Test / test (push) Successful in 43s
Add VSTP message print when schedule segment is empty
2024-04-27 21:13:22 +01:00

32 lines
719 B
Go

package vstp
import (
"fmt"
"time"
"git.fjla.uk/owlboard/timetable-mgr/log"
"github.com/go-stomp/stomp/v3"
"go.uber.org/zap"
)
func handle(msg *stomp.Message) {
start := time.Now()
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))
fmt.Println(msg.Body)
return
}
err = processCifData(convertedType)
if err != nil {
log.Error("Error processing VSTP Schedule", zap.Error(err))
}
end := time.Now()
duration := end.Sub(start)
log.Info("Message processed", zap.Duration("processing-time", duration))
}