config

package
v2.0.2-rc.19 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2022 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

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"`
	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 CDNConfig added in v2.0.2

type CDNConfig struct {
	// Enable is to enable cdn as P2P peer
	Enable bool `yaml:"enable" mapstructure:"enable"`
}

type Config

type Config struct {
	// Base options
	base.Options `yaml:",inline" mapstructure:",squash"`

	// Scheduler configuration
	Scheduler *SchedulerConfig `yaml:"scheduler" mapstructure:"scheduler"`

	// Server configuration
	Server *ServerConfig `yaml:"server" mapstructure:"server"`

	// Dynconfig configuration
	DynConfig *DynConfig `yaml:"dynConfig" mapstructure:"dynConfig"`

	// Manager configuration
	Manager *ManagerConfig `yaml:"manager" mapstructure:"manager"`

	// CDN configuration
	CDN *CDNConfig `yaml:"cdn" mapstructure:"cdn"`

	// Host configuration
	Host *HostConfig `yaml:"host" mapstructure:"host"`

	// Job configuration
	Job *JobConfig `yaml:"job" mapstructure:"job"`

	// Metrics configuration
	Metrics *MetricsConfig `yaml:"metrics" mapstructure:"metrics"`
}

func New

func New() *Config

New default configuration

func (*Config) Validate

func (c *Config) Validate() error

Validate config parameters

type DynConfig

type DynConfig struct {
	// RefreshInterval is refresh interval for manager cache.
	RefreshInterval time.Duration `yaml:"refreshInterval" mapstructure:"refreshInterval"`

	// CDNDir is cdn dir path.
	CDNDir string `yaml:"cdnDir" mapstructure:"cdnDir"`
}

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() error
}

func NewDynconfig

func NewDynconfig(rawManagerClient managerclient.Client, cacheDir string, cfg *Config) (DynconfigInterface, error)

TODO(Gaius) Rely on manager to delete cdnDirPath

type GCConfig

type GCConfig struct {
	// Peer gc interval
	PeerGCInterval time.Duration `yaml:"peerGCInterval" mapstructure:"peerGCInterval"`

	// Peer time to live
	PeerTTL time.Duration `yaml:"peerTTL" mapstructure:"peerTTL"`

	// Task gc interval
	TaskGCInterval time.Duration `yaml:"taskGCInterval" mapstructure:"taskGCInterval"`

	// Task time to live
	TaskTTL time.Duration `yaml:"taskTTL" mapstructure:"taskTTL"`

	// Host gc interval
	HostGCInterval time.Duration `yaml:"hostGCInterval" mapstructure:"hostGCInterval"`

	// Host time to live
	HostTTL time.Duration `yaml:"hostTTL" mapstructure:"hostTTL"`
}

type HostConfig

type HostConfig struct {
	// IDC for scheduler
	IDC string `mapstructure:"idc" yaml:"idc"`

	// NetTopology for scheduler
	NetTopology string `mapstructure:"netTopology" yaml:"netTopology"`

	// Location for scheduler
	Location string `mapstructure:"location" yaml:"location"`
}

type JobConfig

type JobConfig struct {
	// Enable job service
	Enable bool `yaml:"enable" mapstructure:"enable"`

	// Number of workers in global queue
	GlobalWorkerNum uint `yaml:"globalWorkerNum" mapstructure:"globalWorkerNum"`

	// Number of workers in scheduler queue
	SchedulerWorkerNum uint `yaml:"schedulerWorkerNum" mapstructure:"schedulerWorkerNum"`

	// Number of workers in local queue
	LocalWorkerNum uint `yaml:"localWorkerNum" mapstructure:"localWorkerNum"`

	// Redis configuration
	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 MetricsConfig added in v2.0.1

type MetricsConfig struct {
	// Enable metrics service
	Enable bool `yaml:"enable" mapstructure:"enable"`

	// Metrics service address
	Addr string `yaml:"addr" mapstructure:"addr"`

	// Enable peer host metrics
	EnablePeerHost bool `yaml:"enablePeerHost" mapstructure:"enablePeerHost"`
}

type Observer

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

type RedisConfig

type RedisConfig struct {
	// Server hostname
	Host string `yaml:"host" mapstructure:"host"`

	// Server port
	Port int `yaml:"port" mapstructure:"port"`

	// Server password
	Password string `yaml:"password" mapstructure:"password"`

	// Broker database name
	BrokerDB int `yaml:"brokerDB" mapstructure:"brokerDB"`

	// Backend database name
	BackendDB int `yaml:"backendDB" mapstructure:"backendDB"`
}

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 {
	// Scheduling algorithm used by the scheduler
	Algorithm string `yaml:"algorithm" mapstructure:"algorithm"`

	// Single task allows the client to back-to-source count
	BackSourceCount int `yaml:"backSourceCount" mapstructure:"backSourceCount"`

	// Retry scheduling back-to-source limit times
	RetryBackSourceLimit int `yaml:"retryBackSourceLimit" mapstructure:"retryBackSourceLimit"`

	// Retry scheduling limit times
	RetryLimit int `yaml:"retryLimit" mapstructure:"retryLimit"`

	// Retry scheduling interval
	RetryInterval time.Duration `yaml:"retryInterval" mapstructure:"retryInterval"`

	// Task and peer gc configuration
	GC *GCConfig `yaml:"gc" mapstructure:"gc"`
}

type ServerConfig

type ServerConfig struct {
	// Server ip
	IP string `yaml:"ip" mapstructure:"ip"`

	// Server hostname
	Host string `yaml:"host" mapstructure:"host"`

	// Server port
	Port int `yaml:"port" mapstructure:"port"`

	// Server dynamic config cache directory
	CacheDir string `yaml:"cacheDir" mapstructure:"cacheDir"`

	// Server log directory
	LogDir string `yaml:"logDir" mapstructure:"logDir"`
}

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