worker

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2021 License: GPL-3.0 Imports: 33 Imported by: 1

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"`
	BtrfsSnapshot btrfsSnapshotConfig `toml:"btrfs_snapshot"`
	Docker        dockerConfig        `toml:"docker"`
	Include       includeConfig       `toml:"include"`
	MirrorsConf   []mirrorConfig      `toml:"mirrors"`
	Mirrors       []mirrorConfig
}

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 MemBytes added in v0.8.0

type MemBytes int64

func (*MemBytes) Set added in v0.8.0

func (m *MemBytes) Set(value string) error

Set sets the value of the MemBytes by passing a string

func (*MemBytes) Type added in v0.8.0

func (m *MemBytes) Type() string

Type returns the type

func (*MemBytes) UnmarshalText added in v0.8.0

func (m *MemBytes) UnmarshalText(s []byte) error

UnmarshalJSON is the customized unmarshaler for MemBytes

func (*MemBytes) Value added in v0.8.0

func (m *MemBytes) Value() int64

Value returns the value in int64

type Worker

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

A Worker is a instance of tunasync worker

func NewTUNASyncWorker added in v0.3.4

func NewTUNASyncWorker(cfg *Config) *Worker

NewTUNASyncWorker creates a 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