internal

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: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateHTTPClient

func CreateHTTPClient(CAFile string) (*http.Client, error)

CreateHTTPClient returns a http.Client

func GetJSON

func GetJSON(url string, obj interface{}, client *http.Client) (*http.Response, error)

GetJSON gets a json response from url

func GetTLSConfig

func GetTLSConfig(CAFile string) (*tls.Config, error)

GetTLSConfig generate tls.Config from CAFile

func InitLogger

func InitLogger(verbose, debug, withSystemd bool)

InitLogger initilizes logging format and level

func PostJSON

func PostJSON(url string, obj interface{}, client *http.Client) (*http.Response, error)

PostJSON posts json object to url

Types

type ClientCmd

type ClientCmd struct {
	Cmd      CmdVerb  `json:"cmd"`
	MirrorID string   `json:"mirror_id"`
	WorkerID string   `json:"worker_id"`
	Args     []string `json:"args"`
}

A ClientCmd is the command message send from client to the manager

type CmdVerb

type CmdVerb uint8

A CmdVerb is an action to a job or worker

const (
	// CmdStart start a job
	CmdStart CmdVerb = iota
	// CmdStop stop syncing, but keep the job
	CmdStop
	// CmdDisable disable the job (stops goroutine)
	CmdDisable
	// CmdRestart restart a syncing job
	CmdRestart
	// CmdPing ensures the goroutine is alive
	CmdPing

	// CmdReload tells a worker to reload mirror config
	CmdReload
)

func (CmdVerb) String

func (c CmdVerb) String() string

type MirrorStatus

type MirrorStatus struct {
	Name       string     `json:"name"`
	Worker     string     `json:"worker"`
	IsMaster   bool       `json:"is_master"`
	Status     SyncStatus `json:"status"`
	LastUpdate time.Time  `json:"last_update"`
	Upstream   string     `json:"upstream"`
	Size       string     `json:"size"`
	ErrorMsg   string     `json:"error_msg"`
}

A StatusUpdateMsg represents a msg when a worker has done syncing

type SyncStatus

type SyncStatus uint8
const (
	None SyncStatus = iota
	Failed
	Success
	Syncing
	PreSyncing
	Paused
	Disabled
)

func (SyncStatus) MarshalJSON

func (s SyncStatus) MarshalJSON() ([]byte, error)

func (SyncStatus) String

func (s SyncStatus) String() string

func (*SyncStatus) UnmarshalJSON

func (s *SyncStatus) UnmarshalJSON(v []byte) error

type WorkerCmd

type WorkerCmd struct {
	Cmd      CmdVerb  `json:"cmd"`
	MirrorID string   `json:"mirror_id"`
	Args     []string `json:"args"`
}

A WorkerCmd is the command message send from the manager to a worker

func (WorkerCmd) String

func (c WorkerCmd) String() string

type WorkerStatus

type WorkerStatus struct {
	ID         string    `json:"id"`
	URL        string    `json:"url"`         // worker url
	Token      string    `json:"token"`       // session token
	LastOnline time.Time `json:"last_online"` // last seen
}

A WorkerStatus is the information struct that describe a worker, and sent from the manager to clients.

Jump to

Keyboard shortcuts

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