nats.c
nats.c copied to clipboard
The async for natsConnection_RequestString
Feature Request
Currently, I see there have the natsConnection_RequestString with a given timeout in MS, can it has an async version? Likes
natsConnection_RequestString(&reply, nc, "foo", "help", callback, 1000);
Once received the reply in 1000 MS or its timeout, the callback will be triggered.
Use Case:
For some large amounts of the sync call will cause the thread blocked
Proposed Change:
Add a callback parameter to the natsConnection_RequestString.
Who Benefits From The Change(s)?
Alternative Approaches
Is this for the server or a specific client language?
Is this for the server or a specific client language?
For the C language client.
Thanks
ok will move this over to there.
The C client already provides a way to create an async subscription that times out. See natsConnection_SubscribeTimeout. So you could create a subscription on a wildcard subject, and publish your requests using natsConnection_PublishRequestString with a unique token at the end of the reply subject.
Take note of the behavior of the async subscription timeout in the doc. That is, the callback will be invoked with a NULL message if no message is received in the timeout interval specified when creating the subscription. Receiving a message reset this interval, etc..