2023-07-19 21:31:00 +01:00
|
|
|
package vstp
|
|
|
|
|
|
|
|
import (
|
2024-04-27 21:13:22 +01:00
|
|
|
"fmt"
|
2024-04-15 20:36:33 +01:00
|
|
|
"time"
|
|
|
|
|
2024-03-25 11:26:07 +00:00
|
|
|
"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
|
|
|
)
|
|
|
|
|
|
|
|
func handle(msg *stomp.Message) {
|
2024-04-15 20:36:33 +01:00
|
|
|
start := time.Now()
|
2024-04-24 23:09:34 +01:00
|
|
|
schedule, err := unmarshalData(msg.Body)
|
2024-04-15 20:03:48 +01:00
|
|
|
if err != nil {
|
|
|
|
log.Error("Error unmarshalling VSTP Message", zap.Error(err))
|
|
|
|
}
|
2024-04-24 23:09:34 +01:00
|
|
|
err, convertedType := convertCifType(schedule)
|
|
|
|
if err != nil {
|
|
|
|
log.Error("Error converting VSTP to CIF", zap.Error(err))
|
2024-04-27 21:13:22 +01:00
|
|
|
fmt.Println(msg.Body)
|
2024-04-24 23:09:34 +01:00
|
|
|
return
|
|
|
|
}
|
|
|
|
err = processCifData(convertedType)
|
2024-04-15 20:03:48 +01:00
|
|
|
if err != nil {
|
|
|
|
log.Error("Error processing VSTP Schedule", zap.Error(err))
|
|
|
|
}
|
2024-04-15 20:36:33 +01:00
|
|
|
end := time.Now()
|
2024-04-26 20:48:17 +01:00
|
|
|
duration := end.Sub(start)
|
2024-04-15 20:36:33 +01:00
|
|
|
log.Info("Message processed", zap.Duration("processing-time", duration))
|
2023-07-19 21:31:00 +01:00
|
|
|
}
|