discovery

package
v0.2.34 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 5, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DiscoveryQueryTimeout = 20 * time.Second
)

Variables

This section is empty.

Functions

func PublishChannel

func PublishChannel(Conn net.Conn, Channel string, AddressURLs []string) error

PublishChannel publishes current peerinfo into the connection to the server. Returns any error encountered, the connection will stay alive after the publish is done.

func Watch added in v0.2.33

func Watch(ctx context.Context, Conn net.Conn, Channel string, PrefixMatch bool, Callback func(*PeerInfo) error) error

Returns error only if ctx is cancelled, `Callback` returns error or initial handshake failed.

Types

type Config

type Config struct {
	TracerFunc        util.TracerFunc
	EvictExistingPeer bool
}

type ExternalSourcePeer added in v0.2.33

type ExternalSourcePeer struct {
	InfoMap map[string]*PeerInfo
}

type Peer

type Peer struct {
	Conn     *trackConn
	PeerInfo *PeerInfo
}

type PeerInfo

type PeerInfo struct {
	CreatedAt time.Time `json:"create-at"`
	Channel   string    `json:"channel"`

	AddressURLs []string `json:"address-urls"`
}

func QueryChannel

func QueryChannel(Conn net.Conn, Channel string, PrefixMatch bool) ([]*PeerInfo, error)

QueryChannel queries the channel info from the connection to the server. The connection will not be closed by this function.

type Request

type Request struct {
	Type    string `json:"type"`
	Payload string `json:"payload"`

	PeerInfo []*PeerInfo `json:"peer-info"`
	// Only works for queries.
	PrefixMatch bool `json:"prefix-match"`
}

type Response

type Response struct {
	Payload string `json:"payload"`

	PeerInfo []*PeerInfo `json:"peer-info"`
	Success  bool        `json:"success"`
}

type Server

type Server struct {
	// contains filtered or unexported fields
}

func New

func New(config *Config) *Server

func (*Server) AddExternalSource added in v0.2.33

func (s *Server) AddExternalSource(sourceName string, InfoMap []*PeerInfo)

func (*Server) Close

func (s *Server) Close() error

func (*Server) ListChannel added in v0.2.33

func (s *Server) ListChannel(Channel string, PrefixMatch bool) []*PeerInfo

func (*Server) Serve

func (s *Server) Serve(lis net.Listener) error

func (*Server) ServeConnection

func (s *Server) ServeConnection(c net.Conn)

ServeConnection will close the connection once done.

func (*Server) UpdateExternalStorageTable added in v0.2.33

func (s *Server) UpdateExternalStorageTable(sourceName string, info *PeerInfo)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL