Replies: 1 comment
-
You could indeed create a wrapper replay provider which always sends a message when type AlwaysReplay struct {
Message *sse.Message // could also be an array
Replayer sse.ReplayProvider // may be nil
}
func (a *AlwaysReplay) Put(m *Message, topics []string) *Message {
if a.Replayer != nil {
return a.Replayer.Put(m, topics)
}
return nil
}
func (a *AlwaysReplay) Replay(s Subscription) error {
if err := s.Client.Send(a.Message); err != nil {
return fmt.Errorf("always replay: %w", err)
}
if a.Replayer != nil {
return a.Replayer.Replay(s)
}
return nil
} Another, maybe simpler, way would be to send that message directly inside The replay provider solution will guarantee though that with any provider the message will be replayed if the subscription is successful (of course, if the provider is correctly implemented). Apologies for the very delayed response, I didn't notice that you've opened a discussion. Hopefully this will still be of help! |
Beta Was this translation helpful? Give feedback.
-
I am using your lib in https://github.com/taranis-ai/sse-broker which works great!
I would like to send a message on successful subscription. The only idea to achieve this so far is, writing a new provider for Joe.
A "StaticProvider" that you could add messages, to he keeps indefinitely, if the messages have an ID he wouldn't resend them on reconnect, otherwise you would just get the message.
Am I overcomplicating this, and there is an easier way to do this?
Beta Was this translation helpful? Give feedback.
All reactions