-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Question regarding PeerDiscovery api #38
Comments
You can use Notify to get a callback and you can run this in a Go routine for async. Check out croc for a battle-tested example. Croc needs blocking because it decides to switch to LAN only if peers are connected. Can you describe your use case some more for peer discovery? |
I didn't notice, notify also gets called by the Yes, I can run
I have a cli application which I can use for local operation. But it is also possible to start it as a server which accepts rpc calls from a client. In this way, the client is able to perform operations on a remote server. To ease the server discovery in a LAN, I want to start peerdiscovery on the server with TimeLimit=-1. Theoretically, on the server, notification of available clients is not necessary. Everything is already possible with the current API of peerdiscovery but I see no way to stop the discovery service in a clean way. |
You can use StopChan or Shutdown to stop peer discovery. Can you link to your code? It will be easier to see your code to get an idea of what might work best. |
I missed the StopChan. That works indeed.
ps, err := peerdiscovery.NewPeerDiscovery(ps)
ps.Shutdown() // either TimeLimit = -1 and this point will not be reached or there's a limit but than discovery has already been stopped or do I miss something regarding the |
Hi, I'm about to use this library in a client-server project where the client should be able to discover servers in the lan.
I looked at the
PeerDiscovery
object and its attached methods. For me, it's strange how it is implemented.NewPeerDiscovery()
creates this object and does a peer discover in a blocking way. Still PeerDiscovery has aShutdown()
method to stop discovery. But how should this work, if the object creation is blocking until discovering has been finished?Wouldn't it be better to create the option, have a
Serve()
andShutdown()
method and get the notification about new peer via callback (or channel)?The text was updated successfully, but these errors were encountered: