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

Nats::Server shouldn't be called that way #1

Closed
FCO opened this issue May 28, 2023 · 4 comments
Closed

Nats::Server shouldn't be called that way #1

FCO opened this issue May 28, 2023 · 4 comments

Comments

@FCO
Copy link
Owner

FCO commented May 28, 2023

It's not a server, it shouldn't be called that way, maybe something like:

  • Nats::Client
  • Nats::Connection
  • Nats::Service
@FCO
Copy link
Owner Author

FCO commented May 28, 2023

@dontlaugh
Copy link

There are many official clients, so really you ought to follow their lead.

I would not call this "Server". Perhaps Subscriber or Subscription. Unless you intend to totally re-implement nats-server, everything here is a client concern.

It's confusing at first, because EVERYTHING is a client, except the NATS server itself.

@dontlaugh
Copy link

dontlaugh commented May 28, 2023

https://github.com/nats-io/nats.deno/blob/main/examples/nats-sub.ts#L61-L64 example

Note that the official NATS libraries expose multiple APIs that do the same thing, but at different levels of detail.

Consider this:
https://github.com/nats-io/nats.go/blob/main/examples/nats-sub/main.go#L99-L110

The Conn object has a high-level subscribe method that accepts a callback.

But while that example throws away the *Subscription object, be aware that Subscription exposes an iterator-style API for getting messages as well (lower level with more control) https://github.com/nats-io/nats.go/blob/main/nats.go#L4517

After some thought, I think you should rework it as the Connection class and this method: https://github.com/nats-io/nats.go/blob/main/nats.go#L4083

@FCO
Copy link
Owner Author

FCO commented Jun 17, 2023

I’ve renamed Nats::Server to Nats::Client and also renamed Nats::Route to Nats::Subscriptions (there is already a Nats::Subscription).

@FCO FCO closed this as completed Jun 17, 2023
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

No branches or pull requests

2 participants