Help us shape the future of Go! Take the 2026 Go Developer Survey

store

package
v1.1.16 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2024 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Db is the main databse connection
	Db   *gorm.DB
	Dbx  *sqlx.DB
	Conn database.Connection

	// DropAll signifies to drop all tables and recreate them
	DropAll = false
)

Functions

func InitDB

func InitDB()

InitDB initializes the database

func StoreInsert

func StoreInsert(t *sling.TaskExecution)

Store saves the task into the local sqlite

func StoreUpdate

func StoreUpdate(t *sling.TaskExecution)

Store saves the task into the local sqlite

func ToConfigObject

func ToConfigObject(t *sling.TaskExecution) (task *Task, replication *Replication)

Types

type Execution

type Execution struct {
	// ID auto-increments
	ID int64 `json:"id" gorm:"primaryKey"`

	ExecID string `json:"exec_id" gorm:"index"`

	// StreamID represents the stream inside the replication that is running.
	// Is an MD5 construct:`md5(Source, Target, Stream)`.
	StreamID string `json:"stream_id" sql:"not null" gorm:"index"`

	// ConfigMD5 points to config table. not null
	TaskMD5        string `json:"task_md5" sql:"not null" gorm:"index"`
	ReplicationMD5 string `json:"replication_md5" sql:"not null" gorm:"index"`

	Status    sling.ExecStatus `json:"status" gorm:"index"`
	Err       *string          `json:"error"`
	StartTime *time.Time       `json:"start_time" gorm:"index"`
	EndTime   *time.Time       `json:"end_time" gorm:"index"`
	Bytes     uint64           `json:"bytes"`
	ExitCode  int              `json:"exit_code"`
	Output    string           `json:"output" sql:"default ''"`
	Rows      uint64           `json:"rows"`
	Pid       int              `json:"pid"`
	Version   string           `json:"version"`

	// ProjectID represents the project or the repository.
	// If .git exists, grab first commit with `git rev-list --max-parents=0 HEAD`.
	// if not, use md5 of path of folder. Can be `null` if using task.
	ProjectID *string `json:"project_id" gorm:"index"`

	// FilePath represents the path to a file.
	// We would need this to refer back to the same file, even if
	// the contents change. So this should just be the relative path
	// of the replication.yaml or task.yaml from the root of the project.
	// If Ad-hoc from CLI flags, let it be `null`.
	FilePath *string `json:"file_path" gorm:"index"`

	CreatedDt time.Time `json:"created_dt" gorm:"autoCreateTime"`
	UpdatedDt time.Time `json:"updated_dt" gorm:"autoUpdateTime"`
}

func ToExecutionObject

func ToExecutionObject(t *sling.TaskExecution) *Execution

Store saves the task into the local sqlite

type Replication

type Replication struct {
	// MD5 is MD5 of Config json string
	MD5 string `json:"md5" gorm:"primaryKey"`

	Type sling.JobType `json:"type"  gorm:"index"`

	Replication sling.ReplicationConfig `json:"replication"`

	CreatedDt time.Time `json:"created_dt" gorm:"autoCreateTime"`
	UpdatedDt time.Time `json:"updated_dt" gorm:"autoUpdateTime"`
}

type Task

type Task struct {
	// MD5 is MD5 of Config json string
	MD5 string `json:"md5" gorm:"primaryKey"`

	Type sling.JobType `json:"type"  gorm:"index"`

	Task sling.Config `json:"task"`

	CreatedDt time.Time `json:"created_dt" gorm:"autoCreateTime"`
	UpdatedDt time.Time `json:"updated_dt" gorm:"autoUpdateTime"`
}

Jump to

Keyboard shortcuts

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