db

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2016 License: MIT Imports: 10 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CurrentSchema int = currentSchema()
View Source
var Schemas = map[int]Schema{
	1: v1Schema{},
	2: v2Schema{},
}

Functions

func Pattern added in v0.4.1

func Pattern(glob string) string

Turns globs ('*search*') into SQL patterns ('%search%')

func ValidateEffectiveUnix added in v0.4.1

func ValidateEffectiveUnix(effective time.Time) int64

Types

type AnnotatedArchive

type AnnotatedArchive struct {
	UUID        string    `json:"uuid"`
	StoreKey    string    `json:"key"`
	TakenAt     Timestamp `json:"taken_at"`
	ExpiresAt   Timestamp `json:"expires_at"`
	Notes       string    `json:"notes"`
	Status      string    `json:"status"`
	PurgeReason string    `json:"purge_reason"`

	TargetUUID     string `json:"target_uuid"`
	TargetPlugin   string `json:"target_plugin"`
	TargetEndpoint string `json:"target_endpoint"`
	StoreUUID      string `json:"store_uuid"`
	StorePlugin    string `json:"store_plugin"`
	StoreEndpoint  string `json:"store_endpoint"`
}

type AnnotatedJob

type AnnotatedJob struct {
	UUID           string `json:"uuid"`
	Name           string `json:"name"`
	Summary        string `json:"summary"`
	RetentionName  string `json:"retention_name"`
	RetentionUUID  string `json:"retention_uuid"`
	Expiry         int    `json:"expiry"`
	ScheduleName   string `json:"schedule_name"`
	ScheduleUUID   string `json:"schedule_uuid"`
	ScheduleWhen   string `json:"schedule_when"`
	Paused         bool   `json:"paused"`
	StoreUUID      string `json:"store_uuid"`
	StoreName      string `json:"store_name"`
	StorePlugin    string `json:"store_plugin"`
	StoreEndpoint  string `json:"store_endpoint"`
	TargetUUID     string `json:"target_uuid"`
	TargetName     string `json:"target_name"`
	TargetPlugin   string `json:"target_plugin"`
	TargetEndpoint string `json:"target_endpoint"`
	Agent          string `json:"agent"`
}

type AnnotatedRetentionPolicy

type AnnotatedRetentionPolicy struct {
	UUID    string `json:"uuid"`
	Name    string `json:"name"`
	Summary string `json:"summary"`
	Expires uint   `json:"expires"`
}

type AnnotatedSchedule

type AnnotatedSchedule struct {
	UUID    string `json:"uuid"`
	Name    string `json:"name"`
	Summary string `json:"summary"`
	When    string `json:"when"`
}

type AnnotatedStore

type AnnotatedStore struct {
	UUID     string `json:"uuid"`
	Name     string `json:"name"`
	Summary  string `json:"summary"`
	Plugin   string `json:"plugin"`
	Endpoint string `json:"endpoint"`
}

type AnnotatedTarget

type AnnotatedTarget struct {
	UUID     string `json:"uuid"`
	Name     string `json:"name"`
	Summary  string `json:"summary"`
	Plugin   string `json:"plugin"`
	Endpoint string `json:"endpoint"`
	Agent    string `json:"agent"`
}

type AnnotatedTask

type AnnotatedTask struct {
	UUID        string    `json:"uuid"`
	Owner       string    `json:"owner"`
	Op          string    `json:"type"`
	JobUUID     string    `json:"job_uuid"`
	ArchiveUUID string    `json:"archive_uuid"`
	Status      string    `json:"status"`
	StartedAt   Timestamp `json:"started_at"`
	StoppedAt   Timestamp `json:"stopped_at"`
	Log         string    `json:"log"`
}

type ArchiveFilter

type ArchiveFilter struct {
	ForTarget     string
	ForStore      string
	Before        *time.Time
	After         *time.Time
	ExpiresBefore *time.Time
	WithStatus    []string
	WithOutStatus []string
	Limit         string
}

func (*ArchiveFilter) Args

func (f *ArchiveFilter) Args() []interface{}

func (*ArchiveFilter) Query

func (f *ArchiveFilter) Query() string

type DB

type DB struct {
	Driver string
	DSN    string
	// contains filtered or unexported fields
}

func (*DB) Alias

func (db *DB) Alias(name string, sql string) error

Register a SQL query alias

func (*DB) AnnotateArchive

func (db *DB) AnnotateArchive(id uuid.UUID, notes string) error

func (*DB) AnnotateJob

func (db *DB) AnnotateJob(id uuid.UUID, name string, summary string) error

func (*DB) AnnotateRetentionPolicy

func (db *DB) AnnotateRetentionPolicy(id uuid.UUID, name string, summary string) error

func (*DB) AnnotateSchedule

func (db *DB) AnnotateSchedule(id uuid.UUID, name string, summary string) error

func (*DB) AnnotateStore

func (db *DB) AnnotateStore(id uuid.UUID, name string, summary string) error

func (*DB) AnnotateTarget

func (db *DB) AnnotateTarget(id uuid.UUID, name string, summary string) error

func (*DB) CancelTask

func (db *DB) CancelTask(id uuid.UUID, effective time.Time) error

func (*DB) CheckCurrentSchema

func (db *DB) CheckCurrentSchema() error

func (*DB) CompleteTask

func (db *DB) CompleteTask(id uuid.UUID, effective time.Time) error

func (*DB) Connect

func (db *DB) Connect() error

Connect to the backend database

func (*DB) Connected

func (db *DB) Connected() bool

Are we connected?

func (*DB) Copy

func (db *DB) Copy() *DB

func (*DB) Count

func (db *DB) Count(sql_or_name string, args ...interface{}) (uint, error)

Execute a data query (SELECT) and return how many rows were returned

func (*DB) CreateBackupTask

func (db *DB) CreateBackupTask(owner string, job uuid.UUID) (uuid.UUID, error)

func (*DB) CreateJob

func (db *DB) CreateJob(target, store, schedule, retention string, paused bool) (uuid.UUID, error)

func (*DB) CreatePurgeTask

func (db *DB) CreatePurgeTask(owner string, archive *AnnotatedArchive) (uuid.UUID, error)

func (*DB) CreateRestoreTask

func (db *DB) CreateRestoreTask(owner string, archive, target uuid.UUID) (uuid.UUID, error)

func (*DB) CreateRetentionPolicy

func (db *DB) CreateRetentionPolicy(expiry uint) (uuid.UUID, error)

func (*DB) CreateSchedule

func (db *DB) CreateSchedule(ts string) (uuid.UUID, error)

func (*DB) CreateStore

func (db *DB) CreateStore(plugin string, endpoint interface{}) (uuid.UUID, error)

func (*DB) CreateTarget

func (db *DB) CreateTarget(plugin string, endpoint interface{}, agent string) (uuid.UUID, error)

func (*DB) CreateTaskArchive

func (db *DB) CreateTaskArchive(id uuid.UUID, key string, effective time.Time) (uuid.UUID, error)

func (*DB) DeleteArchive

func (db *DB) DeleteArchive(id uuid.UUID) (bool, error)

func (*DB) DeleteJob

func (db *DB) DeleteJob(id uuid.UUID) (bool, error)

func (*DB) DeleteRetentionPolicy

func (db *DB) DeleteRetentionPolicy(id uuid.UUID) (bool, error)

func (*DB) DeleteSchedule

func (db *DB) DeleteSchedule(id uuid.UUID) (bool, error)

func (*DB) DeleteStore

func (db *DB) DeleteStore(id uuid.UUID) (bool, error)

func (*DB) DeleteTarget

func (db *DB) DeleteTarget(id uuid.UUID) (bool, error)

func (*DB) Disconnect

func (db *DB) Disconnect() error

Disconnect from the backend database

func (*DB) Exec

func (db *DB) Exec(sql_or_name string, args ...interface{}) error

Execute a named, non-data query (INSERT, UPDATE, DELETE, etc.)

func (*DB) ExpireArchive

func (db *DB) ExpireArchive(id uuid.UUID) error

func (*DB) FailTask

func (db *DB) FailTask(id uuid.UUID, effective time.Time) error

func (*DB) GetAllAnnotatedArchives

func (db *DB) GetAllAnnotatedArchives(filter *ArchiveFilter) ([]*AnnotatedArchive, error)

func (*DB) GetAllAnnotatedJobs

func (db *DB) GetAllAnnotatedJobs(filter *JobFilter) ([]*AnnotatedJob, error)

func (*DB) GetAllAnnotatedRetentionPolicies

func (db *DB) GetAllAnnotatedRetentionPolicies(filter *RetentionFilter) ([]*AnnotatedRetentionPolicy, error)

func (*DB) GetAllAnnotatedSchedules

func (db *DB) GetAllAnnotatedSchedules(filter *ScheduleFilter) ([]*AnnotatedSchedule, error)

func (*DB) GetAllAnnotatedStores

func (db *DB) GetAllAnnotatedStores(filter *StoreFilter) ([]*AnnotatedStore, error)

func (*DB) GetAllAnnotatedTargets

func (db *DB) GetAllAnnotatedTargets(filter *TargetFilter) ([]*AnnotatedTarget, error)

func (*DB) GetAllAnnotatedTasks

func (db *DB) GetAllAnnotatedTasks(filter *TaskFilter) ([]*AnnotatedTask, error)

func (*DB) GetAnnotatedArchive

func (db *DB) GetAnnotatedArchive(id uuid.UUID) (*AnnotatedArchive, error)

func (*DB) GetAnnotatedJob

func (db *DB) GetAnnotatedJob(id uuid.UUID) (*AnnotatedJob, error)

func (*DB) GetAnnotatedRetentionPolicy

func (db *DB) GetAnnotatedRetentionPolicy(id uuid.UUID) (*AnnotatedRetentionPolicy, error)

