Skip to content
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

The async for natsConnection_RequestString #449

Open
portsip opened this issue Aug 4, 2021 · 4 comments
Open

The async for natsConnection_RequestString #449

portsip opened this issue Aug 4, 2021 · 4 comments

Comments

@portsip
Copy link

portsip commented Aug 4, 2021

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

@derekcollison
Copy link
Member

Is this for the server or a specific client language?

@portsip
Copy link
Author

portsip commented Aug 4, 2021

Is this for the server or a specific client language?

For the C language client.

Thanks

@derekcollison
Copy link
Member

ok will move this over to there.

@derekcollison derekcollison transferred this issue from nats-io/nats-server Aug 4, 2021
@kozlovic kozlovic closed this as completed Aug 4, 2021
@kozlovic kozlovic reopened this Aug 4, 2021
@kozlovic
Copy link
Member

kozlovic commented Aug 4, 2021

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..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants