Documentation
¶
Index ¶
- func CreateHTTPClient() (*http.Client, error)
- func ExtractSizeFromFileSystem(path string) uint64
- func ExtractSizeFromLog(logFile string, re *regexp.Regexp) uint64
- func ExtractSizeFromRsyncLog(logFile string) uint64
- func ExtractSizeFromWalk(path string) uint64
- func FindAllSubmatchInFile(fileName string, re *regexp.Regexp) (matches [][][]byte, err error)
- func GetBoolEnv(key string) bool
- func GetIntEnv(key string, def int) int
- func GetListEnv(key string) []string
- func GetStringEnv(key, def string) string
- func InitLogger(verbose, debug bool)
- func TranslateRsyncErrorCode(cmdErr error) (exitCode int, msg string)
- type Config
- type Context
- type MemBytes
- type Worker
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateHTTPClient ¶
CreateHTTPClient returns a http.Client
func ExtractSizeFromFileSystem ¶
ExtractSizeFromFileSystem extracts the size from filesystem
func ExtractSizeFromLog ¶
ExtractSizeFromLog uses a regexp to extract the size from log files
func ExtractSizeFromRsyncLog ¶
ExtractSizeFromRsyncLog extracts the size from rsync logs
func ExtractSizeFromWalk ¶
ExtractSizeFromWalk extracts the size from path
func FindAllSubmatchInFile ¶
FindAllSubmatchInFile calls re.FindAllSubmatch to find matches in given file
func GetBoolEnv ¶
func GetListEnv ¶
func GetStringEnv ¶
func InitLogger ¶
func InitLogger(verbose, debug bool)
InitLogger initilizes logging format and level
func TranslateRsyncErrorCode ¶
TranslateRsyncErrorCode translates the exit code of rsync to a message
Types ¶
type Config ¶
type Config struct {
Name string `toml:"name"`
Provider string `toml:"provider"`
Upstream string `toml:"upstream"`
LogDir string `toml:"log_dir"`
MirrorDir string `toml:"mirror_dir"`
MirrorPath string `toml:"mirror_path"`
Concurrent int `toml:"concurrent"`
Interval int `toml:"interval"`
Retry int `toml:"retry"`
Timeout int `toml:"timeout"`
Command string `toml:"command"`
FailOnMatch string `toml:"fail_on_match"`
SizePattern string `toml:"size_pattern"`
UseIPv6 bool `toml:"use_ipv6"`
UseIPv4 bool `toml:"use_ipv4"`
ExcludeFile string `toml:"exclude_file"`
RsyncNoTimeo bool `toml:"rsync_no_timeout"`
RsyncTimeout int `toml:"rsync_timeout"`
RsyncOptions []string `toml:"rsync_options"`
RsyncOverride []string `toml:"rsync_override"`
Stage1Profile string `toml:"stage1_profile"`
ExecOnSuccess []string `toml:"exec_on_success"`
ExecOnFailure []string `toml:"exec_on_failure"`
APIBase string `toml:"api_base"`
Addr string `toml:"listen_addr"`
ZFSEnable bool `toml:"zfs_enable"`
Zpool string `toml:"zpool"`
BtrfsEnable bool `toml:"btrfs_enable"`
SnapshotPath string `toml:"snapshot_path"`
Verbose bool
Debug bool
}
Config represents worker config options
type Context ¶
type Context struct {
// contains filtered or unexported fields
}
A Context object is a layered key-value storage when enters a context, the changes to the storage would be stored in a new layer and when exits, the top layer poped and the storage returned to the state before entering this context
type MemBytes ¶
type MemBytes int64
func (*MemBytes) UnmarshalText ¶
UnmarshalText is the customized unmarshaler for MemBytes
type Worker ¶
A Worker is an instance of tunasync worker
func NewTUNASyncWorker ¶
NewTUNASyncWorker creates a worker
func (*Worker) HandleRequest ¶
HandleRequest post/head url