2020-06-05 23:36:31 +00:00
|
|
|
package stream
|
|
|
|
|
|
|
|
type Topic int32
|
|
|
|
|
|
|
|
// TODO: remove underscores
|
2020-06-15 22:49:00 +00:00
|
|
|
// TODO: type string instead of int?
|
2020-07-06 20:15:13 +00:00
|
|
|
// TODO: define non-internal topics in state package?
|
2020-06-05 23:36:31 +00:00
|
|
|
const (
|
2020-07-06 18:34:58 +00:00
|
|
|
TopicInternal Topic = 0
|
|
|
|
Topic_ServiceHealth Topic = 1
|
|
|
|
Topic_ServiceHealthConnect Topic = 2
|
2020-06-05 23:36:31 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// TODO:
|
|
|
|
type Event struct {
|
|
|
|
Topic Topic
|
|
|
|
Key string
|
|
|
|
Index uint64
|
|
|
|
Payload interface{}
|
|
|
|
}
|
|
|
|
|
2020-06-15 22:49:00 +00:00
|
|
|
func (e Event) IsEndOfSnapshot() bool {
|
2020-06-05 23:36:31 +00:00
|
|
|
return e.Payload == endOfSnapshot{}
|
|
|
|
}
|
|
|
|
|
2020-06-15 22:49:00 +00:00
|
|
|
func (e Event) IsResumeStream() bool {
|
|
|
|
return e.Payload == ResumeStream{}
|
|
|
|
}
|
|
|
|
|
2020-06-05 23:36:31 +00:00
|
|
|
type endOfSnapshot struct{}
|
2020-06-15 22:49:00 +00:00
|
|
|
|
|
|
|
type ResumeStream struct{}
|
2020-07-06 18:34:58 +00:00
|
|
|
|
|
|
|
// TODO: unexport once EventPublisher is in stream package
|
|
|
|
type UnsubscribePayload struct {
|
|
|
|
TokensSecretIDs []string
|
|
|
|
}
|
|
|
|
|
|
|
|
// NewUnsubscribeEvent returns a special Event that is handled by the
|
|
|
|
// stream package, and is never sent to subscribers. It results in any subscriptions
|
|
|
|
// which match any of the TokenSecretIDs to be unsubscribed.
|
|
|
|
func NewUnsubscribeEvent(tokenSecretIDs []string) Event {
|
|
|
|
return Event{Payload: UnsubscribePayload{TokensSecretIDs: tokenSecretIDs}}
|
|
|
|
}
|