config

package
v2.0.1-alpha.7 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	AttributePeerRegisterRequest = attribute.Key("d7y.peer.register.request")
	AttributeTaskSizeScope       = attribute.Key("d7y.task.size.scope")
	AttributeSinglePiece         = attribute.Key("d7y.peer.single.piece")
	AttributePieceReceived       = attribute.Key("d7y.peer.piece.received")
	AttributeLeavePeerID         = attribute.Key("d7y.leave.peer.id")
	AttributeLeaveTaskID         = attribute.Key("d7y.leave.task.id")
	AttributeReportPeerID        = attribute.Key("d7y.report.peer.id")
	AttributePeerDownloadSuccess = attribute.Key("d7y.peer.download.success")
	AttributeDownloadFileURL     = attribute.Key("d7y.file.url")
	AttributeContentLength       = attribute.Key("d7y.source.content.length")
	AttributePeerDownloadResult  = attribute.Key("d7y.peer.download.result")
	AttributeSchedulePacket      = attribute.Key("d7y.schedule.packet")
	AttributeTaskID              = attribute.Key("d7y.peer.task.id")
	AttributePeerID              = attribute.Key("d7y.peer.id")
	AttributeCDNSeedRequest      = attribute.Key("d7y.cdn.seed.request")
	AttributeNeedSeedCDN         = attribute.Key("d7y.need.seed.cdn")
	AttributeTaskStatus          = attribute.Key("d7y.task.status")
	AttributeLastTriggerTime     = attribute.Key("d7y.task.last.trigger.time")
	AttributeClientBackSource    = attribute.Key("d7y.need.client.back-source")
	AttributeTriggerCDNError     = attribute.Key("d7y.trigger.cdn.error")
)
View Source
const (
	SpanPeerRegister      = "peer-register"
	SpanTriggerCDNSeed    = "trigger-cdn-seed"
	SpanReportPieceResult = "report-piece-result"
	SpanReportPeerResult  = "report-peer-result"
	SpanPeerLeave         = "peer-leave"
	SpanPreheat           = "preheat"
)
View Source
const (
	EventSmallTaskSelectParentFail = "small-task-select-parent-fail"
	EventPeerNotFound              = "peer-not-found"
	EventHostNotFound              = "host-not-found"
	EventCreateCDNPeer             = "create-cdn-peer"
	EventCDNPieceReceived          = "receive-cdn-piece"
	EventPeerDownloaded            = "downloaded"
	EventDownloadTinyFile          = "download-tiny-file"
	EventCDNFailBackClientSource   = "cdn-fail-back-client-source"
)

Variables

View Source
var (
	DefaultDynconfigCachePath = filepath.Join(dfpath.DefaultCacheDir, "scheduler_dynconfig")
)

Functions

func NewManagerClient

func NewManagerClient(client managerclient.Client, schedulerClusterID uint) dc.ManagerClient

Types

type CDN

type CDN struct {
	ID            uint        `yaml:"id" mapstructure:"id" json:"id"`
	HostName      string      `yaml:"hostname" mapstructure:"hostname" json:"host_name"`
	IP            string      `yaml:"ip" mapstructure:"ip" json:"ip"`
	Port          int32       `yaml:"port" mapstructure:"port" json:"port"`
	DownloadPort  int32       `yaml:"downloadPort" mapstructure:"downloadPort" json:"download_port"`
	SecurityGroup string      `yaml:"securityGroup" mapstructure:"securityGroup" json:"security_group"`
	Location      string      `yaml:"location" mapstructure:"location" json:"location"`
	IDC           string      `yaml:"idc" mapstructure:"idc" json:"idc"`
	CDNCluster    *CDNCluster `yaml:"cdnCluster" mapstructure:"cdnCluster" json:"cdn_cluster"`
}

func (*CDN) GetCDNClusterConfig added in v2.0.1

func (c *CDN) GetCDNClusterConfig() (types.CDNClusterConfig, bool)

type CDNCluster added in v2.0.1

type CDNCluster struct {
	Config []byte `yaml:"config" mapstructure:"config" json:"config"`
}

type Config

type Config struct {
	base.Options `yaml:",inline" mapstructure:",squash"`
	Scheduler    *SchedulerConfig `yaml:"scheduler" mapstructure:"scheduler"`
	Server       *ServerConfig    `yaml:"server" mapstructure:"server"`
	DynConfig    *DynConfig       `yaml:"dynConfig" mapstructure:"dynConfig"`
	Manager      *ManagerConfig   `yaml:"manager" mapstructure:"manager"`
	Host         *HostConfig      `yaml:"host" mapstructure:"host"`
	Job          *JobConfig       `yaml:"job" mapstructure:"job"`
	Metrics      *RestConfig      `yaml:"metrics" mapstructure:"metrics"`
	DisableCDN   bool             `yaml:"disableCDN" mapstructure:"disableCDN"`
}

func New

func New() *Config

func (*Config) Convert

func (c *Config) Convert() error

func (*Config) Validate

func (c *Config) Validate() error

type DynConfig

type DynConfig struct {
	// Type is dynconfig source type.
	Type dc.SourceType `yaml:"type" mapstructure:"type"`

	// ExpireTime is expire time for manager cache.
	ExpireTime time.Duration `yaml:"expireTime" mapstructure:"expireTime"`

	// CDNDirPath is cdn dir.
	CDNDirPath string `yaml:"cdnDirPath" mapstructure:"cdnDirPath"`

	// Data is dynconfig local data.
	Data *DynconfigData `yaml:"data" mapstructure:"data"`
}

type DynconfigData

