delaneyj / toolbelt

A set of utilities used in every go project
MIT License
16 stars 5 forks source link

Nats Server configuration options #3

Closed gedw99 closed 1 month ago

gedw99 commented 4 months ago

I would like to change the function signature that is used to start the NATS embedded Server, so that the folder, that is used for storage, can be passed in and used.

That function is here: https://github.com/delaneyj/datastar/blob/main/backends/go/site/router.go#L146

ns, err := toolbelt.NewEmbeddedNATsServer(context.Background(), true)

Also this function is affected here: https://github.com/delaneyj/datastar/blob/main/backends/go/site/routes_home.go#L25

func setupHome(router chi.Router, store sessions.Store, ns *toolbelt.EmbeddedNATsServer) error 

Also I would like to support using a NATS Cluster. I imagine that a separate Function call, is best for this ?

Then, in the Datastart repo, we can expose these changes so that everyone can have the flexibility to use it for their deployment options. In order to do that, we will probably need a PR in DataStar so that these options can be configured with environment variables also ?

delaneyj commented 2 months ago

You closed this without a PR @gedw99

gedw99 commented 2 months ago

I was not sure if you wanted it .

I asked in the initial issue for your opinion .

if you can give me your thoughts on it I can then work on it and make the PR.

delaneyj commented 2 months ago

You didn't say what you wanted the new signature to be so I was on standby.

gedw99 commented 2 months ago

I am fine with you to decide. The intent is so that Devs can tap into NATS with DataStar, where they have an Embedded, Leaf or NATS Cluster.

delaneyj commented 2 months ago

Datastar works either way. It's usage is completely orthogonal to this unless I'm missing something

gedw99 commented 2 months ago

Yes, but the issue is about using Data start with NATS its various forms. From what I see Toolblet only allows embedded.

Maybe you can use embeded as a NATS Leaf and then hook up NATS Cluster to the Embedded Leaf also ?

delaneyj commented 2 months ago

Setting up NATS to be used with Datastar means just using a *nats.Conn and doesn't need anything special. Embedded is the special case and reason for its inclusion here.