config

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2018 License: Apache-2.0 Imports: 16 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package config holds all Properties of dfget.

Index

Constants

View Source
const (
	// HTTPSuccess represents the http request is success.
	HTTPSuccess   = 200
	ResultFail    = 500
	ResultSuc     = 501
	ResultInvalid = 502
	// ResultSemiSuc represents the result is partial successful.
	ResultSemiSuc = 503
)

the response code from supernode

View Source
const (
	TaskStatusStart   = 700
	TaskStatusRunning = 701
	TaskStatusFinish  = 702
)

report status of task to supernode

View Source
const (
	TaskCodeFinish   = 600
	TaskCodeContinue = 601
	TaskCodeWait     = 602
	TaskCodeLimited  = 603
	TaskCodeNeedAuth = 608
	TaskCodeWaitAuth = 609
)

the task code get from supernode

View Source
const (
	BackSourceReasonNone          = 0
	BackSourceReasonRegisterFail  = 1
	BackSourceReasonMd5NotMatch   = 2
	BackSourceReasonDownloadError = 3
	BackSourceReasonNoSpace       = 4
	BackSourceReasonInitError     = 5
	BackSourceReasonWriteError    = 6
	BackSourceReasonHostSysError  = 7
	ForceNotBackSourceAddition    = 1000
)

the reason of backing to source

View Source
const (
	DefaultYamlConfigFile  = "/etc/dragonfly.yaml"
	DefaultIniConfigFile   = "/etc/dragonfly.conf"
	DefaultNode            = "127.0.0.1"
	DefaultLocalLimit      = 20 * 1024 * 1024
	DefaultClientQueueSize = 6
)

properties

View Source
const (
	DefaultTimestampFormat = "2006-01-02 15:04:05"
	SchemaHTTP             = "http"

	ServerPortLowerLimit = 15000
	ServerPortUpperLimit = 65000

	RangeNotExistDesc = "range not satisfiable"
	AddrUsedDesc      = "address already in use"

	PeerHTTPPathPrefix = "/peer/file/"
	CDNPathPrefix      = "/qtdown/"

	LocalHTTPPathCheck  = "/check/"
	LocalHTTPPathClient = "/client/"
	LocalHTTPPathRate   = "/rate/"
)

others

Variables

View Source
var (
	// Props is loaded from config file.
	Props *Properties

	// Ctx holds all the runtime Context information.
	Ctx *Context
)

Functions

func AssertContext

func AssertContext(ctx *Context)

AssertContext checks the ctx and panic if any error happens.

func Reset

func Reset()

Reset configuration and Context.

Types

type Context

type Context struct {
	URL             string   `json:"url"`
	Output          string   `json:"output"`
	LocalLimit      int      `json:"localLimit,omitempty"`
	TotalLimit      int      `json:"totalLimit,omitempty"`
	Timeout         int      `json:"timeout,omitempty"`
	Md5             string   `json:"md5,omitempty"`
	Identifier      string   `json:"identifier,omitempty"`
	CallSystem      string   `json:"callSystem,omitempty"`
	Pattern         string   `json:"pattern,omitempty"`
	Filter          []string `json:"filter,omitempty"`
	Header          []string `json:"header,omitempty"`
	Node            []string `json:"node,omitempty"`
	Notbs           bool     `json:"notbs,omitempty"`
	DFDaemon        bool     `json:"dfdaemon,omitempty"`
	Version         bool     `json:"version,omitempty"`
	ShowBar         bool     `json:"showBar,omitempty"`
	Console         bool     `json:"console,omitempty"`
	Verbose         bool     `json:"verbose,omitempty"`
	Help            bool     `json:"help,omitempty"`
	ClientQueueSize int      `json:"clientQueueSize,omitempty"`

	StartTime   time.Time `json:"startTime"`
	Sign        string    `json:"sign"`
	User        string    `json:"user"`
	WorkHome    string    `json:"workHome"`
	ConfigFiles []string  `json:"configFile"`

	ClientLogger *logrus.Logger `json:"-"`
	ServerLogger *logrus.Logger `json:"-"`
}

Context holds all the runtime context information.

func NewContext

func NewContext() *Context

NewContext creates and initialize a Context.

func (*Context) String

func (ctx *Context) String() string

type Properties

type Properties struct {
	Nodes           []string `yaml:"nodes"`
	LocalLimit      int      `yaml:"localLimit"`
	TotalLimit      int      `yaml:"totalLimit"`
	ClientQueueSize int      `yaml:"clientQueueSize"`
}

Properties holds all configurable Properties. Support INI(or conf) and YAML(since 0.2.0). Before 0.2.0, only support INI config and only have one property(node):

[node]
address=127.0.0.1,10.10.10.1

Since 0.2.0, the INI config is just to be compatible with previous versions. The YAML config will have more properties:

nodes:
    - 127.0.0.1
    - 10.10.10.1
localLimit: 20971520
totalLimit: 20971520
clientQueueSize: 6

func NewProperties

func NewProperties() *Properties

NewProperties create a new properties with default values.

func (*Properties) Load

func (p *Properties) Load(path string) error

Load loads properties from config file.

func (*Properties) String

func (p *Properties) String() string

Jump to

Keyboard shortcuts

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