-
Notifications
You must be signed in to change notification settings - Fork 67
How to create and pass instances of new NatsMsg<T>() to the NatsConnection#PublishAsync<T>(in NatsMsg<T> msg....) API correctly? #632
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
Labels
Comments
currently publish(NatsMsg) call implementation doesn't need all the fields and defaults would be fine: new NatsMsg<T>(
Subject: subject,
Data: payload,
Headers: headers,
ReplyTo: replyTo,
Connection: default,
Size: default
); it'd be nice to formalize it with a builder and tests. |
Hi!
|
thanks @Ivandemidov00 💯 not sure about the API maybe we can iterate on a PR? |
Ivandemidov00
added a commit
to Ivandemidov00/nats.net.v2
that referenced
this issue
Mar 29, 2025
* Change GetBytesLength long to int * Add NatsMsg method Create
Ivandemidov00
added a commit
to Ivandemidov00/nats.net.v2
that referenced
this issue
Apr 5, 2025
* Add Create overload without size/serialization calculation
Ivandemidov00
added a commit
to Ivandemidov00/nats.net.v2
that referenced
this issue
Apr 5, 2025
Ivandemidov00
added a commit
to Ivandemidov00/nats.net.v2
that referenced
this issue
Apr 6, 2025
* Refactor size handling: use max value for undefined size instead of separate field
Ivandemidov00
added a commit
to Ivandemidov00/nats.net.v2
that referenced
this issue
Apr 6, 2025
* apply format
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Proposed change
I want to use this API
to publish instances of
NatsMsg<T>
But this requires from me to construct an instance of NatsMsg in "low level" manner:
If I understood correctly, API's doc hints to provide the Size of the message in such a way:
But to achieve this, it seems, one needs to provide the headers parsed (since headers.Length is not compilable).
Question: How to create and pass instances of
NatsMsg<T>()
to theNatsConnection#PublishAsync<T>(in NatsMsg<T> msg....)
API correctly?I'm asking such question since I used nats-java version of this API but now want to transfer the java code consistently (without loosing API usage semantic) to C#/.Net platform.
https://github.com/nats-io/nats.java/blob/main/src/main/java/io/nats/client/impl/NatsMessage.java#L447
Note that a user of the Nats Java API is not enforced to provide "Size" of the message up front.
Use case
Better user experience to call
NatsConnection#PublishAsync<T>(in NatsMsg<T> msg....)
API.Contribution
No response
The text was updated successfully, but these errors were encountered: