Documentation ¶
Index ¶
- Constants
- func CreateHTTPClient(CAFile string) (*http.Client, error)
- func ExtractSizeFromLog(logFile string, re *regexp.Regexp) string
- func ExtractSizeFromRsyncLog(logFile string) string
- func FindAllSubmatchInFile(fileName string, re *regexp.Regexp) (matches [][][]byte, err error)
- func GetJSON(url string, obj interface{}, client *http.Client) (*http.Response, error)
- func GetTLSConfig(CAFile string) (*tls.Config, error)
- func InitLogger(verbose, debug, withSystemd bool)
- func PostJSON(url string, obj interface{}, client *http.Client) (*http.Response, error)
- func TranslateRsyncErrorCode(cmdErr error) (exitCode int, msg string)
- type ClientCmd
- type CmdVerb
- type MirrorSchedule
- type MirrorSchedules
- type MirrorStatus
- type SyncStatus
- type WebMirrorStatus
- type WorkerCmd
- type WorkerStatus
Constants ¶
const Version string = "0.9.1"
Version of the program
Variables ¶
This section is empty.
Functions ¶
func CreateHTTPClient ¶
CreateHTTPClient returns a http.Client
func ExtractSizeFromLog ¶ added in v0.5.1
ExtractSizeFromLog uses a regexp to extract the size from log files
func ExtractSizeFromRsyncLog ¶ added in v0.3.4
ExtractSizeFromRsyncLog extracts the size from rsync logs
func FindAllSubmatchInFile ¶ added in v0.5.1
FindAllSubmatchInFile calls re.FindAllSubmatch to find matches in given file
func GetTLSConfig ¶
GetTLSConfig generate tls.Config from CAFile
func InitLogger ¶
func InitLogger(verbose, debug, withSystemd bool)
InitLogger initilizes logging format and level
func TranslateRsyncErrorCode ¶ added in v0.6.0
TranslateRsyncErrorCode translates the exit code of rsync to a message
Types ¶
type ClientCmd ¶
type ClientCmd struct { Cmd CmdVerb `json:"cmd"` MirrorID string `json:"mirror_id"` WorkerID string `json:"worker_id"` Args []string `json:"args"` Options map[string]bool `json:"options"` }
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 NewCmdVerbFromString ¶ added in v0.6.8
func (CmdVerb) MarshalJSON ¶ added in v0.6.8
Marshal and Unmarshal for CmdVerb
func (*CmdVerb) UnmarshalJSON ¶ added in v0.6.8
type MirrorSchedule ¶ added in v0.3.4
type MirrorSchedules ¶ added in v0.3.4
type MirrorSchedules struct {
Schedules []MirrorSchedule `json:"schedules"`
}
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"` LastStarted time.Time `json:"last_started"` LastEnded time.Time `json:"last_ended"` Scheduled time.Time `json:"next_schedule"` Upstream string `json:"upstream"` Size string `json:"size"` ErrorMsg string `json:"error_msg"` }
A MirrorStatus 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 WebMirrorStatus ¶ added in v0.3.2
type WebMirrorStatus struct { Name string `json:"name"` IsMaster bool `json:"is_master"` Status SyncStatus `json:"status"` LastUpdate textTime `json:"last_update"` LastUpdateTs stampTime `json:"last_update_ts"` LastStarted textTime `json:"last_started"` LastStartedTs stampTime `json:"last_started_ts"` LastEnded textTime `json:"last_ended"` LastEndedTs stampTime `json:"last_ended_ts"` Scheduled textTime `json:"next_schedule"` ScheduledTs stampTime `json:"next_schedule_ts"` Upstream string `json:"upstream"` Size string `json:"size"` // approximate size }
WebMirrorStatus is the mirror status to be shown in the web page
func BuildWebMirrorStatus ¶ added in v0.3.2
func BuildWebMirrorStatus(m MirrorStatus) WebMirrorStatus
type WorkerCmd ¶
type WorkerCmd struct { Cmd CmdVerb `json:"cmd"` MirrorID string `json:"mirror_id"` Args []string `json:"args"` Options map[string]bool `json:"options"` }
A WorkerCmd is the command message send from the manager to a worker
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 LastRegister time.Time `json:"last_register"` // last register time }
A WorkerStatus is the information struct that describe a worker, and sent from the manager to clients.