Documentation ¶
Index ¶
- Constants
- Variables
- func MeasureConnectivity(ctx context.Context, peers []Peer) map[string]float64
- type InternalTransport
- type Peer
- func (p *Peer) Alive() bool
- func (p *Peer) Call(method string, args any, reply any) error
- func (p *Peer) Connect() (pmtp.Client, error)
- func (p *Peer) Delete(ctx context.Context, path string, result any) error
- func (p *Peer) DistanceTo(other *Peer) float64
- func (p *Peer) Get(ctx context.Context, path string, result any) error
- func (p *Peer) Patch(ctx context.Context, path string, body any, result any) error
- func (p *Peer) Post(ctx context.Context, path string, body any, result any) error
- func (p *Peer) Put(ctx context.Context, path string, body any, result any) error
- func (p *Peer) RTT(ctx context.Context) (ms float64)
- func (p *Peer) Request(ctx context.Context, method string, path string, body any, result any) error
- func (p *Peer) SendRequest(req *http.Request) (res *http.Response, err error)
- type Peerlist
- type SDSource
Constants ¶
View Source
const HeartbeatInterval = 30 * time.Second
View Source
const HeartbeatTimeout = 1 * time.Hour
Variables ¶
View Source
var HttpClient = &http.Client{Transport: InternalTransport{}}
Functions ¶
Types ¶
type InternalTransport ¶
type InternalTransport struct{}
type Peer ¶
type Peer struct { MachineID string `json:"machine_id,omitempty"` // the machine ID of the member Host string `json:"host"` // the hostname of the member IP string `json:"ip"` // the IP address of the member Lat float64 `json:"lat" bson:"lat"` // the latitude and longitude of the member Lon float64 `json:"lon" bson:"lon"` // the latitude and longitude of the member Country string `json:"country"` // the country of the member ISP string `json:"isp"` // the ISP of the member Heartbeat int64 `json:"heartbeat"` // the time of the last heartbeat (ms since epoch) Me bool `json:"me,omitempty"` // if this is the local member Distance float64 `json:"distance,omitempty"` // the distance from the local member (meters) UD map[string]any `json:"ud"` // user data SD map[string]any `json:"sd"` // system data }
func FillPeerForSelf ¶
func (*Peer) DistanceTo ¶
type Peerlist ¶
type Peerlist struct {
// contains filtered or unexported fields
}
Peerlist type
func NewPeerlist ¶
func (*Peerlist) AddSDSource ¶
Click to show internal directories.
Click to hide internal directories.