basestreamleecher

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2023 License: MIT Imports: 2 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseLeecher

type BaseLeecher struct {
	Peers map[string]struct{}

	Quit chan struct{}

	Wg sync.WaitGroup

	Mu *sync.RWMutex

	Terminated bool
	// contains filtered or unexported fields
}

BaseLeecher is a generic items downloader

func New

func New(recheckInterval time.Duration, callback Callbacks) *BaseLeecher

New creates a generic items downloader

func (*BaseLeecher) PeersNum

func (d *BaseLeecher) PeersNum() int

func (*BaseLeecher) RegisterPeer

func (d *BaseLeecher) RegisterPeer(peer string) error

RegisterPeer injects a new download peer to download items from.

func (*BaseLeecher) Routine

func (d *BaseLeecher) Routine()

func (*BaseLeecher) Start

func (d *BaseLeecher) Start()

func (*BaseLeecher) Stop

func (d *BaseLeecher) Stop()

Stop interrupts the leecher, canceling all the pending operations. Stop waits until all the internal goroutines have finished.

func (*BaseLeecher) Terminate

func (d *BaseLeecher) Terminate()

func (*BaseLeecher) UnregisterPeer

func (d *BaseLeecher) UnregisterPeer(peer string) error

UnregisterPeer removes a peer from the known list, preventing current or any future sessions with the peer

type Callbacks

type Callbacks struct {
	SelectSessionPeerCandidates func() []string
	ShouldTerminateSession      func() bool
	StartSession                func(candidates []string)
	TerminateSession            func()
	OngoingSession              func() bool
	OngoingSessionPeer          func() string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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