-
Notifications
You must be signed in to change notification settings - Fork 811
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
pubsub/natspubsub: NATS v2.2.0+ native message headers and message encoding #3282
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Codecov Report
@@ Coverage Diff @@
## master #3282 +/- ##
==========================================
- Coverage 77.47% 77.39% -0.09%
==========================================
Files 104 104
Lines 13721 13853 +132
==========================================
+ Hits 10631 10721 +90
- Misses 2353 2374 +21
- Partials 737 758 +21
|
…ebsite/data/examples.json
…ebsite/data/examples.json
vangent
requested changes
Jul 21, 2023
Thank you, @vangent for your review. I've already applied requested changes. |
vangent
approved these changes
Jul 21, 2023
Thanks for the contribution! |
ybourgery
pushed a commit
to Simprints/go-cloud
that referenced
this pull request
Jun 17, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR implements the native NATS v2.2.0+ message headers as metadata.
This PR doesn't break the API of the
github.com/google/go-cloud/pubsub/natspubsub
package. It provides additional functionality that could be chosen by the user of the library.For servers that support it (NATS Server 2.2.0 or later), messages could
be encoded using native NATS message headers, and native message content.
This provides full support for non-Go clients. Versions prior to 2.2.0 uses
gob.Encoder
to encode the message metadata and content, which limits the subscribers only to Go clients.To use this feature, set the query parameter "natsv2" in the URL.
The value needs to either be empty value or boolean parsable. For example:
nats://mysubject?natsv2
nats://mysubject?natsv2=true
This feature could also be enabled by setting the
URLOpener.UseV2
field manually.This implementation automatically determines if the server is capable of using v2.2.0+ headers.
If the server does not support it, any attempt to use it results in an error.
Using native NATS message headers and content is more efficient than using
gob.Encoder
, and allows non-Go clients to subscribe to the topic andreceive messages.
The benchmarks provided in the test files shows that using v2.2.0+ API is about three times faster on both
Send
andReceive
operations than the original implementation:where the
MB/s
is the actual number of messages send/received per second.