Check if producer was registered
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
This commit is contained in:
parent
0c8c6f5668
commit
5f07bc2d7c
3 changed files with 14 additions and 5 deletions
|
|
@ -488,11 +488,18 @@ func (s *sqlDatabase) unsealAndUnmarshal(data []byte, target interface{}) error
|
|||
return nil
|
||||
}
|
||||
|
||||
func (s *sqlDatabase) sendNotify(entityType dbCommon.DatabaseEntityType, op dbCommon.OperationType, payload interface{}) {
|
||||
func (s *sqlDatabase) sendNotify(entityType dbCommon.DatabaseEntityType, op dbCommon.OperationType, payload interface{}) error {
|
||||
if s.producer == nil {
|
||||
// no producer was registered. Not sending notifications.
|
||||
return nil
|
||||
}
|
||||
if payload == nil {
|
||||
return errors.New("missing payload")
|
||||
}
|
||||
message := dbCommon.ChangePayload{
|
||||
Operation: op,
|
||||
Payload: payload,
|
||||
EntityType: entityType,
|
||||
}
|
||||
s.producer.Notify(message)
|
||||
return s.producer.Notify(message)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue