watermill
watermill copied to clipboard
feat(manager): Add a manager to support unified driver switching
For Example:
package main
import (
"context"
"github.com/ThreeDotsLabs/watermill"
"github.com/ThreeDotsLabs/watermill/manager"
"github.com/ThreeDotsLabs/watermill/message"
"github.com/ThreeDotsLabs/watermill/pubsub/gochannel"
)
func main() {
m := manager.New(gochannel.NewGoChannel(
gochannel.Config{},
watermill.NewStdLogger(false, false),
))
m.Register("another", gochannel.NewGoChannel(
gochannel.Config{},
watermill.NewStdLogger(false, false),
))
// or other pubsub drivers, e.g.: nas/kafka...
m.Publish("topic", message.NewMessage(watermill.NewUUID(), []byte("Hello, world!")))
m.Use().Publish("topic", message.NewMessage(watermill.NewUUID(), []byte("Hello, world!")))
m.Use("another").Publish("topic", message.NewMessage(watermill.NewUUID(), []byte("Hello, world!")))
m.Subscribe(context.Background(), "topic")
m.Use().Subscribe(context.Background(), "topic")
m.Use("another").Subscribe(context.Background(), "topic")
}
Originally, I wanted to put it under the
https://github.com/ThreeDotsLabs/watermillpackage, but there is a circular dependency in the current architecture. So, I created amanagerpackage.