TuyaInc / tuya_pulsar_sdk_go

8 stars 6 forks source link

problem of ReceiveAsync #3

Closed LvBay closed 4 years ago

LvBay commented 5 years ago

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 5 years ago

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 4 years ago

loop flow