We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
I want to use this API
NatsConnection#public ValueTask PublishAsync<T>(in NatsMsg<T> msg, INatsSerialize<T>? serializer = default, NatsPubOpts? opts = default, CancellationToken cancellationToken = default) => PublishAsync(msg.Subject, msg.Data, msg.Headers, msg.ReplyTo, serializer, opts, cancellationToken);
to publish instances of NatsMsg<T>
NatsMsg<T>
But this requires from me to construct an instance of NatsMsg in "low level" manner:
new NatsMsg<T>( Subject: subject, Data: payload, Headers: headers, ReplyTo: replyTo, Connection: connection, Size: size );
If I understood correctly, API's doc hints to provide the Size of the message in such a way:
int size = subject.Length + replyTo.Length + headers.Length + payload.Length;
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 the NatsConnection#PublishAsync<T>(in NatsMsg<T> msg....) API correctly?
NatsMsg<T>()
NatsConnection#PublishAsync<T>(in NatsMsg<T> msg....)
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
Message message = NatsMessage.builder() .subject(subject) .headers(headers) .replyTo(replyTo) .data(payload) .build(); // and then publish it: connection.jetStream().publish(message)
Note that a user of the Nats Java API is not enforced to provide "Size" of the message up front.
Better user experience to call NatsConnection#PublishAsync<T>(in NatsMsg<T> msg....) API.
No response
The text was updated successfully, but these errors were encountered:
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.
Sorry, something went wrong.
No branches or pull requests
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: