plan

package
Version: v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2021 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultRunnerPort = uint16(38080)

Variables

View Source
var DefaultHostList = HostList{
	{
		IPv4:       MustParseIPv4(`127.0.0.1`),
		Slots:      runtime.NumCPU(),
		PublicAddr: `127.0.0.1`,
	},
}
View Source
var DefaultPortRange = PortRange{
	Begin: 10000,
	End:   11000,
}
View Source
var ErrInvalidHostSpec = errors.New("Invalid HostSpec")
View Source
var ErrNoEnoughCapacity = errors.New("no enough capacity")

Functions

func FormatIPv4

func FormatIPv4(ipv4 uint32) string

func GenAlternativeStar added in v0.2.3

func GenAlternativeStar(peers PeerList, off int) *graph.Graph

func GenBinaryTree

func GenBinaryTree(k int) *graph.Graph

func GenBinaryTreeStar

func GenBinaryTreeStar(peers PeerList) *graph.Graph

func GenCircularGraphPair

func GenCircularGraphPair(k, r int) (*graph.Graph, *graph.Graph)

func GenDefaultReduceGraph

func GenDefaultReduceGraph(g *graph.Graph) *graph.Graph

func GenMultiBinaryTreeStar added in v0.2.1

func GenMultiBinaryTreeStar(peers PeerList) []*graph.Graph

func GenMultiStar added in v0.2.3

func GenMultiStar(peers PeerList) []*graph.Graph

func GenStarBcastGraph

func GenStarBcastGraph(k, r int) *graph.Graph

GenStarBcastGraph generates a star shape graph with k vertices and centered at vertice r (0 <= r < k)

func GenTree

func GenTree(peers PeerList) *graph.Graph

func MustParseIPv4

func MustParseIPv4(host string) uint32

func PackIPv4

func PackIPv4(ip net.IP) uint32

func ParseIPv4

func ParseIPv4(host string) (uint32, error)

Types

type Addr

type Addr struct {
	IPv4 uint32
	Port uint16
	Name string
}

Addr is the logical address of a named channel

func (Addr) NetAddr

func (a Addr) NetAddr() NetAddr

func (Addr) Peer added in v0.2.2

func (a Addr) Peer() PeerID

func (Addr) String

func (a Addr) String() string

type Cluster added in v0.2.2

type Cluster struct {
	Runners PeerList
	Workers PeerList
}

func (Cluster) Bytes added in v0.2.2

func (c Cluster) Bytes() []byte

func (Cluster) Clone added in v0.2.2

func (c Cluster) Clone() Cluster

func (Cluster) DebugString added in v0.2.2

func (c Cluster) DebugString() string

func (*Cluster) Eq added in v0.2.2

func (c *Cluster) Eq(d Cluster) bool

func (Cluster) Resize added in v0.2.2

func (c Cluster) Resize(newSize int) (*Cluster, error)

func (Cluster) Validate added in v0.2.2

func (c Cluster) Validate() error

type HostList

type HostList []HostSpec

func ParseHostList

func ParseHostList(hostlist string) (HostList, error)

func (HostList) Cap

func (hl HostList) Cap() int

func (HostList) GenPeerList

func (hl HostList) GenPeerList(np int, pr PortRange) (PeerList, error)

func (HostList) GenRunnerList added in v0.2.2

func (hl HostList) GenRunnerList(port uint16) PeerList

func (HostList) LookupHost added in v0.2.3

func (hl HostList) LookupHost(ipv4 uint32) string

func (HostList) MustGenPeerList added in v0.2.3

func (hl HostList) MustGenPeerList(np int, pr PortRange) PeerList

func (HostList) ShrinkToFit added in v0.2.3

func (hl HostList) ShrinkToFit(np int) HostList

func (HostList) SlotOf added in v0.2.2

func (hl HostList) SlotOf(ipv4 uint32) int

func (HostList) String

func (hl HostList) String() string

type HostSpec

type HostSpec struct {
	IPv4       uint32
	Slots      int
	PublicAddr string
}

func (HostSpec) DebugString added in v0.2.3

func (h HostSpec) DebugString() string

func (HostSpec) String

func (h HostSpec) String() string

type Interval

type Interval struct {
	Begin int
	End   int
}

Interval represents the interval of integers [Begin, End)

func EvenPartition

func EvenPartition(r Interval, k int) []Interval

EvenPartition parts an Interval into k parts such that the length of each part differ at most 1

func (Interval) Len

func (i Interval) Len() int

type NetAddr

type NetAddr struct {
	IPv4 uint32
	Port uint16
}

NetAddr is the network address of a Peer

func (NetAddr) ColocatedWith

func (a NetAddr) ColocatedWith(b NetAddr) bool

func (NetAddr) SockFile

func (a NetAddr) SockFile() string

func (NetAddr) String

func (a NetAddr) String() string

func (NetAddr) WithName

func (a NetAddr) WithName(name string) Addr

type PeerID

type PeerID NetAddr

PeerID is the unique identifier of a peer.

func ParsePeerID added in v0.2.2

func ParsePeerID(val string) (*PeerID, error)

func (PeerID) ColocatedWith

func (p PeerID) ColocatedWith(q PeerID) bool

func (PeerID) ListenAddr added in v0.2.2

func (p PeerID) ListenAddr(strict bool) NetAddr

func (PeerID) SockFile

func (p PeerID) SockFile() string

func (PeerID) String

func (p PeerID) String() string

func (PeerID) WithName

func (p PeerID) WithName(name string) Addr

type PeerList

type PeerList []PeerID

PeerList is an ordered list of PeerIDs

func ParsePeerList added in v0.2.2

func ParsePeerList(val string) (PeerList, error)

func (PeerList) Bytes

func (pl PeerList) Bytes() []byte

func (PeerList) Clone added in v0.2.2

func (pl PeerList) Clone() PeerList

func (PeerList) Contains added in v0.2.2

func (pl PeerList) Contains(p PeerID) bool

func (PeerList) DebugString added in v0.2.2

func (pl PeerList) DebugString() string

func (PeerList) Diff

func (pl PeerList) Diff(ql PeerList) (PeerList, PeerList)

func (PeerList) Disjoint added in v0.2.2

func (pl PeerList) Disjoint(ql PeerList) bool

func (PeerList) Eq

func (pl PeerList) Eq(ql PeerList) bool

func (PeerList) HostCount added in v0.2.3

func (pl PeerList) HostCount() int

func (PeerList) Intersection added in v0.2.2

func (pl PeerList) Intersection(ql PeerList) PeerList

func (PeerList) LocalRank

func (pl PeerList) LocalRank(q PeerID) (int, bool)

func (PeerList) LocalSize added in v0.2.3

func (pl PeerList) LocalSize(q PeerID) int

func (PeerList) On

func (pl PeerList) On(host uint32) PeerList

func (PeerList) Others added in v0.2.3

func (pl PeerList) Others(self PeerID) PeerList

func (PeerList) PartitionByHost added in v0.2.3

func (pl PeerList) PartitionByHost() ([]int, []int)

PartitionByHost partitions the PeerList into several groups by host IP, each with a master. It returns two int list masters and masterOf, representing the partition, where masters is the list of ranks of masters masterOf[i] is the rank of master of the i-th peer

func (PeerList) Rank added in v0.2.1

func (pl PeerList) Rank(q PeerID) (int, bool)

func (PeerList) Select added in v0.2.2

func (pl PeerList) Select(ranks []int) PeerList

func (PeerList) Set

func (pl PeerList) Set() map[PeerID]struct{}

func (PeerList) String

func (pl PeerList) String() string

type PortRange

type PortRange struct {
	Begin uint16
	End   uint16
}

func ParsePortRange

func ParsePortRange(val string) (*PortRange, error)

func (PortRange) Cap

func (pr PortRange) Cap() int

func (*PortRange) Set added in v0.2.0

func (pr *PortRange) Set(val string) error

Set implements flags.Value::Set

func (PortRange) String

func (pr PortRange) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL