data

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2021 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const UserVersion = 1

UserVersion PRAGMA [database.]user_version

Variables

This section is empty.

Functions

func UpperFirst added in v0.4.0

func UpperFirst(str string) string

Types

type ExperimentModel

type ExperimentModel struct {
	Uid        string
	Command    string
	SubCommand string
	Flag       string
	Status     string
	Error      string
	CreateTime string
	UpdateTime string
}

type ExperimentSource

type ExperimentSource interface {
	// CheckAndInitExperimentTable, if experiment table not exists, then init it
	CheckAndInitExperimentTable()

	// ExperimentTableExists return true if experiment exists
	ExperimentTableExists() (bool, error)

	// InitExperimentTable for first executed
	InitExperimentTable() error

	// InsertExperimentModel for creating chaos experiment
	InsertExperimentModel(model *ExperimentModel) error

	// UpdateExperimentModelByUid
	UpdateExperimentModelByUid(uid, status, errMsg string) error

	// QueryExperimentModelByUid
	QueryExperimentModelByUid(uid string) (*ExperimentModel, error)

	// QueryExperimentModels
	QueryExperimentModels(target, action, status, limit string, asc bool) ([]*ExperimentModel, error)

	// QueryExperimentModelsByCommand
	// flags value contains necessary parameters generally
	QueryExperimentModelsByCommand(command, subCommand string, flags map[string]string) ([]*ExperimentModel, error)

	// DeleteExperimentModelByUid
	DeleteExperimentModelByUid(uid string) error
}

type PreparationRecord

type PreparationRecord struct {
	Uid         string
	ProgramType string
	Process     string
	Port        string
	Pid         string
	Status      string
	Error       string
	CreateTime  string
	UpdateTime  string
}

type PreparationSource

type PreparationSource interface {
	// CheckAndInitPreTable
	CheckAndInitPreTable()

	// InitPreparationTable when first executed
	InitPreparationTable() error

	// PreparationTableExists return true if preparation exists, otherwise return false or error if execute sql exception
	PreparationTableExists() (bool, error)

	// InsertPreparationRecord
	InsertPreparationRecord(record *PreparationRecord) error

	// QueryPreparationByUid
	QueryPreparationByUid(uid string) (*PreparationRecord, error)

	// QueryRunningPreByTypeAndProcess
	QueryRunningPreByTypeAndProcess(programType string, processName, processId string) (*PreparationRecord, error)

	// UpdatePreparationRecordByUid
	UpdatePreparationRecordByUid(uid, status, errMsg string) error

	// UpdatePreparationPortByUid
	UpdatePreparationPortByUid(uid, port string) error

	// UpdatePreparationPidByUid
	UpdatePreparationPidByUid(uid, pid string) error

	// QueryPreparationRecords
	QueryPreparationRecords(target, status, limit string, asc bool) ([]*PreparationRecord, error)
}

type Source

type Source struct {
	DB *sql.DB
}

func (*Source) AlterPreparationTable added in v0.3.0

func (s *Source) AlterPreparationTable(alterSql string) error

func (*Source) CheckAndInitExperimentTable

func (s *Source) CheckAndInitExperimentTable()

func (*Source) CheckAndInitPreTable

func (s *Source) CheckAndInitPreTable()

func (*Source) Close

func (s *Source) Close()

func (*Source) DeleteExperimentModelByUid added in v0.6.0

func (s *Source) DeleteExperimentModelByUid(uid string) error

func (*Source) ExperimentTableExists

func (s *Source) ExperimentTableExists() (bool, error)

func (*Source) GetUserVersion added in v0.3.0

func (s *Source) GetUserVersion() (int, error)

GetUserVersion returns the user_version value

func (*Source) InitExperimentTable

func (s *Source) InitExperimentTable() error

func (*Source) InitPreparationTable

func (s *Source) InitPreparationTable() error

func (*Source) InsertExperimentModel

func (s *Source) InsertExperimentModel(model *ExperimentModel) error

func (*Source) InsertPreparationRecord

func (s *Source) InsertPreparationRecord(record *PreparationRecord) error

func (*Source) PreparationTableExists

func (s *Source) PreparationTableExists() (bool, error)

func (*Source) QueryExperimentModelByUid

func (s *Source) QueryExperimentModelByUid(uid string) (*ExperimentModel, error)

func (*Source) QueryExperimentModels added in v0.4.0

func (s *Source) QueryExperimentModels(target, action, status, limit string, asc bool) ([]*ExperimentModel, error)

func (*Source) QueryExperimentModelsByCommand

func (s *Source) QueryExperimentModelsByCommand(command, subCommand string, flags map[string]string) ([]*ExperimentModel, error)

func (*Source) QueryPreparationByUid

func (s *Source) QueryPreparationByUid(uid string) (*PreparationRecord, error)

func (*Source) QueryPreparationRecords added in v0.4.0

func (s *Source) QueryPreparationRecords(target, status, limit string, asc bool) ([]*PreparationRecord, error)

func (*Source) QueryRunningPreByTypeAndProcess

func (s *Source) QueryRunningPreByTypeAndProcess(programType string, processName, processId string) (*PreparationRecord, error)

QueryRunningPreByTypeAndProcess returns the first record matching the process id or process name

func (*Source) UpdateExperimentModelByUid

func (s *Source) UpdateExperimentModelByUid(uid, status, errMsg string) error

func (*Source) UpdatePreparationPidByUid added in v0.3.0

func (s *Source) UpdatePreparationPidByUid(uid, pid string) error

func (*Source) UpdatePreparationPortByUid added in v0.3.0

func (s *Source) UpdatePreparationPortByUid(uid, port string) error

func (*Source) UpdatePreparationRecordByUid

func (s *Source) UpdatePreparationRecordByUid(uid, status, errMsg string) error

func (*Source) UpdateUserVersion added in v0.3.0

func (s *Source) UpdateUserVersion(version int) error

UpdateUserVersion to the latest

type SourceI

type SourceI interface {
	ExperimentSource
	PreparationSource
}

func GetSource

func GetSource() SourceI

Jump to

Keyboard shortcuts

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