include existing logic

This commit is contained in:
2024-08-06 15:15:21 +01:00
parent 5d9e4bdd89
commit 1186e69121
7 changed files with 326 additions and 0 deletions

18
common.go Normal file
View File

@@ -0,0 +1,18 @@
package gubgub
// Subscriber is a func that processes a message and returns true if it should continue processing more messages.
type Subscriber[T any] func(T) bool
// Topic is just a convenience interface you can expect all topics to implement.
type Topic[T any] interface {
Publishable[T]
Subscribable[T]
}
type Publishable[T any] interface {
Publish(msg T) error
}
type Subscribable[T any] interface {
Subscribe(Subscriber[T]) error
}