worker

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2016 License: GPL-3.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Global  globalConfig   `toml:"global"`
	Manager managerConfig  `toml:"manager"`
	Server  serverConfig   `toml:"server"`
	Cgroup  cgroupConfig   `toml:"cgroup"`
	ZFS     zfsConfig      `toml:"zfs"`
	Include includeConfig  `toml:"include"`
	Mirrors []mirrorConfig `toml:"mirrors"`
}

Config represents worker config options

func LoadConfig

func LoadConfig(cfgFile string) (*Config, error)

LoadConfig loads configuration

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

func NewContext

func NewContext() *Context

NewContext returns a new context object

func (*Context) Enter

func (ctx *Context) Enter() *Context

Enter generates a new layer of context

func (*Context) Exit

func (ctx *Context) Exit() (*Context, error)

Exit return the upper layer of context

func (*Context) Get

func (ctx *Context) Get(key string) (interface{}, bool)

Get returns the value corresponding to key, if it's not found in the current layer, return the lower layer context's value

func (*Context) Set

func (ctx *Context) Set(key string, value interface{})

Set sets the value to the key at current layer

type Worker

type Worker struct {
	L sync.Mutex
	// contains filtered or unexported fields
}

A Worker is a instance of tunasync worker

func GetTUNASyncWorker

func GetTUNASyncWorker(cfg *Config) *Worker

GetTUNASyncWorker returns a singalton worker

func (*Worker) Halt

func (w *Worker) Halt()

Halt stops all jobs

func (*Worker) Name

func (w *Worker) Name() string

Name returns worker name

func (*Worker) ReloadMirrorConfig

func (w *Worker) ReloadMirrorConfig(newMirrors []mirrorConfig)

ReloadMirrorConfig refresh the providers and jobs from new mirror configs TODO: deleted job should be removed from manager-side mirror list

func (*Worker) Run

func (w *Worker) Run()

Run runs worker forever

func (*Worker) URL

func (w *Worker) URL() string

URL returns the url to http server of the worker

Jump to

Keyboard shortcuts

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