Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(manager): Add a manager to support unified driver switching #420

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

flc1125
Copy link

@flc1125 flc1125 commented Jan 26, 2024

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/watermill package, but there is a circular dependency in the current architecture. So, I created a manager package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant