Manager: log error when an event doesn't have a SocketIO event type
SocketIO has 'rooms' and 'event types'. The 'event type' is set via reflection of the OpenAPI type of the event payload. This has to be set up in a mapping, though, and if that mapping is incomplete, an error will now be logged.
This commit is contained in:
parent
ee7af29748
commit
9bfb53a7f6
@ -14,6 +14,7 @@ import (
|
||||
"github.com/rs/zerolog/log"
|
||||
"projects.blender.org/studio/flamenco/internal/uuid"
|
||||
"projects.blender.org/studio/flamenco/pkg/api"
|
||||
"projects.blender.org/studio/flamenco/pkg/website"
|
||||
)
|
||||
|
||||
type SocketIOEventType string
|
||||
@ -59,7 +60,17 @@ func (s *SocketIOForwarder) Broadcast(topic EventTopic, payload interface{}) {
|
||||
// SocketIO has a concept of 'event types'. MQTT doesn't have this, and thus the Flamenco event
|
||||
// system doesn't rely on it. We use the payload type name as event type.
|
||||
payloadType := reflect.TypeOf(payload).Name()
|
||||
eventType := socketIOEventTypes[payloadType]
|
||||
|
||||
eventType, ok := socketIOEventTypes[payloadType]
|
||||
if !ok {
|
||||
log.Error().
|
||||
Str("topic", string(topic)).
|
||||
Str("payloadType", payloadType).
|
||||
Interface("event", payload).
|
||||
Msgf("socketIO: payload type does not have an event type, please copy-paste this message into a bug report at %s", website.BugReportURL)
|
||||
return
|
||||
}
|
||||
|
||||
log.Debug().
|
||||
Str("topic", string(topic)).
|
||||
Str("eventType", eventType).
|
||||
|
@ -6,6 +6,7 @@ import "fmt"
|
||||
|
||||
const (
|
||||
// Topics on which events are published.
|
||||
// NOTE: when adding here, also add to socketIOEventTypes in socketio.go.
|
||||
TopicLifeCycle EventTopic = "/lifecycle" // sends api.EventLifeCycle
|
||||
TopicFarmStatus EventTopic = "/status" // sends api.EventFarmStatus
|
||||
TopicJobUpdate EventTopic = "/jobs" // sends api.EventJobUpdate
|
||||
|
Loading…
x
Reference in New Issue
Block a user