weapp/pkg/pubsub/pubsub.go

28 lines
483 B
Go

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
}