storage

package
v2.0.9-alpha.6 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2022 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// RecordFilePrefix is prefix of record file name.
	RecordFilePrefix = "record"

	// RecordFileExt is extension of record file name.
	RecordFileExt = "csv"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Build added in v2.0.8

type Build struct {
	// Git version.
	GitVersion string `csv:"gitVersion"`

	// Git commit.
	GitCommit string `csv:"gitCommit"`

	// Golang version.
	GoVersion string `csv:"goVersion"`

	// Build platform.
	Platform string `csv:"platform"`
}

Build contains content for build.

type CPU added in v2.0.8

type CPU struct {
	// Number of logical cores in the system.
	LogicalCount uint32 `csv:"logicalCount"`

	// Number of physical cores in the system.
	PhysicalCount uint32 `csv:"physicalCount"`

	// Percent calculates the percentage of cpu used.
	Percent float64 `csv:"percent"`

	// Calculates the percentage of cpu used by process.
	ProcessPercent float64 `csv:"processPercent"`

	// Times contains the amounts of time the CPU has spent performing different kinds of work.
	Times CPUTimes `csv:"times"`
}

CPU contains content for cpu.

type CPUTimes added in v2.0.8

type CPUTimes struct {
	// CPU time of user.
	User float64 `csv:"user"`

	// CPU time of system.
	System float64 `csv:"system"`

	// CPU time of idle.
	Idle float64 `csv:"idle"`

	// CPU time of nice.
	Nice float64 `csv:"nice"`

	// CPU time of iowait.
	Iowait float64 `csv:"iowait"`

	// CPU time of irq.
	Irq float64 `csv:"irq"`

	// CPU time of softirq.
	Softirq float64 `csv:"softirq"`

	// CPU time of steal.
	Steal float64 `csv:"steal"`

	// CPU time of guest.
	Guest float64 `csv:"guest"`

	// CPU time of guest nice.
	GuestNice float64 `csv:"guestNice"`
}

CPUTimes contains content for cpu times.

type Disk added in v2.0.8

type Disk struct {
	// Total amount of disk on the data path of dragonfly.
	Total uint64 `csv:"total"`

	// Free amount of disk on the data path of dragonfly.
	Free uint64 `csv:"free"`

	// Used amount of disk on the data path of dragonfly.
	Used uint64 `csv:"used"`

	// Used percent of disk on the data path of dragonfly directory.
	UsedPercent float64 `csv:"usedPercent"`

	// Total amount of indoes on the data path of dragonfly directory.
	InodesTotal uint64 `csv:"inodesTotal"`

	// Used amount of indoes on the data path of dragonfly directory.
	InodesUsed uint64 `csv:"inodesUsed"`

	// Free amount of indoes on the data path of dragonfly directory.
	InodesFree uint64 `csv:"inodesFree"`

	// Used percent of indoes on the data path of dragonfly directory.
	InodesUsedPercent float64 `csv:"inodesUsedPercent"`
}

Disk contains content for disk.

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 CPU `csv:"cpu"`

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

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

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

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

	// 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 Memory added in v2.0.8

type Memory struct {
	// Total amount of RAM on this system.
	Total uint64 `csv:"total"`

	// RAM available for programs to allocate.
	Available uint64 `csv:"available"`

	// RAM used by programs.
	Used uint64 `csv:"used"`

	// Percentage of RAM used by programs.
	UsedPercent float64 `csv:"usedPercent"`

	// Calculates the percentage of memory used by process.
	ProcessUsedPercent float64 `csv:"processUsedPercent"`

	// This is the kernel's notion of free memory.
	Free uint64 `csv:"free"`
}

Memory contains content for memory.

type Network added in v2.0.8

type Network struct {
	// Return count of tcp connections opened and status is ESTABLISHED.
	TCPConnectionCount uint32 `csv:"tcpConnectionCount"`

	// Return count of upload tcp connections opened and status is ESTABLISHED.
	UploadTCPConnectionCount uint32 `csv:"uploadTCPConnectionCount"`

	// Security domain for network.
	SecurityDomain string `csv:"securityDomain"`

	// Location path(area|country|province|city|...).
	Location string `csv:"location"`

	// IDC where the peer host is located
	IDC string `csv:"idc"`

	// Network topology(switch|router|...).
	NetTopology string `csv:"netTopology"`
}

Network contains content for network.

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

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

	// 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 Record

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

	// 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"`
}

Record contains content for record.

type Storage

type Storage interface {
	// Create inserts the record into csv file.
	Create(Record) error

	// List returns all of records in csv file.
	List() ([]Record, error)

	// Count returns the count of records.
	Count() int64

	// Open opens storage for read, it returns io.ReadCloser of storage files.
	Open() (io.ReadCloser, error)

	// Clear removes all record files.
	Clear() 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 instence.

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