Closed gedw99 closed 3 months ago
I made all the code changes to support both Google Pub Sub and Nats Jetstream as a PR.
But it looks like the Interface is not the same for each :
"github.com/ThreeDotsLabs/watermill-googlecloud/pkg/googlecloud" "github.com/ThreeDotsLabs/watermill-nats/v2/pkg/nats"
Any thoughts / advice ?
Hey @gedw99, can you share the code you changed?
You need to replace the googlecloud.NewPublisher
and googlecloud.NewSubscriber
calls with the equivalent constructors of nats
. The returned values always implement the Publisher
and Subscriber
interfaces.
Hey @m110
thanks for the follow up. I have to come back on this, as deep in the weeds on something else right now, but I wanted to ask in the mean time :
Could we do a Factory pattern ( the golang way though ), on this code such that a config can drive which one is loaded ? Or would a compile time go build tag be better ?
My intent here is to make it easy to not have to do this again and again in Watermill....
Yes, sure. You could use a factory with a method that returns the message.Publisher
or the message.Subscriber
, and it would decide what implementation to use. :)
Ok thanks @m110
I am snowed under, so if someone else wants to take this go for it. Otherwise I will swing back on to this.
The solution seems to be worked out.
https://github.com/ThreeDotsLabs/watermill/tree/master/_examples/real-world-examples/
How can I swap this out to use NATS Jetstream ?
My understanding is that it's pretty easy to swap out to NATS or even a DB with Watermill ?