timetable-extension #1
3
main.go
3
main.go
@ -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")
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
@ -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))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user