dcc

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2024 License: CC0-1.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DCC

type DCC struct {
	// contains filtered or unexported fields
}

DCC creates a new socket client instance where it'll download the DCC transaction into the specified io.Writer destination

func NewDCC

func NewDCC(
	address string,
	size int,
	writer io.Writer,
	dialFunc func(ctx context.Context, network, address string) (net.Conn, error),
) *DCC

NewDCC creates a new DCC instance. the host, port are needed for the socket client connection the size is required so the download progress is calculated the writer is required to store the transaction fragments into the specified io.Writer

func (*DCC) Run

func (d *DCC) Run(ctx context.Context) (
	progressc <-chan Progress,
	done <-chan error,
)

Run established the connection with the DCC TCP socket and returns two channels, where one is used for the download progress and the other is used to return exceptions during our transaction. A context is required, where you have the ability to cancel and timeout a download. One should check the second value for the progress/error channels when receiving data as if the channels are closed, it means that the transaction is finished or got interrupted.

type Progress

type Progress struct {
	Speed           float64
	Percentage      float64
	CurrentFileSize float64
	FileSize        float64
}

Progress contains the progression of the download handled by the DCC client socket

func (Progress) LogValue

func (p Progress) LogValue() slog.Value

Jump to

Keyboard shortcuts

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