nats.net icon indicating copy to clipboard operation
nats.net copied to clipboard

Implement Async Get/Delete

Open thinkbeforecoding opened this issue 2 years ago • 8 comments

This PR implement Task based async for GetMessage/DeleteMessage.

I have an extra question on this. Would it be ok to also implement GetMessage on IJetStream ? It would return a Msg instead of MsgInfo in that case.

https://github.com/nats-io/nats.net/issues/540

thinkbeforecoding avatar Jan 18 '22 16:01 thinkbeforecoding

@thinkbeforecoding can you open an issue to track your question regarding the other method family.

sixlettervariables avatar Jan 18 '22 16:01 sixlettervariables

@thinkbeforecoding a couple things. Please sign your commits, this is the policy for our repos.

Regarding the change, you could always do it yourself by wrapping the sync call. The problem with adding this to the api is that we have to consider it in all clients, not that all clients have to be exactly equal but we do try to maintain some amount of parity. And since you can wrap the call yourself and the management context is actually very light, I don't see the problem with using both the management api and the regular api. We are really just separating concerns by having different interfaces.

scottf avatar Jan 19 '22 14:01 scottf

Also GetMessage is a JS API call, which is why it returns MessageInfo instead of a Message, which is returned in subscriptions.

scottf avatar Jan 19 '22 14:01 scottf

In .NET you should avoid wrapping sync in async calls whenever possible. "Turtles all the way down" is best, so to speak.

sixlettervariables avatar Jan 19 '22 14:01 sixlettervariables

I'm ok to leave GetMessage in the management api. But having an Async version (returning a task) is very important for .Net performance.

thinkbeforecoding avatar Jan 19 '22 17:01 thinkbeforecoding

I signed the commit 👍

thinkbeforecoding avatar Jan 21 '22 15:01 thinkbeforecoding

This will be addressed in V2

scottf avatar Jun 15 '22 21:06 scottf

@scottf Any more details about v2? Do you have an idea of how far down the line it is? Like this year, next year? Is it a complete rewrite?

JohannesEH avatar Aug 25 '22 08:08 JohannesEH