pex

package
v2.1.50 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2024 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SearchPeerResultTypeLocal = iota
	SearchPeerResultTypeReplica
	SearchPeerResultTypeRemote
	SearchPeerResultTypeNotFound
)
View Source
const (
	GRPCMetadataHostID = "HostID"
)

Variables

View Source
var (
	ErrAlreadyExists = errors.New("member is already exist")
	ErrNotFound      = errors.New("member not found")
)

Functions

func IsErrAlreadyExists

func IsErrAlreadyExists(err error) bool

func WithAdvertiseAddr

func WithAdvertiseAddr(advertiseAddr string) func(*memberlist.Config, *peerExchangeConfig)

func WithAdvertisePort

func WithAdvertisePort(advertisePort int) func(*memberlist.Config, *peerExchangeConfig)

func WithBindAddr

func WithBindAddr(bindAddr string) func(*memberlist.Config, *peerExchangeConfig)

func WithBindPort

func WithBindPort(bindPort int) func(*memberlist.Config, *peerExchangeConfig)

func WithInitialRetryInterval

func WithInitialRetryInterval(interval time.Duration) func(*memberlist.Config, *peerExchangeConfig)

func WithName

func WithName(name string) func(*memberlist.Config, *peerExchangeConfig)

func WithReSyncInterval

func WithReSyncInterval(interval time.Duration) func(*memberlist.Config, *peerExchangeConfig)

func WithReplicaCleanPercentage added in v2.1.45

func WithReplicaCleanPercentage(percentage int32) func(*memberlist.Config, *peerExchangeConfig)

func WithReplicaThreshold

func WithReplicaThreshold(threshold int) func(*memberlist.Config, *peerExchangeConfig)

Types

type DestPeer

type DestPeer struct {
	*MemberMeta
	PeerID string
}

type InitialMember

type InitialMember = memberlist.Node

type InitialMemberLister

type InitialMemberLister interface {
	List() ([]*InitialMember, error)
}

func NewSeedPeerMemberLister

func NewSeedPeerMemberLister(getSeedPeers func() ([]*managerv1.SeedPeer, error)) InitialMemberLister

func NewStaticPeerMemberLister

func NewStaticPeerMemberLister(members []*InitialMember) InitialMemberLister

type MemberMeta

type MemberMeta struct {
	HostID    string
	IP        string
	RPCPort   int32
	ProxyPort int32
	// contains filtered or unexported fields
}

func ExtractNodeMeta

func ExtractNodeMeta(node *memberlist.Node) (*MemberMeta, error)

type PeerExchangeMember

type PeerExchangeMember interface {
	FindMember(hostID string) (*MemberMeta, error)
	Register(member *MemberMeta, sr PeerMetadataSendReceiveCloser) error
	UnRegister(member *MemberMeta)
	UnRegisterByHostID(hostID string)
}

type PeerExchangeRPC

type PeerExchangeRPC interface {
	PeerExchange(exchangeServer dfdaemonv1.Daemon_PeerExchangeServer) error
}

type PeerExchangeServer

type PeerExchangeServer interface {
	Serve(localMember *MemberMeta) error
	Stop() error

	PeerSearchBroadcaster() PeerSearchBroadcaster
	PeerExchangeRPC() PeerExchangeRPC
}

func NewPeerExchange

func NewPeerExchange(
	reclaim ReclaimFunc,
	lister InitialMemberLister,
	grpcDialTimeout time.Duration,
	grpcDialOptions []grpc.DialOption, opts ...func(*memberlist.Config, *peerExchangeConfig)) (PeerExchangeServer, error)

type PeerExchangeSynchronizer

type PeerExchangeSynchronizer interface {
	Sync(nodeMeta *MemberMeta, peer *dfdaemonv1.PeerExchangeData)
}

type PeerMetadataSendReceiveCloser

type PeerMetadataSendReceiveCloser interface {
	PeerMetadataSendReceiver
	Close() error
}

func NewPeerMetadataSendReceiveCloser

func NewPeerMetadataSendReceiveCloser(p PeerMetadataSendReceiver, close func() error) PeerMetadataSendReceiveCloser

type PeerMetadataSendReceiver

type PeerMetadataSendReceiver interface {
	Send(*dfdaemonv1.PeerExchangeData) error
	Recv() (*dfdaemonv1.PeerExchangeData, error)
}

type PeerSearchBroadcaster

type PeerSearchBroadcaster interface {
	SearchPeer(task string) SearchPeerResult
	BroadcastPeer(data *dfdaemonv1.PeerMetadata)
	BroadcastPeers(data *dfdaemonv1.PeerExchangeData)
}

type ReclaimFunc

type ReclaimFunc func(task, peer string) error

type SearchPeerResult

type SearchPeerResult struct {
	Type  SearchPeerResultType
	Peers []*DestPeer
}

type SearchPeerResultType

type SearchPeerResultType int

Jump to

Keyboard shortcuts

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