storage

package
v2.1.29 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 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"

	// NetworkTopologyFilePrefix is prefix of network topology file name.
	NetworkTopologyFilePrefix = "networktopology"

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

Variables

This section is empty.

Functions

This section is empty.

Types

type DestHost added in v2.0.30

type DestHost 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"`

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

	// Probes is the network information probed to destination host.
	Probes Probes `csv:"probes"`
}

DestHost contains content for destination host.

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 NetworkTopology added in v2.0.30

type NetworkTopology struct {
	// ID is network topology id.
	ID string `csv:"id"`

	// Host is probe source host.
	Host SrcHost `csv:"host"`

	// DestHosts is the destination hosts probed from source host.
	DestHosts []DestHost `csv:"destHosts" csv[]:"5"`

	// CreatedAt is network topology create nanosecond time.
	CreatedAt int64 `csv:"createdAt"`
}

NetworkTopology contains content for network topology.

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 Probes added in v2.0.30

type Probes struct {
	// AverageRTT is the average round-trip time of probes.
	AverageRTT int64 `csv:"averageRTT"`

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

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

Probes contains content for probes.

type SrcHost added in v2.0.30

type SrcHost 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"`

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

SrcHost contains content for source host.

type Storage

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

	// CreateNetworkTopology inserts the network topology into csv file.
	CreateNetworkTopology(NetworkTopology) error

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

	// ListNetworkTopology returns all network topologies in csv file.
	ListNetworkTopology() ([]NetworkTopology, error)

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

	// NetworkTopologyCount returns the count of network topologies.
	NetworkTopologyCount() int64

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

	// OpenNetworkTopology opens network topology files for read, it returns io.ReadCloser of network topology files.
	OpenNetworkTopology() (io.ReadCloser, error)

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

	// ClearNetworkTopology removes all network topology files.
	ClearNetworkTopology() 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
Code generated by MockGen.
Code generated by MockGen.

Jump to

Keyboard shortcuts

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