Documentation ¶
Index ¶
Constants ¶
View Source
const ( // DefaultListenPort is the default port cdn server listens on. DefaultListenPort = 8003 // DefaultDownloadPort is the default port for download files from cdn. DefaultDownloadPort = 8001 )
View Source
const ( // DefaultPieceSize 4M DefaultPieceSize = 4 * 1024 * 1024 // DefaultPieceSizeLimit 15M DefaultPieceSizeLimit = 15 * 1024 * 1024 )
View Source
const ( // DefaultGCInitialDelay is the delay time from the start to the first GC execution. DefaultGCInitialDelay = 6 * time.Second // DefaultGCMetaInterval is the interval time to execute the GC meta. DefaultGCMetaInterval = 2 * time.Minute // DefaultTaskExpireTime when a task is not accessed within the taskExpireTime, // and it will be treated to be expired. DefaultTaskExpireTime = 30 * time.Minute )
gc
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 ( AttributeObtainSeedsRequest = attribute.Key("d7y.obtain.seeds.request") AttributeGetPieceTasksRequest = attribute.Key("d7y.get.piece.tasks.request") AttributePiecePacketResult = attribute.Key("d7y.piece.packet.result") AttributeTaskID = attribute.Key("d7y.task.id") AttributeTaskStatus = attribute.Key("d7y.task.status") AttributeTaskURL = attribute.Key("d7y.task.url") AttributeTaskInfo = attribute.Key("d7y.taskInfo") AttributeIfReuseTask = attribute.Key("d7y.task.already.exist") AttributeSeedPiece = attribute.Key("d7y.seed.piece") AttributeSeedTask = attribute.Key("d7y.seed.task") AttributeCacheResult = attribute.Key("d7y.cache.result") AttributeWriteGoroutineCount = attribute.Key("d7y.write.goroutine.count") AttributeDownloadFileInfo = attribute.Key("d7y.download.file.info") AttributeDetectCacheResult = attribute.Key("d7y.detect.cache.result") )
View Source
const ( SpanObtainSeeds = "cdn-obtain-seeds" SpanGetPieceTasks = "get-piece-tasks" SpanTaskRegister = "task-register" SpanAndOrUpdateTask = "add-or-update-task" SpanTriggerCDNSyncAction = "trigger-cdn-sync-action" SpanTriggerCDN = "trigger-cdn" SpanDetectCache = "detect-cache" SpanDownloadSource = "download-source" SpanWriteData = "write-data" )
View Source
const ( EventHitUnReachableURL = "hit-unReachableURL" EventRequestSourceFileLength = "request-source-file-length" EventDeleteUnReachableTask = "downloaded" EventInitSeedProgress = "init-seed-progress" EventWatchSeedProgress = "watch-seed-progress" EventPublishPiece = "publish-piece" EventPublishTask = "publish-task" )
View Source
const (
CDNWriterRoutineLimit = 4
)
View Source
const ( // DefaultFailAccessInterval is the interval time after failed to access the URL. DefaultFailAccessInterval = 3 * time.Minute )
View Source
const (
DefaultKeepAliveInterval = 5 * time.Second
)
View Source
const (
DefaultStorageMode = "disk"
)
Variables ¶
View Source
var ( DefaultDiskBaseDir = filepath.Join(basic.HomeDir, "ftp") DefaultMemoryBaseDir = "/dev/shm/dragonfly" )
Functions ¶
func NewDefaultPlugins ¶
func NewDefaultPlugins() map[plugins.PluginType][]*plugins.PluginProperties
NewDefaultPlugins creates plugin instants with default values.
Types ¶
type BaseProperties ¶
type BaseProperties struct { // ListenPort is the port cdn server listens on. // default: 8002 ListenPort int `yaml:"listenPort" mapstructure:"listenPort"` // DownloadPort is the port for download files from cdn. // default: 8001 DownloadPort int `yaml:"downloadPort" mapstructure:"downloadPort"` // 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"` // AdvertiseIP is used to set the ip that we advertise to other peer in the p2p-network. // By default, the first non-loop address is advertised. AdvertiseIP string `yaml:"advertiseIP" mapstructure:"advertiseIP"` // FailAccessInterval is the interval time after failed to access the URL. // unit: minutes // default: 3 FailAccessInterval time.Duration `yaml:"failAccessInterval" mapstructure:"failAccessInterval"` // gc related // GCInitialDelay is the delay time from the start to the first GC execution. // default: 6s GCInitialDelay time.Duration `yaml:"gcInitialDelay" mapstructure:"gcInitialDelay"` // GCMetaInterval is the interval time to execute GC meta. // default: 2min GCMetaInterval time.Duration `yaml:"gcMetaInterval" mapstructure:"gcMetaInterval"` // TaskExpireTime when a task is not accessed within the taskExpireTime, // and it will be treated to be expired. // default: 3min TaskExpireTime time.Duration `yaml:"taskExpireTime" mapstructure:"taskExpireTime"` // StorageMode disk/hybrid/memory StorageMode string `yaml:"storageMode" mapstructure:"storageMode"` // Manager configuration Manager ManagerConfig `yaml:"manager" mapstructure:"manager"` // Host configuration Host HostConfig `yaml:"host" mapstructure:"host"` // Metrics configuration Metrics *RestConfig `yaml:"metrics" mapstructure:"metrics"` }
BaseProperties contains all basic properties of cdn system.
func NewDefaultBaseProperties ¶
func NewDefaultBaseProperties() *BaseProperties
NewDefaultBaseProperties creates an base properties instant with default values.
type Config ¶
type Config struct { base.Options `yaml:",inline" mapstructure:",squash"` *BaseProperties `yaml:"base" mapstructure:"base"` Plugins map[plugins.PluginType][]*plugins.PluginProperties `yaml:"plugins" mapstructure:"plugins"` }
Config contains all configuration of cdn node.
type HostConfig ¶
type KeepAliveConfig ¶
type ManagerConfig ¶
type ManagerConfig struct { // NetAddr is manager address. Addr string `yaml:"addr" mapstructure:"addr"` // CDNClusterID is cdn cluster id. CDNClusterID uint `yaml:"cdnClusterID" mapstructure:"cdnClusterID"` // KeepAlive configuration KeepAlive KeepAliveConfig `yaml:"keepAlive" mapstructure:"keepAlive"` }
type RestConfig ¶ added in v2.0.1
type RestConfig struct {
Addr string `yaml:"addr" mapstructure:"addr"`
}
Click to show internal directories.
Click to hide internal directories.