Ask a question about using golang to develop a connection pool to put connections in a buffered channel with get and put operations <-chan and chan <- conn
Currently, there is also a function to check whether the connection is valid at regular intervals. To do this at regular intervals, that is, to take out the check and store it in, but will it affect the normal get and put operation when checking?
Or are there other data structures to recommend?
Thank you very much!
... will it affect the normal get and put operation when checking
So currently you pop one connection from the channel and check if it's live. While this is being checked, that connection wont be available to other subscribers on that pool channel.
I guess you're asking if this will affect any concurrent operation at the time you do this check?
I don't think it will since the 'user' of the pool also has to pop a connection from the channel to use the connection. So a concurrent operation shouldn't occur.
This, of course depends on you having a 'Put' function that pops the connection from the channel, does a command, then pushes it back onto the channel only once everything is done.