discovery

package
v0.2.26 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2024 License: MIT Imports: 6 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.

Types

type Config

type Config struct {
	TracerFunc        util.TracerFunc
	EvictExistingPeer bool
}

type Peer

type Peer struct {
	Conn     net.Conn
	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) ([]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"`
}

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) Close

func (s *Server) Close() error

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.

Jump to

Keyboard shortcuts

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