github.com/grafana/pyroscope@v1.18.0/pkg/metastore/discovery/discovery.go (about)

     1  package discovery
     2  
     3  import (
     4  	"fmt"
     5  
     6  	"github.com/hashicorp/raft"
     7  )
     8  
     9  type Updates interface {
    10  	Servers(servers []Server)
    11  }
    12  
    13  type UpdateFunc func(servers []Server)
    14  
    15  func (f UpdateFunc) Servers(servers []Server) {
    16  	f(servers)
    17  }
    18  
    19  type Server struct {
    20  	Raft            raft.Server
    21  	ResolvedAddress string
    22  }
    23  
    24  func (s *Server) String() string {
    25  	return fmt.Sprintf("Server{id: %s, Address %s ResolvedAddress: %v}", s.Raft.ID, s.Raft.Address, s.ResolvedAddress)
    26  }
    27  
    28  type Discovery interface {
    29  	Subscribe(updates Updates)
    30  	Rediscover()
    31  	Close()
    32  }