ifconnmgr

package
v0.0.0-...-8b9b725 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2019 License: MIT, MIT Imports: 5 Imported by: 44

README

go-libp2p-interface-connmgr

Coverage Status Travis CI

The interface for libp2p connection managers

Table of Contents

Install

make install

Contribute

PRs are welcome!

Small note: If editing the Readme, please conform to the standard-readme specification.

License

MIT © Jeromy Johnson

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConnManager

type ConnManager interface {

	// TagPeer tags a peer with a string, associating a weight with the tag.
	TagPeer(peer.ID, string, int)

	// Untag removes the tagged value from the peer.
	UntagPeer(p peer.ID, tag string)

	// GetTagInfo returns the metadata associated with the peer,
	// or nil if no metadata has been recorded for the peer.
	GetTagInfo(p peer.ID) *TagInfo

	// TrimOpenConns terminates open connections based on an implementation-defined
	// heuristic.
	TrimOpenConns(ctx context.Context)

	// Notifee returns an implementation that can be called back to inform of
	// opened and closed connections.
	Notifee() inet.Notifiee
}

ConnManager tracks connections to peers, and allows consumers to associate metadata with each peer.

It enables connections to be trimmed based on implementation-defined heuristics.

type NullConnMgr

type NullConnMgr struct{}

func (NullConnMgr) GetTagInfo

func (_ NullConnMgr) GetTagInfo(peer.ID) *TagInfo

func (NullConnMgr) Notifee

func (_ NullConnMgr) Notifee() inet.Notifiee

func (NullConnMgr) TagPeer

func (_ NullConnMgr) TagPeer(peer.ID, string, int)

func (NullConnMgr) TrimOpenConns

func (_ NullConnMgr) TrimOpenConns(context.Context)

func (NullConnMgr) UntagPeer

func (_ NullConnMgr) UntagPeer(peer.ID, string)

type TagInfo

type TagInfo struct {
	FirstSeen time.Time
	Value     int

	// Tags maps tag ids to the numerical values.
	Tags map[string]int

	// Conns maps connection ids (such as remote multiaddr) to their creation time.
	Conns map[string]time.Time
}

TagInfo stores metadata associated with a peer.

Jump to

Keyboard shortcuts

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