Skip to content

Commit

Permalink
Evaluate service imports when publishing advisories
Browse files Browse the repository at this point in the history
Signed-off-by: Neil Twigg <neil@nats.io>
  • Loading branch information
neilalexander committed Jul 12, 2023
1 parent e3b132a commit de371c6
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions server/jetstream_events.go
Expand Up @@ -30,6 +30,21 @@ func (s *Server) publishAdvisory(acc *Account, subject string, adv interface{})
err = s.sendInternalAccountMsg(acc, subject, ej)
if err != nil {
s.Warnf("Advisory could not be sent for account %q: %v", acc.Name, err)
return
}

// To allow advisories to be captured by service imports/exports,
// we will need to check the subs separately.
for _, sub := range acc.sl.Match(subject).psubs {
if im, ok := acc.imports.services[string(sub.subject)]; ok {
to := subject
if im.tr != nil {
to, _ = im.tr.transformSubject(subject)
}
if err = s.sendInternalAccountMsg(im.acc, to, ej); err != nil {
s.Warnf("Advisory could not be sent for account %q via service import: %v", sub.im.acc.Name, err)
}
}
}
} else {
s.Warnf("Advisory could not be serialized for account %q: %v", acc.Name, err)
Expand Down

0 comments on commit de371c6

Please sign in to comment.