type DynconfigData struct {
	CDNs             []*CDN            `yaml:"cdns" mapstructure:"cdns" json:"cdns"`
	SchedulerCluster *SchedulerCluster `yaml:"schedulerCluster" mapstructure:"schedulerCluster" json:"scheduler_cluster"`
}

type DynconfigInterface

type DynconfigInterface interface {
	// Get the scheduler cluster config.
	GetSchedulerClusterConfig() (types.SchedulerClusterConfig, bool)

	// Get the client config.
	GetSchedulerClusterClientConfig() (types.SchedulerClusterClientConfig, bool)

	// Get the cdn cluster config.
	GetCDNClusterConfig(uint) (types.CDNClusterConfig, bool)

	// Get the dynamic config from manager.
	Get() (*DynconfigData, error)

	// Register allows an instance to register itself to listen/observe events.
	Register(Observer)

	// Deregister allows an instance to remove itself from the collection of observers/listeners.
	Deregister(Observer)

	// Notify publishes new events to listeners.
	Notify() error

	// Serve the dynconfig listening service.
	Serve() error

	// Stop the dynconfig listening service.
	Stop()
}

func NewDynconfig

func NewDynconfig(sourceType dc.SourceType, cdnDirPath string, options ...dc.Option) (DynconfigInterface, error)

TODO(Gaius) Rely on manager to delete cdnDirPath

type GCConfig

type GCConfig struct {
	PeerGCInterval time.Duration `yaml:"peerGCInterval" mapstructure:"peerGCInterval"`
	// PeerTTL is advised to set the time to be smaller than the expire time of a task in the CDN
	PeerTTL        time.Duration `yaml:"peerTTL" mapstructure:"peerTTL"`
	PeerTTI        time.Duration `yaml:"peerTTI" mapstructure:"peerTTI"`
	TaskGCInterval time.Duration `yaml:"taskGCInterval" mapstructure:"taskGCInterval"`
	TaskTTL        time.Duration `yaml:"taskTTL" mapstructure:"taskTTL"`
	TaskTTI        time.Duration `yaml:"taskTTI" mapstructure:"taskTTI"`
}

type HostConfig

type HostConfig struct {
	// Location for scheduler
	Location string `mapstructure:"location" yaml:"location"`

	// IDC for scheduler
	IDC string `mapstructure:"idc" yaml:"idc"`
}

type JobConfig

type JobConfig struct {
	GlobalWorkerNum    uint         `yaml:"globalWorkerNum" mapstructure:"globalWorkerNum"`
	SchedulerWorkerNum uint         `yaml:"schedulerWorkerNum" mapstructure:"schedulerWorkerNum"`
	LocalWorkerNum     uint         `yaml:"localWorkerNum" mapstructure:"localWorkerNum"`
	Redis              *RedisConfig `yaml:"redis" mapstructure:"redis"`
}

type KeepAliveConfig

type KeepAliveConfig struct {
	// Keep alive interval
	Interval time.Duration `yaml:"interval" mapstructure:"interval"`
}

type ManagerConfig

type ManagerConfig struct {
	// Addr is manager address.
	Addr string `yaml:"addr" mapstructure:"addr"`

	// SchedulerClusterID is scheduler cluster id.
	SchedulerClusterID uint `yaml:"schedulerClusterID" mapstructure:"schedulerClusterID"`

	// KeepAlive configuration
	KeepAlive KeepAliveConfig `yaml:"keepAlive" mapstructure:"keepAlive"`
}

type Observer

type Observer interface {
	// OnNotify allows an event to be "published" to interface implementations.
	OnNotify(*DynconfigData)
}

type RedisConfig

type RedisConfig struct {
	Host      string `yaml:"host" mapstructure:"host"`
	Port      int    `yaml:"port" mapstructure:"port"`
	Password  string `yaml:"password" mapstructure:"password"`
	BrokerDB  int    `yaml:"brokerDB" mapstructure:"brokerDB"`
	BackendDB int    `yaml:"backendDB" mapstructure:"backendDB"`
}

type RestConfig

type RestConfig struct {
	Addr string `yaml:"addr" mapstructure:"addr"`
}

type SchedulerCluster added in v2.0.1

type SchedulerCluster struct {
	Config       []byte `yaml:"config" mapstructure:"config" json:"config"`
	ClientConfig []byte `yaml:"clientConfig" mapstructure:"clientConfig" json:"client_config"`
}

type SchedulerConfig

type SchedulerConfig struct {
	ABTest          bool   `yaml:"abtest" mapstructure:"abtest"`
	AEvaluator      string `yaml:"aevaluator" mapstructure:"aevaluator"`
	BEvaluator      string `yaml:"bevaluator" mapstructure:"bevaluator"`
	WorkerNum       int    `yaml:"workerNum" mapstructure:"workerNum"`
	BackSourceCount int32  `yaml:"backSourceCount" mapstructure:"backSourceCount"`
	// AccessWindow should less than CDN task expireTime
	AccessWindow         time.Duration `yaml:"accessWindow" mapstructure:"accessWindow"`
	CandidateParentCount int           `yaml:"candidateParentCount" mapstructure:"candidateParentCount"`
	Scheduler            string        `yaml:"scheduler" mapstructure:"scheduler"`
	CDNLoad              int           `yaml:"cdnLoad" mapstructure:"cdnLoad"`
	ClientLoad           int32         `yaml:"clientLoad" mapstructure:"clientLoad"`
	OpenMonitor          bool          `yaml:"openMonitor" mapstructure:"openMonitor"`
	GC                   *GCConfig     `yaml:"gc" mapstructure:"gc"`
}

type ServerConfig

type ServerConfig struct {
	IP   string `yaml:"ip" mapstructure:"ip"`
	Host string `yaml:"host" mapstructure:"host"`
	Port int    `yaml:"port" mapstructure:"port"`
}

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