feat: add pubsub

This commit is contained in:
lab 2021-12-28 01:42:42 +08:00
parent 0b0da3b030
commit 5667d34e59

View File

@ -0,0 +1,27 @@
package pubsub
import "context"
type Subject string
func (subject Subject) String() string {
return string(subject)
}
type Message interface{}
type Publishing struct{}
type PublishOption func(*Publishing)
type Publisher interface {
Publish(context.Context, Subject, Message, ...PublishOption) error
}
type MessageHandler interface {
HandleMessage(context.Context, *Message) error
}
type Subscriber interface {
Subscribe(context.Context, Subject, MessageHandler) error
}