redis / hiredis

Minimalistic C client for Redis >= 1.2
BSD 3-Clause "New" or "Revised" License
6.22k stars 1.81k forks source link

Documentation Request: Structure and Order of Replies in Async Context when Subscribe #1245

Closed YoungjaeDev closed 8 months ago

YoungjaeDev commented 8 months ago

Hello

I am currently working with the hiredis library, specifically using the asynchronous API for a project. I have encountered a situation where I need a deeper understanding of the structure and order of replies when using the async API with SUBSCRIBE.

In my application, I am using the redisAsyncCommand function to subscribe to a Redis channel, and handling the messages in a callback function. My primary concern revolves around the structure and order of the reply object provided to the callback function.

I have the following questions:

  1. Is there comprehensive documentation available that describes the structure of the reply object in the context of asynchronous callbacks, especially when subscribing to channels?
  2. Can you provide more details on how the reply object is structured for different types of responses, such as messages from subscribed channels, subscription confirmations, etc.?

Having a clear understanding of this will greatly aid in correctly processing the messages received and ensuring the robustness of the application.

Thank you for your time and assistance. Looking forward to your guidance on this matter.

Best regards,

michael-grunder commented 8 months ago

Do you just mean the internal structure of our redisReply?

There is a fair bit of documentation on our readme about the various reply types.

You can also cross-reference this with the Redis docs to see what reply type to expect. Another way is to just play around with a Redis connection using telnet to look at the raw RESP2/RESP3 payloads.

michael-grunder commented 8 months ago

Closing this since it's not a bug in hiredis but happy to answer further questions.