feat: add pubsub
This commit is contained in:
parent
0b0da3b030
commit
5667d34e59
27
internal/pkg/pubsub/pubsub.go
Normal file
27
internal/pkg/pubsub/pubsub.go
Normal 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
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user