You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
we are using this lib to do long polling for our REST API, but we facing issue when sending data to our API, it seems the channel not blocked and not waits till data written to a variable, so we don't know when it's finished or not, please check following code for details:
for {
datach, err := c.pollChannel.Get(poll.PollTime) // this line will get data from longpoll
if err != nil {
break
}
rows := <-datach // get data from channel
logrus.Debugf("from poll channel: %d", rows) // this debug will print data from channel (data exists)
if (rows != nil){
// processing the data and pass it to API
}
}
// return data empty to API
// in our case, we always got empty data even though debug prints the data to console.
our question: Is there any Flag to check the go routine / channel are done? so, we can tells API to waits and response if data ready.
The text was updated successfully, but these errors were encountered:
I am sorry I do not understand "we always got empty data even though debug prints the data to console": it is not clear in which line of this code sample you get no data which is earlier printed by the debug. Fact is, if the debug prints data correctly, then the library functions as designed as the library is about waiting for data and getting it out, not about what happens to it afterwards.
I also do not quite understand what sort of flag you want. Long polling works like this: you wait for data on a channel, if data arrives then the polling channel immediately returns with that data in a go channel. If the data does not arrive, the polling channel also returns, but after the timeout and with an empty go channel. There is no flag to indicate one of the other. Furthermore, you always get something in the Go channel after the polling period completes (with or without data), just what you get is different. If I recall right, you either get and empty slice or a slice with data, but please check tests as I did not touch the lib for a long time now.
if data arrives then the polling channel immediately returns with that data in a go channel. If the data does not arrive, the polling channel also returns, but after the timeout and with an empty go channel
Hi,
we are using this lib to do long polling for our REST API, but we facing issue when sending data to our API, it seems the channel not blocked and not waits till data written to a variable, so we don't know when it's finished or not, please check following code for details:
our question: Is there any Flag to check the go routine / channel are done? so, we can tells API to waits and response if data ready.
The text was updated successfully, but these errors were encountered: