cdn

package
v2.0.3 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2022 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultSystemReservedBandwidth is the default network bandwidth reserved for system software.
	// unit: MB/s
	DefaultSystemReservedBandwidth = 20 * unit.MB
	// DefaultMaxBandwidth is the default network bandwidth that cdn can use.
	// unit: MB/s
	DefaultMaxBandwidth = 1 * unit.GB
)
View Source
const (
	CacheReport      = "cache"
	DownloaderReport = "download"
)
View Source
const (
	DefaultWriterRoutineLimit = 4
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config added in v2.0.2

type Config struct {
	// SystemReservedBandwidth is the network bandwidth reserved for system software.
	// default: 20 MB, in format of G(B)/g/M(B)/m/K(B)/k/B, pure number will also be parsed as Byte.
	SystemReservedBandwidth unit.Bytes `yaml:"systemReservedBandwidth" mapstructure:"systemReservedBandwidth"`

	// MaxBandwidth is the network bandwidth that cdn system can use.
	// default: 200 MB, in format of G(B)/g/M(B)/m/K(B)/k/B, pure number will also be parsed as Byte.
	MaxBandwidth unit.Bytes `yaml:"maxBandwidth" mapstructure:"maxBandwidth"`

	// WriterRoutineLimit is the count of write goroutine for one task
	WriterRoutineLimit int `yaml:"WriterRoutineLimit" mapstructure:"WriterRoutineLimit"`
}

func DefaultConfig added in v2.0.2

func DefaultConfig() Config

func (Config) Validate added in v2.0.2

func (c Config) Validate() []error

type Manager

type Manager interface {

	// TriggerCDN will trigger the download resource from sourceURL.
	TriggerCDN(context.Context, *task.SeedTask) (*task.SeedTask, error)

	// Delete the cdn meta with specified taskID.
	// The file on the disk will be deleted when the force is true.
	Delete(taskID string) error

	// TryFreeSpace checks if the free space of the storage is larger than the fileLength.
	TryFreeSpace(fileLength int64) (bool, error)
}

Manager as an interface defines all operations against CDN and operates on the underlying files stored on the local disk, etc.

func NewManager

func NewManager(config Config, cacheStore storage.Manager, progressManager progress.Manager,
	taskManager task.Manager) (Manager, error)

NewManager returns a new Manager.

Directories

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

Jump to

Keyboard shortcuts

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