Files
universal-data-ingest/src/udi/handlers/handler/handler.go
Wolfgang Hottgenroth 17b2b362a0
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline was successful
fix in error output
2024-02-09 14:05:14 +01:00

47 lines
744 B
Go

package handler
import (
"time"
"log"
"udi/counter"
)
type MessageT struct {
Timestamp time.Time
Topic string
Payload string
}
type Handler interface {
GetId() string
Handle(MessageT)
Lost(msg string, err error, message MessageT)
S()
F()
}
type CommonHandler struct {
Id string
}
func (self *CommonHandler) S() {
counter.SH(self.Id)
}
func (self *CommonHandler) F() {
counter.FH(self.Id)
}
func (self *CommonHandler) GetId() string {
return self.Id
}
func (self *CommonHandler) Lost(msg string, err error, message MessageT) {
if err == nil {
log.Printf("Error: %s, message %s is lost", msg, message)
} else {
log.Printf("Error: %s (%s), message %s is lost", msg, err, message)
}
self.F()
}