Skip to content

Commit

Permalink
add ListPeers method that returns remote fetchers.
Browse files Browse the repository at this point in the history
  • Loading branch information
manu844 committed Dec 17, 2022
1 parent 7157786 commit c714b1e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
5 changes: 5 additions & 0 deletions galaxycache.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,11 @@ func (universe *Universe) RemovePeers(ids ...string) error {
return universe.peerPicker.remove(ids...)
}

// ListPeers returns Universe's remote fetchers map keyed by peer IDs
func (universe *Universe) ListPeers() map[string]RemoteFetcher {
return universe.peerPicker.listPeers()
}

// Shutdown closes all open fetcher connections
func (universe *Universe) Shutdown() error {
return universe.peerPicker.shutdown()
Expand Down
7 changes: 7 additions & 0 deletions peers.go
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,13 @@ func (pp *PeerPicker) remove(ids ...string) error {
return eg.Wait()
}

func (pp *PeerPicker) listPeers() map[string]RemoteFetcher {
pp.mu.Lock()
defer pp.mu.Unlock()
fetchers := pp.fetchers
return fetchers
}

func (pp *PeerPicker) shutdown() error {
pp.setIncludeSelf(false)
// Clear out all the existing peers
Expand Down

0 comments on commit c714b1e

Please sign in to comment.