perlin-network / noise

A decentralized P2P networking stack written in Go.
https://godoc.org/github.com/perlin-network/noise
MIT License
1.78k stars 213 forks source link

Example for reconnecting to nodes if they drop out #284

Open pocockn opened 4 years ago

pocockn commented 4 years ago

I'm creating an application that has a node that broadcasts messages out to all the nodes that are connected to it. I'm currently using a simple approach where I get my child nodes to ping the master node so they get added to the route table and then my master node can send messages to all the connected nodes.

I'm thinking it would be nice to have an example to show how to handle the situation when my master node drops out and then the child nodes do some sort of retry until the master node comes back online.

I wanted to have a loop running and a select that listened on the client method WaitUntilReady that tells my child nodes the client connection has closed and then tries to reconnect every x seconds but I don't think WaitUntilReady returns a channel.

I'm not sure if my use case can be easily done with the current implementation, great library though.

johnhorsema commented 4 years ago

Check out lithew/monte. It's by the same author and has reconnection functionality.