task

package
v0.0.0-...-182d01c Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2016 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

example of calling one of these

request := &backup.Reload{"something", "yes"} response, err := backup.ReloadClient("http://cpm-task:13001", request)

Package task is the implementation of the CPM Task REST API. There are serveral types of 'admin' functions or 'tasks' that a DBA could perform on a running CPM database container. Currently a pg_basebackup and a pg_backrest restore are implemented as 'tasks'.

Index

Constants

View Source
const CLUSTERADMIN_DB = "clusteradmin"
View Source
const URL = "http://cpm-task:13001"

Variables

View Source
var CRONInstance *cron.Cron

global cron instance that gets started, stopped, restarted

Functions

func AddSchedule

func AddSchedule(dbConn *sql.DB, s TaskSchedule) (string, error)

AddSchedule writes a new schedule to the database

func AddStatus

func AddStatus(dbConn *sql.DB, status *TaskStatus) (string, error)

AddStatus writes new status info to the database

func DeleteSchedule

func DeleteSchedule(dbConn *sql.DB, id string) error

DeleteSchedule deletes a schedule from the database

func DeleteStatus

func DeleteStatus(dbConn *sql.DB, id string) error

DeleteStatus deletes a task status from the database

func ExecuteNow

func ExecuteNow(w rest.ResponseWriter, r *rest.Request)

ExecuteNow called by admin do perform an adhoc task

func LoadSchedules

func LoadSchedules() error

LoadSchedules loads the initial set of task schedules

func ProvisionBackrestRestoreJob

func ProvisionBackrestRestoreJob(dbConn *sql.DB, args *TaskRequest) error

ProvisionRestoreJob creates a docker container to orchestrate a pg_backrest restore job

func ProvisionBackupJob

func ProvisionBackupJob(dbConn *sql.DB, args *TaskRequest) error

ProvisionBackupJob creates a Docker container that performs the backup on a db

func ProvisionRestoreJob

func ProvisionRestoreJob(dbConn *sql.DB, args *TaskRequest) error

ProvisionRestoreJob creates a docker container to orchestrate a restore job

func Reload

func Reload(w rest.ResponseWriter, r *rest.Request)

Reload called by admin to cause a reload of the cron jobs

func StatusAdd

func StatusAdd(w rest.ResponseWriter, r *rest.Request)

StatusAdd called by backup jobs as they execute to write new status info

func StatusUpdate

func StatusUpdate(w rest.ResponseWriter, r *rest.Request)

StatusUpdate called by backup jobs as they execute

func UpdateSchedule

func UpdateSchedule(dbConn *sql.DB, s TaskSchedule) error

UpdateSchedule updates a schedule in the database

func UpdateStatus

func UpdateStatus(dbConn *sql.DB, status *TaskStatus) error

UpdateStatus updates status info in the database for a job

Types

type DefaultJob

type DefaultJob struct {
	// contains filtered or unexported fields
}

func (DefaultJob) Run

func (t DefaultJob) Run()

Run this is the func that implements the cron Job interface

type ExecuteNowResponse

type ExecuteNowResponse struct {
	Output string
}

func ExecuteNowClient

func ExecuteNowClient(req *TaskRequest) (ExecuteNowResponse, error)

ExecuteNowClient client for the execute now function which runs a task immediately

type ReloadRequest

type ReloadRequest struct {
	Name string
}

type ReloadResponse

type ReloadResponse struct {
	Output string
}

func ReloadClient

func ReloadClient() (ReloadResponse, error)

ReloadClient is the client to the reload function which causes the scheduled tasks to be reread from the database

type StatusAddResponse

type StatusAddResponse struct {
	ID string
}

func StatusAddClient

func StatusAddClient(req *TaskStatus) (StatusAddResponse, error)

StatusAddClient is the client to the StatusAdd function which allows for the addition of new status info

type StatusUpdateResponse

type StatusUpdateResponse struct {
	Output string
}

func StatusUpdateClient

func StatusUpdateClient(req *TaskStatus) (StatusUpdateResponse, error)

StatusUpdateClient is the client to the StatusUpdate function

type TaskProfile

type TaskProfile struct {
	ID   string
	Name string
}

type TaskRequest

type TaskRequest struct {
	ScheduleID    string
	StatusID      string
	DockerProfile string
	ProfileName   string
	ContainerName string
}

type TaskSchedule

type TaskSchedule struct {
	ID                string
	ContainerName     string
	ProfileName       string
	Name              string
	Enabled           string
	Minutes           string
	Hours             string
	DayOfMonth        string
	Month             string
	DayOfWeek         string
	UpdateDt          string
	RestoreSet        string
	RestoreRemotePath string
	RestoreRemoteHost string
	RestoreRemoteUser string
	RestoreDbUser     string
	RestoreDbPass     string
	Serverip          string
}

func GetAllSchedules

func GetAllSchedules(dbConn *sql.DB, containerid string) ([]TaskSchedule, error)

GetAllSchedules returns a list of all schedules for a given container

func GetSchedule

func GetSchedule(dbConn *sql.DB, id string) (TaskSchedule, error)

GetSchedule returns a schedule from the database by id

func GetSchedules

func GetSchedules(dbConn *sql.DB) ([]TaskSchedule, error)

GetSchedules returns a list of all task schedules

type TaskStatus

type TaskStatus struct {
	Token         string
	ID            string
	ContainerName string
	StartTime     string
	TaskName      string
	ProfileName   string
	ScheduleID    string
	Path          string
	ElapsedTime   string
	TaskSize      string
	Status        string
	UpdateDt      string
}

func GetAllStatus

func GetAllStatus(dbConn *sql.DB, scheduleid string) ([]TaskStatus, error)

GetAllStatus returns a list of task status for given schedule

func GetStatus

func GetStatus(dbConn *sql.DB, id string) (TaskStatus, error)

GetStatus returns task status for a given task

Jump to

Keyboard shortcuts

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