func (*DB) GetAnnotatedSchedule

func (db *DB) GetAnnotatedSchedule(id uuid.UUID) (*AnnotatedSchedule, error)

func (*DB) GetAnnotatedStore

func (db *DB) GetAnnotatedStore(id uuid.UUID) (*AnnotatedStore, error)

func (*DB) GetAnnotatedTarget

func (db *DB) GetAnnotatedTarget(id uuid.UUID) (*AnnotatedTarget, error)

func (*DB) GetAnnotatedTask

func (db *DB) GetAnnotatedTask(id uuid.UUID) (*AnnotatedTask, error)

func (*DB) GetArchivesNeedingPurge

func (db *DB) GetArchivesNeedingPurge() ([]*AnnotatedArchive, error)

func (*DB) GetExpiredArchives

func (db *DB) GetExpiredArchives() ([]*AnnotatedArchive, error)

func (*DB) GetRestoreTaskDetails

func (db *DB) GetRestoreTaskDetails(archive, target uuid.UUID, storePlugin, storeEndpoint, storeKey, targetPlugin, targetEndpoint, agent *string) error

func (*DB) InvalidateArchive

func (db *DB) InvalidateArchive(id uuid.UUID) error

func (*DB) PauseJob

func (db *DB) PauseJob(id uuid.UUID) (bool, error)

func (*DB) PauseOrUnpauseJob

func (db *DB) PauseOrUnpauseJob(id uuid.UUID, pause bool) (bool, error)

func (*DB) PurgeArchive

func (db *DB) PurgeArchive(id uuid.UUID) error

func (*DB) Query

func (db *DB) Query(sql_or_name string, args ...interface{}) (*sql.Rows, error)

Execute a named, data query (SELECT)

func (*DB) SchemaVersion

func (db *DB) SchemaVersion() (int, error)

func (*DB) Setup

func (db *DB) Setup() error

func (*DB) StartTask

func (db *DB) StartTask(id uuid.UUID, effective time.Time) error

func (*DB) UnpauseJob

func (db *DB) UnpauseJob(id uuid.UUID) (bool, error)

func (*DB) UpdateJob

func (db *DB) UpdateJob(id uuid.UUID, target, store, schedule, retention string) error

func (*DB) UpdateRetentionPolicy

func (db *DB) UpdateRetentionPolicy(id uuid.UUID, expiry uint) error

func (*DB) UpdateSchedule

func (db *DB) UpdateSchedule(id uuid.UUID, ts string) error

func (*DB) UpdateStore

func (db *DB) UpdateStore(id uuid.UUID, plugin string, endpoint interface{}) error

func (*DB) UpdateTarget

func (db *DB) UpdateTarget(id uuid.UUID, plugin string, endpoint interface{}, agent string) error

func (*DB) UpdateTaskLog

func (db *DB) UpdateTaskLog(id uuid.UUID, more string) error

type JobFilter

type JobFilter struct {
	SkipPaused   bool
	SkipUnpaused bool

	SearchName string

	ForTarget    string
	ForStore     string
	ForSchedule  string
	ForRetention string
}

func (*JobFilter) Args

func (f *JobFilter) Args() []interface{}

func (*JobFilter) Query

func (f *JobFilter) Query() string

type RetentionFilter

type RetentionFilter struct {
	SkipUsed   bool
	SkipUnused bool

	SearchName string
}

func (*RetentionFilter) Args added in v0.4.1

func (f *RetentionFilter) Args() []interface{}

func (*RetentionFilter) Query

func (f *RetentionFilter) Query() string

type ScheduleFilter

type ScheduleFilter struct {
	SkipUsed   bool
	SkipUnused bool

	SearchName string
}

func (*ScheduleFilter) Args added in v0.4.1

func (f *ScheduleFilter) Args() []interface{}

func (*ScheduleFilter) Query

func (f *ScheduleFilter) Query() string

type Schema

type Schema interface {
	Deploy(*DB) error
}

type StoreFilter

type StoreFilter struct {
	SkipUsed   bool
	SkipUnused bool
	SearchName string
	ForPlugin  string
}

func (*StoreFilter) Args

func (f *StoreFilter) Args() []interface{}

func (*StoreFilter) Query

func (f *StoreFilter) Query() string

type TargetFilter

type TargetFilter struct {
	SkipUsed   bool
	SkipUnused bool
	SearchName string
	ForPlugin  string
}

func (*TargetFilter) Args

func (f *TargetFilter) Args() []interface{}

func (*TargetFilter) Query

func (f *TargetFilter) Query() string

type TaskFilter

type TaskFilter struct {
	UUID         string
	SkipActive   bool
	SkipInactive bool
	ForStatus    string
	Limit        string
}

func (*TaskFilter) Args

func (f *TaskFilter) Args() []interface{}

func (*TaskFilter) Query

func (f *TaskFilter) Query() string

Jump to

Keyboard shortcuts

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