storage

package
v2.1.62 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DownloadFilePrefix is prefix of download file name.
	DownloadFilePrefix = "download"

	// CSVFileExt is extension of file name.
	CSVFileExt = "csv"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Download added in v2.0.30

type Download struct {
	// ID is peer id.
	ID string `csv:"id"`

	// Tag is peer tag.
	Tag string `csv:"tag"`

	// Application is peer application.
	Application string `csv:"application"`

	// State is the download state of the peer.
	State string `csv:"state"`

	// Error is the details of error.
	Error Error `csv:"error"`

	// Cost is the task download duration of nanosecond.
	Cost int64 `csv:"cost"`

	// FinishedPieceCount is finished piece count.
	FinishedPieceCount int32 `csv:"finishedPieceCount"`

	// Task is peer task.
	Task Task `csv:"task"`

	// Host is peer host.
	Host Host `csv:"host"`

	// Parents is peer parents.
	Parents []Parent `csv:"parents" csv[]:"20"`

	// CreatedAt is peer create nanosecond time.
	CreatedAt int64 `csv:"createdAt"`

	// UpdatedAt is peer update nanosecond time.
	UpdatedAt int64 `csv:"updatedAt"`
}

Download contains content for download.

type Error added in v2.0.9

type Error struct {
	time.Duration
	// Code is the code of error.
	Code string `csv:"code"`

	// Message is the message of error.
	Message string `csv:"message"`
}

Error contains content for error.

type Host added in v2.0.8

type Host struct {
	// ID is host id.
	ID string `csv:"id"`

	// Type is host type.
	Type string `csv:"type"`

	// Hostname is host name.
	Hostname string `csv:"hostname"`

	// IP is host ip.
	IP string `csv:"ip"`

	// Port is grpc service port.
	Port int32 `csv:"port"`

	// DownloadPort is piece downloading port.
	DownloadPort int32 `csv:"downloadPort"`

	// Host OS.
	OS string `csv:"os"`

	// Host platform.
	Platform string `csv:"platform"`

	// Host platform family.
	PlatformFamily string `csv:"platformFamily"`

	// Host platform version.
	PlatformVersion string `csv:"platformVersion"`

	// Host kernel version.
	KernelVersion string `csv:"kernelVersion"`

	// ConcurrentUploadLimit is concurrent upload limit count.
	ConcurrentUploadLimit int32 `csv:"concurrentUploadLimit"`

	// ConcurrentUploadCount is concurrent upload count.
	ConcurrentUploadCount int32 `csv:"concurrentUploadCount"`

	// UploadCount is total upload count.
	UploadCount int64 `csv:"uploadCount"`

	// UploadFailedCount is upload failed count.
	UploadFailedCount int64 `csv:"uploadFailedCount"`

	// CPU Stat.
	CPU resource.CPU `csv:"cpu"`

	// Memory Stat.
	Memory resource.Memory `csv:"memory"`

	// Network Stat.
	Network resource.Network `csv:"network"`

	// Disk Stat.
	Disk resource.Disk `csv:"disk"`

	// Build information.
	Build resource.Build `csv:"build"`

	// SchedulerClusterID is scheduler cluster id.
	SchedulerClusterID int64 `csv:"schedulerClusterId"`

	// CreatedAt is peer create nanosecond time.
	CreatedAt int64 `csv:"createdAt"`

	// UpdatedAt is peer update nanosecond time.
	UpdatedAt int64 `csv:"updatedAt"`
}

Host contains content for host.

type Parent added in v2.0.8

type Parent struct {
	// ID is peer id.
	ID string `csv:"id"`

	// Tag is peer tag.
	Tag string `csv:"tag"`

	// Application is peer application.
	Application string `csv:"application"`

	// State is the download state of the peer.
	State string `csv:"state"`

	// Cost is the task download duration of nanosecond.
	Cost int64 `csv:"cost"`

	// UploadPieceCount is upload piece count.
	UploadPieceCount int32 `csv:"uploadPieceCount"`

	// FinishedPieceCount is finished piece count.
	FinishedPieceCount int32 `csv:"finishedPieceCount"`

	// Host is peer host.
	Host Host `csv:"host"`

	// Pieces is downloaded pieces from parent host.
	Pieces []Piece `csv:"pieces" csv[]:"10"`

	// CreatedAt is peer create nanosecond time.
	CreatedAt int64 `csv:"createdAt"`

	// UpdatedAt is peer update nanosecond time.
	UpdatedAt int64 `csv:"updatedAt"`
}

Parent contains content for parent.

type Piece added in v2.0.30

type Piece struct {
	// Length is piece length.
	Length int64 `csv:"length"`

	// Cost is the cost time for downloading piece.
	Cost int64 `csv:"cost"`

	// CreatedAt is piece create time.
	CreatedAt int64 `csv:"createdAt"`
}

Piece contains content for piece.

type Storage

type Storage interface {
	// CreateDownload inserts the download into csv file.
	CreateDownload(Download) error

	// ListDownload returns all downloads in csv file.
	ListDownload() ([]Download, error)

	// DownloadCount returns the count of downloads.
	DownloadCount() int64

	// OpenDownload opens download files for read, it returns io.ReadCloser of download files.
	OpenDownload() (io.ReadCloser, error)

	// ClearDownload removes all download files.
	ClearDownload() error
}

Storage is the interface used for storage.

func New

func New(baseDir string, maxSize, maxBackups, bufferSize int) (Storage, error)

New returns a new Storage instance.

type Task added in v2.0.8

type Task struct {
	// ID is task id.
	ID string `csv:"id"`

	// URL is task download url.
	URL string `csv:"url"`

	// Type is task type.
	Type string `csv:"type"`

	// ContentLength is task total content length.
	ContentLength int64 `csv:"contentLength"`

	// TotalPieceCount is total piece count.
	TotalPieceCount int32 `csv:"totalPieceCount"`

	// BackToSourceLimit is back-to-source limit.
	BackToSourceLimit int32 `csv:"backToSourceLimit"`

	// BackToSourcePeerCount is back-to-source peer count.
	BackToSourcePeerCount int32 `csv:"backToSourcePeerCount"`

	// State is the download state of the task.
	State string `csv:"state"`

	// CreatedAt is peer create nanosecond time.
	CreatedAt int64 `csv:"createdAt"`

	// UpdatedAt is peer update nanosecond time.
	UpdatedAt int64 `csv:"updatedAt"`
}

Task contains content for task.

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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