timetable-extension #1

Open
fred.boniface wants to merge 154 commits from timetable-extension into main
4 changed files with 18 additions and 9 deletions
Showing only changes of commit 790d293bc4 - Show all commits

View File

@ -74,10 +74,9 @@ func handleSignals(cfg *helpers.Configuration, stop chan<- struct{}) {
func cleanup(cfg *helpers.Configuration, stop chan<- struct{}) {
log.Debug("Cleaning up open connections")
if cfg.VstpOn {
if messaging.Client != nil {
log.Info("Closing STOMP Client")
messaging.Disconnect(messaging.Client)
}
}
if dbAccess.MongoClient != nil {
log.Info("Closing MongoDB Client")

View File

@ -22,7 +22,7 @@ func dial(user, pass string) *stomp.Conn {
)
if err != nil {
log.Fatal("Unable to connect to STOMP Client: " + err.Error())
conn.MustDisconnect()
conn.Disconnect()
}
log.Info("Initialised STOMP Client")
@ -42,6 +42,11 @@ func Disconnect(conn *stomp.Conn) {
return
}
log.Error("STOMP Disconnect failed, next connection attempt may fail")
}
err := Client.Disconnect()
if err != nil {
Client.MustDisconnect()
log.Warn("STOMP Disconnect failed, forced disconnection")
}
log.Info("STOMP Client disconnected")
// Register against the MQ Server and log each message for testing purposes
}

View File

@ -39,7 +39,6 @@ func processCifData(s *upstreamApi.JsonScheduleV1) error {
}
return nil
} else {
err := fmt.Errorf("unknown transaction type: %s", s.TransactionType)
return err
return fmt.Errorf("unknown transaction type: %s", s.TransactionType)
}
}

View File

@ -1,6 +1,8 @@
package vstp
import (
"time"
"git.fjla.uk/owlboard/timetable-mgr/log"
"github.com/go-stomp/stomp/v3"
"go.uber.org/zap"
@ -9,6 +11,7 @@ import (
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(string(msg.Body))
@ -19,4 +22,7 @@ func handle(msg *stomp.Message) {
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))
}