Skip to content

Conversation

@caspervonb
Copy link
Collaborator

@caspervonb caspervonb commented Sep 22, 2025

This adds a standalone nats.client package

Main differences in nats.client compared to nats.aio

  • Asynchronous first
  • Substantially faster than nats.aio
  • Proper headers, with support for multi-values.
  • JetStream unaware as a feature.

@caspervonb caspervonb force-pushed the add-nats-client-package branch from 381af5b to 781a9bf Compare September 22, 2025 12:24
@caspervonb caspervonb requested a review from Copilot September 22, 2025 12:28
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds a new NATS client package with significant performance improvements over the existing nats.aio client. The implementation provides core NATS messaging functionality including publish/subscribe, request/reply, queue groups, and message headers through an asyncio-based Python client.

  • Introduces a complete NATS client implementation with high-level API
  • Adds comprehensive test coverage for all client features and edge cases
  • Includes performance benchmarking tools demonstrating 35x improvement for small messages

Reviewed Changes

Copilot reviewed 20 out of 20 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
nats-client/src/nats/client/init.py Main client implementation with connection management, messaging, and reconnection logic
nats-client/src/nats/client/subscription.py Subscription class supporting async iteration and context management
nats-client/src/nats/client/protocol/message.py NATS protocol message parsing with support for MSG, HMSG, and control messages
nats-client/src/nats/client/protocol/command.py Command encoding for NATS protocol operations (PUB, SUB, CONNECT, etc.)
nats-client/src/nats/client/message.py Message data structures including Headers, Status, and Message classes
nats-client/tests/ Comprehensive test suite covering client functionality, subscriptions, and protocol handling
nats-client/tools/bench.py Benchmarking tool for performance testing

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@caspervonb caspervonb force-pushed the add-nats-server-package branch 2 times, most recently from 83d0f80 to 44fb982 Compare September 22, 2025 13:14
@caspervonb caspervonb force-pushed the add-nats-client-package branch from 781a9bf to 9a8cd71 Compare September 23, 2025 08:13
@wallyqs
Copy link
Member

wallyqs commented Sep 23, 2025

Move this to be under nats.experimental.client to be able to use both while still evaluating the client.

@caspervonb caspervonb mentioned this pull request Sep 23, 2025
13 tasks
Copy link
Member

@philpennock philpennock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see anything in the SSL context init to handle the server identity for TLS identity verification, when we learnt a reconnect address as an IP from the INFO line?

If we connect with a hostname originally, we validate that hostname in the cert, and if we reconnect to a learnt IP address, we validate that same original hostname as present in the new server cert. Did I just miss the handling of that?

@caspervonb caspervonb force-pushed the add-nats-server-package branch 3 times, most recently from accfd1c to 20963ae Compare October 3, 2025 10:28
@caspervonb caspervonb changed the base branch from add-nats-server-package to main October 3, 2025 11:41
@caspervonb caspervonb changed the base branch from main to migrate-project-to-uv-workspace October 3, 2025 18:06
@caspervonb caspervonb force-pushed the add-nats-client-package branch from 9a8cd71 to 0094dba Compare October 3, 2025 18:09
This was referenced Oct 5, 2025
@caspervonb caspervonb requested a review from Copilot October 5, 2025 09:08
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 21 out of 22 changed files in this pull request and generated 4 comments.

Comments suppressed due to low confidence (1)

.github/workflows/test.yml:1

  • Git merge conflict markers are present in the CI configuration file. These need to be resolved before merging.
name: test

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@caspervonb caspervonb requested a review from Copilot October 7, 2025 09:58
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 21 out of 22 changed files in this pull request and generated no new comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@caspervonb caspervonb changed the base branch from migrate-project-to-uv-workspace to main October 7, 2025 10:50
@caspervonb caspervonb force-pushed the add-nats-client-package branch 2 times, most recently from 16d8621 to 7acfd1f Compare October 7, 2025 10:52
Copy link
Member

@wallyqs wallyqs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change the import to nats.experimental.aio.client while iterating on the implementation, then can work using that namespace in the other branches with the JetStream changes.

@caspervonb
Copy link
Collaborator Author

Change the import to nats.experimental.aio.client while iterating on the implementation, then can work using that namespace in the other branches with the JetStream changes.

So nats-experimental-aio-client as a package name? doesn't exactly roll of the tongue so not sure about that.

Also would make all the currently pending PRs painful to merge and also the ones that aren't opened yet (e.g client auth, client tls, jetstream ordered consumer). Not sure what the benefit is of such a rename?

@caspervonb caspervonb force-pushed the add-nats-client-package branch from 7acfd1f to 2e13fe5 Compare October 7, 2025 15:02
Signed-off-by: Casper Beyer <casper@synadia.com>
Signed-off-by: Casper Beyer <casper@synadia.com>
Signed-off-by: Casper Beyer <casper@synadia.com>
Signed-off-by: Casper Beyer <casper@synadia.com>
Signed-off-by: Casper Beyer <casper@synadia.com>
Signed-off-by: Casper Beyer <casper@synadia.com>
@caspervonb caspervonb force-pushed the add-nats-client-package branch from c015d99 to d1ec510 Compare October 21, 2025 16:00
Signed-off-by: Casper Beyer <casper@synadia.com>
Signed-off-by: Casper Beyer <casper@synadia.com>
@caspervonb caspervonb force-pushed the add-nats-client-package branch 2 times, most recently from a3fc895 to 71eb800 Compare October 22, 2025 11:46
Signed-off-by: Casper Beyer <casper@synadia.com>
Signed-off-by: Casper Beyer <casper@synadia.com>
Signed-off-by: Casper Beyer <casper@synadia.com>
Signed-off-by: Casper Beyer <casper@synadia.com>
Signed-off-by: Casper Beyer <casper@synadia.com>
Signed-off-by: Casper Beyer <casper@synadia.com>
Signed-off-by: Casper Beyer <casper@synadia.com>
Signed-off-by: Casper Beyer <casper@synadia.com>
Signed-off-by: Casper Beyer <casper@synadia.com>
Signed-off-by: Casper Beyer <casper@synadia.com>
@caspervonb caspervonb force-pushed the add-nats-client-package branch from 6eb24dc to bd8a5f0 Compare October 23, 2025 11:23
Signed-off-by: Casper Beyer <casper@synadia.com>
Signed-off-by: Casper Beyer <casper@synadia.com>
Signed-off-by: Casper Beyer <casper@synadia.com>
Signed-off-by: Casper Beyer <casper@synadia.com>
Signed-off-by: Casper Beyer <casper@synadia.com>
Signed-off-by: Casper Beyer <casper@synadia.com>
Signed-off-by: Casper Beyer <casper@synadia.com>
Signed-off-by: Casper Beyer <casper@synadia.com>
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.

5 participants