store

package
v1.2.9 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2024 License: GPL-3.0 Imports: 14 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,omitempty" gorm:"primaryKey"`

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

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

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

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

	// 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,omitempty" 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,omitempty" gorm:"index"`

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

	Task        *Task        `json:"task,omitempty" gorm:"-"`
	Replication *Replication `json:"replication,omitempty" gorm:"-"`
}

Execution is a task execute in the store. PK = exec_id + stream_id

func ToExecutionObject

func ToExecutionObject(t *sling.TaskExecution) *Execution

Store saves the task into the local sqlite

type Replication

type Replication struct {
	Name string `json:"name"  gorm:"index"`

	ProjectID *string `json:"project_id,omitempty" gorm:"index"`

	// MD5 is MD5 of Config json string
	MD5 string `json:"md5" gorm:"primaryKey"`

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

	Config sling.ReplicationConfig `json:"config"`

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

type Task

type Task struct {
	ProjectID *string `json:"project_id,omitempty" gorm:"index"`

	// MD5 is MD5 of Config json string
	MD5 string `json:"md5" gorm:"primaryKey"`

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

	Config sling.Config `json:"config"`

	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