TuyaInc/tuya_pulsar_sdk_go

problem of ReceiveAsync

Closed this issue · 2 comments

LvBay commented

In ReceiveAsync, the ideal situation is that each time the client calls flow(n), after receiving the nth message, it executes flow(n). But in actual situations, the number of messages returned by the pulsar service is sometimes less than n. This will cause the next flow to never be triggered, and then the message will be stacked.

LvBay commented

In order to solve this problem, we can use time.Ticker to set a special timed task, and call flow(n) every once in a while. However, there will be a lot of tickers that will not be recycled in this program, which will put some pressure on the CPU. Maybe we have a better way?

LvBay commented

loop flow