@Souvlaki42 this’d be the correct place to access the connection:
After “handling” psync and writing the response, that same connection
object is what you’ll need to call Write
on to propagate commands.
Looks like you’ve already got a replicas
global here, instead of a channel you could use an array ([]net.Conn
) and then append to that array from within handleConnection
after receiving the psync
command. That way all replica connections will be accessible from other parts of your program.
Note that you’ll need to find a way to prevent the defer connection.Close()
statement within handleConnection
from firing, else that’d close the connection when the handleConnection
function exits.
Hope this helps!