supervisor

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2016 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DEV_MODE_SCHEDULING bool = false

Functions

func JSON

func JSON(w http.ResponseWriter, thing interface{})

func JSONLiteral

func JSONLiteral(w http.ResponseWriter, thing string)

func Sentencify

func Sentencify(words []string) string

Types

type AdhocTask

type AdhocTask struct {
	Op    Operation
	Owner string

	TargetUUID  uuid.UUID
	ArchiveUUID uuid.UUID
	RestoreKey  string

	JobUUID uuid.UUID
}

type ArchiveAPI

type ArchiveAPI struct {
	Data       *db.DB
	ResyncChan chan int
	AdhocChan  chan AdhocTask
}

func (ArchiveAPI) ServeHTTP

func (self ArchiveAPI) ServeHTTP(w http.ResponseWriter, req *http.Request)

type Config

type Config struct {
	DatabaseType string `yaml:"database_type"`
	DatabaseDSN  string `yaml:"database_dsn"`

	Port string `yaml:"port"`

	PrivateKeyFile string `yaml:"private_key"`

	Workers uint `yaml:"workers"`

	PurgeAgent string `yaml:"purge_agent"`

	MaxTimeout uint `yaml:"max_timeout"`
}

type InvalidParametersError

type InvalidParametersError struct {
	Errors map[string]string
}

func InvalidParameters

func InvalidParameters(names ...string) InvalidParametersError

func (InvalidParametersError) Error

func (e InvalidParametersError) Error() string

func (*InvalidParametersError) IsValid

func (e *InvalidParametersError) IsValid() bool

func (InvalidParametersError) JSON

func (e InvalidParametersError) JSON() string

func (*InvalidParametersError) Validate

func (e *InvalidParametersError) Validate(name string, value interface{}, fn Validator)

type JSONError

type JSONError interface {
	JSON() string
}

type Job

type Job struct {
	UUID uuid.UUID

	StorePlugin    string
	StoreEndpoint  string
	TargetPlugin   string
	TargetEndpoint string
	Agent          string

	Spec   *timespec.Spec
	Paused bool

	NextRun time.Time
}

func (*Job) Reschedule

func (j *Job) Reschedule() error

func (*Job) Runnable

func (j *Job) Runnable() bool

func (*Job) Task

func (j *Job) Task() *Task

type JobAPI

type JobAPI struct {
	Data       *db.DB
	ResyncChan chan int
	AdhocChan  chan AdhocTask
}

func (JobAPI) ServeHTTP

func (self JobAPI) ServeHTTP(w http.ResponseWriter, req *http.Request)

type JobFailedError

type JobFailedError struct {
	FailedJobs []JobRepresentation
}

func (JobFailedError) Error

func (e JobFailedError) Error() string

type JobRepresentation

type JobRepresentation struct {
	UUID  uuid.UUID
	Tspec string
	Error error
}

type MetaAPI

type MetaAPI struct {
	PrivateKeyFile string
}

func (MetaAPI) ServeHTTP

func (self MetaAPI) ServeHTTP(w http.ResponseWriter, req *http.Request)

type MissingParametersError

type MissingParametersError struct {
	Missing []string `json:"missing"`
}

func MissingParameters

func MissingParameters(names ...string) MissingParametersError

func (*MissingParametersError) Check

func (e *MissingParametersError) Check(name string, value string)

func (MissingParametersError) Error

func (e MissingParametersError) Error() string

func (MissingParametersError) IsValid

func (e MissingParametersError) IsValid() bool

func (MissingParametersError) JSON

func (e MissingParametersError) JSON() string

type Operation

type Operation int
const (
	BACKUP Operation = iota
	RESTORE
	PURGE
)

func (Operation) String

func (o Operation) String() string

type PingAPI

type PingAPI struct{}

func (PingAPI) ServeHTTP

func (p PingAPI) ServeHTTP(w http.ResponseWriter, req *http.Request)

type RetentionAPI

type RetentionAPI struct {
	Data       *db.DB
	ResyncChan chan int
}

func (RetentionAPI) ServeHTTP

func (self RetentionAPI) ServeHTTP(w http.ResponseWriter, req *http.Request)

type ScheduleAPI

type ScheduleAPI struct {
	Data       *db.DB
	ResyncChan chan int
}

func (ScheduleAPI) ServeHTTP

func (self ScheduleAPI) ServeHTTP(w http.ResponseWriter, req *http.Request)

type Status

type Status int
const (
	PENDING Status = iota
	RUNNING
	CANCELED
	DONE
)

type StoreAPI

type StoreAPI struct {
	Data       *db.DB
	ResyncChan chan int
}

func (StoreAPI) ServeHTTP

func (self StoreAPI) ServeHTTP(w http.ResponseWriter, req *http.Request)

type Supervisor

type Supervisor struct {
	Database *db.DB

	Port           string /* addr/interface(s) and port to bind */
	PrivateKeyFile string /* path to the SSH private key for talking to remote agents */
	Workers        uint   /* how many workers to spin up */
	PurgeAgent     string /* What agent to use for purge jobs */

	Timeout time.Duration
	// contains filtered or unexported fields
}

func NewSupervisor

func NewSupervisor() *Supervisor

func (*Supervisor) CheckSchedule

func (s *Supervisor) CheckSchedule()

func (*Supervisor) GetAllJobs

func (s *Supervisor) GetAllJobs() ([]*Job, error)

func (*Supervisor) PurgeArchives

func (s *Supervisor) PurgeArchives()

func (*Supervisor) ReadConfig

func (s *Supervisor) ReadConfig(path string) error

func (*Supervisor) Resync

func (s *Supervisor) Resync() error

func (*Supervisor) Run

func (s *Supervisor) Run() error

func (*Supervisor) ScheduleAdhoc

func (s *Supervisor) ScheduleAdhoc(a AdhocTask)

func (*Supervisor) SchedulePurgeTask

func (s *Supervisor) SchedulePurgeTask(archive *db.AnnotatedArchive) error

func (*Supervisor) SpawnAPI

func (s *Supervisor) SpawnAPI()

func (*Supervisor) SpawnScheduler

func (s *Supervisor) SpawnScheduler()

func (*Supervisor) SpawnWorker

func (s *Supervisor) SpawnWorker()

func (*Supervisor) SpawnWorkers

func (s *Supervisor) SpawnWorkers()

type TargetAPI

type TargetAPI struct {
	Data       *db.DB
	ResyncChan chan int
}

func (TargetAPI) ServeHTTP

func (self TargetAPI) ServeHTTP(w http.ResponseWriter, req *http.Request)

type Task

type Task struct {
	UUID uuid.UUID

	StorePlugin    string
	StoreEndpoint  string
	ArchiveUUID    uuid.UUID
	TargetPlugin   string
	TargetEndpoint string
	RestoreKey     string
	Agent          string

	Op       Operation
	Status   Status
	Attempts int

	StartedAt time.Time
	StoppedAt time.Time
	TimeoutAt time.Time

	Output []string
}

func NewPendingTask

func NewPendingTask(Op Operation) *Task

type TaskAPI

type TaskAPI struct {
	Data *db.DB
}

func (TaskAPI) ServeHTTP

func (self TaskAPI) ServeHTTP(w http.ResponseWriter, req *http.Request)

type UpdateOp

type UpdateOp int
const (
	STOPPED UpdateOp = iota
	FAILED
	OUTPUT
	RESTORE_KEY
	PURGE_ARCHIVE
)

type Validator

type Validator func(name string, value interface{}) error

type WorkerRequest

type WorkerRequest struct {
	Operation      string `json:"operation"`
	TargetPlugin   string `json:"target_plugin"`
	TargetEndpoint string `json:"target_endpoint"`
	StorePlugin    string `json:"store_plugin"`
	StoreEndpoint  string `json:"store_endpoint"`
	RestoreKey     string `json:"restore_key"`
}

type WorkerUpdate

type WorkerUpdate struct {
	Task        uuid.UUID
	Archive     uuid.UUID
	TaskSuccess bool
	Op          UpdateOp
	StoppedAt   time.Time
	Output      string
}

Jump to

Keyboard shortcuts

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