models

package
v0.15.0-hexun Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2023 License: Apache-2.0, MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BLUEPRINT_MODE_NORMAL   = "NORMAL"
	BLUEPRINT_MODE_ADVANCED = "ADVANCED"
)
View Source
const (
	TASK_CREATED   = "TASK_CREATED"
	TASK_RERUN     = "TASK_RERUN"
	TASK_RUNNING   = "TASK_RUNNING"
	TASK_COMPLETED = "TASK_COMPLETED"
	TASK_FAILED    = "TASK_FAILED"
	TASK_CANCELLED = "TASK_CANCELLED"
	TASK_PARTIAL   = "TASK_PARTIAL"
)

Variables

View Source
var PendingTaskStatus = []string{TASK_CREATED, TASK_RERUN, TASK_RUNNING}

Functions

This section is empty.

Types

type ApiInputProject added in v0.15.0

type ApiInputProject struct {
	BaseProject `mapstructure:",squash"`
	Enable      *bool         `json:"enable" mapstructure:"enable"`
	Metrics     *[]BaseMetric `json:"metrics" mapstructure:"metrics"`
}

type ApiOutputProject added in v0.15.0

type ApiOutputProject struct {
	BaseProject `mapstructure:",squash"`
	Metrics     *[]BaseMetric `json:"metrics" mapstructure:"metrics"`
	Blueprint   *Blueprint    `json:"blueprint" mapstructure:"blueprint"`
}

type BaseMetric added in v0.15.0

type BaseMetric struct {
	PluginName   string `json:"pluginName" mapstructure:"pluginName" gorm:"primaryKey;type:varchar(255)" validate:"required"`
	PluginOption string `json:"pluginOption" mapstructure:"pluginOption" gorm:"type:text"`
	Enable       bool   `json:"enable" mapstructure:"enable" gorm:"type:boolean"`
}

type BaseProject added in v0.15.0

type BaseProject struct {
	Name        string `json:"name" mapstructure:"name" gorm:"primaryKey;type:varchar(255)" validate:"required"`
	Description string `json:"description" mapstructure:"description" gorm:"type:text"`
}

type BaseProjectMetricSetting added in v0.15.0

type BaseProjectMetricSetting struct {
	ProjectName string `json:"projectName" mapstructure:"projectName" gorm:"primaryKey;type:varchar(255)"`
	BaseMetric  `mapstructure:",squash"`
}

type Blueprint

type Blueprint struct {
	Name        string          `json:"name" validate:"required"`
	ProjectName string          `json:"projectName" gorm:"type:varchar(255)"`
	Mode        string          `json:"mode" gorm:"varchar(20)" validate:"required,oneof=NORMAL ADVANCED"`
	Plan        json.RawMessage `json:"plan"`
	Enable      bool            `json:"enable"`
	//please check this https://crontab.guru/ for detail
	CronConfig   string          `json:"cronConfig" format:"* * * * *" example:"0 0 * * 1"`
	IsManual     bool            `json:"isManual"`
	SkipOnFail   bool            `json:"skipOnFail"`
	Labels       []string        `json:"labels"`
	Settings     json.RawMessage `json:"settings" swaggertype:"array,string" example:"please check api: /blueprints/<PLUGIN_NAME>/blueprint-setting"`
	common.Model `swaggerignore:"true"`
}

@Description CronConfig

func (*Blueprint) UnmarshalPlan added in v0.12.0

func (bp *Blueprint) UnmarshalPlan() (core.PipelinePlan, errors.Error)

UnmarshalPlan unmarshals Plan in JSON to strong-typed core.PipelinePlan

type BlueprintSettings added in v0.12.0

type BlueprintSettings struct {
	Version          string          `json:"version" validate:"required,semver,oneof=1.0.0"`
	CreatedDateAfter *time.Time      `json:"createdDateAfter"`
	Connections      json.RawMessage `json:"connections" validate:"required"`
	BeforePlan       json.RawMessage `json:"before_plan"`
	AfterPlan        json.RawMessage `json:"after_plan"`
}

type CollectorLatestState added in v0.15.0

type CollectorLatestState struct {
	CreatedAt          time.Time `json:"createdAt"`
	UpdatedAt          time.Time `json:"updatedAt"`
	RawDataParams      string    `gorm:"primaryKey;column:raw_data_params;type:varchar(255);index" json:"raw_data_params"`
	RawDataTable       string    `gorm:"primaryKey;column:raw_data_table;type:varchar(255)" json:"raw_data_table"`
	CreatedDateAfter   *time.Time
	LatestSuccessStart *time.Time
}

func (CollectorLatestState) TableName added in v0.15.0

func (CollectorLatestState) TableName() string

type DbBlueprint added in v0.14.0

type DbBlueprint struct {
	Name        string `json:"name" validate:"required"`
	ProjectName string `json:"projectName" gorm:"type:varchar(255)"`
	Mode        string `json:"mode" gorm:"varchar(20)" validate:"required,oneof=NORMAL ADVANCED"`
	Plan        string `json:"plan" encrypt:"yes"`
	Enable      bool   `json:"enable"`
	//please check this https://crontab.guru/ for detail
	CronConfig   string `json:"cronConfig" format:"* * * * *" example:"0 0 * * 1"`
	IsManual     bool   `json:"isManual"`
	SkipOnFail   bool   `json:"skipOnFail"`
	Settings     string `` /* 128-byte string literal not displayed */
	common.Model `swaggerignore:"true"`

	Labels []DbBlueprintLabel `json:"-" gorm:"-"`
}

@Description CronConfig

func (DbBlueprint) TableName added in v0.14.0

func (DbBlueprint) TableName() string

type DbBlueprintLabel added in v0.15.0

type DbBlueprintLabel struct {
	CreatedAt   time.Time `json:"createdAt"`
	UpdatedAt   time.Time `json:"updatedAt"`
	BlueprintId uint64    `json:"blueprint_id" gorm:"primaryKey"`
	Name        string    `json:"name" gorm:"primaryKey;index"`
}

func (DbBlueprintLabel) TableName added in v0.15.0

func (DbBlueprintLabel) TableName() string

type DbPipeline added in v0.14.0

type DbPipeline struct {
	common.Model
	Name          string     `json:"name" gorm:"index"`
	BlueprintId   uint64     `json:"blueprintId"`
	Plan          string     `json:"plan" encrypt:"yes"`
	TotalTasks    int        `json:"totalTasks"`
	FinishedTasks int        `json:"finishedTasks"`
	BeganAt       *time.Time `json:"beganAt"`
	FinishedAt    *time.Time `json:"finishedAt" gorm:"index"`
	Status        string     `json:"status"`
	Message       string     `json:"message"`
	ErrorName     string     `json:"errorName"`
	SpentSeconds  int        `json:"spentSeconds"`
	Stage         int        `json:"stage"`
	SkipOnFail    bool       `json:"skipOnFail"`

	Labels []DbPipelineLabel `json:"-" gorm:"-"`
}

func (DbPipeline) TableName added in v0.14.0

func (DbPipeline) TableName() string

type DbPipelineLabel added in v0.15.0

type DbPipelineLabel struct {
	CreatedAt  time.Time `json:"createdAt"`
	UpdatedAt  time.Time `json:"updatedAt"`
	PipelineId uint64    `json:"pipeline_id" gorm:"primaryKey"`
	Name       string    `json:"name" gorm:"primaryKey;index"`
}

func (DbPipelineLabel) TableName added in v0.15.0

func (DbPipelineLabel) TableName() string

type LockingHistory added in v0.15.0

type LockingHistory struct {
	ID        uint64 `gorm:"primaryKey" json:"id"`
	HostName  string
	Version   string
	Succeeded bool
	CreatedAt time.Time `json:"createdAt"`
	UpdatedAt time.Time `json:"updatedAt"`
}

LockingHistory is desgned for preventing mutiple delake instances from sharing the same database which may cause problems like #3537, #3466. It works by the following step:

1. Each devlake insert a record to this table whie `Succeeded=false` 2. Then it should try to lock the LockingStub table 3. Update the record with `Succeeded=true` if it had obtained the lock successfully

NOTE: it works IFF all devlake instances obey the principle described above, in other words, this mechanism can not prevent older versions from sharing the same database

func (LockingHistory) TableName added in v0.15.0

func (LockingHistory) TableName() string

type LockingStub added in v0.15.0

type LockingStub struct {
	Stub string
}

LockingStub does nothing but offer a locking target

func (LockingStub) TableName added in v0.15.0

func (LockingStub) TableName() string

type NewPipeline

type NewPipeline struct {
	Name        string            `json:"name"`
	Plan        core.PipelinePlan `json:"plan" swaggertype:"array,string" example:"please check api /pipelines/<PLUGIN_NAME>/pipeline-plan"`
	Labels      []string          `json:"labels"`
	SkipOnFail  bool              `json:"skipOnFail"`
	BlueprintId uint64
}

We use a 2D array because the request body must be an array of a set of tasks to be executed concurrently, while each set is to be executed sequentially.

type NewTask

type NewTask struct {
	// Plugin name
	*core.PipelineTask
	PipelineId  uint64 `json:"-"`
	PipelineRow int    `json:"-"`
	PipelineCol int    `json:"-"`
	IsRerun     bool   `json:"-"`
}

type Notification

type Notification struct {
	common.Model
	Type         NotificationType
	Endpoint     string
	Nonce        string
	ResponseCode int
	Response     string
	Data         string
}

Notification records notifications sent by lake

func (Notification) TableName

func (Notification) TableName() string

type NotificationType

type NotificationType string
const (
	NotificationPipelineStatusChanged NotificationType = "PipelineStatusChanged"
)

type Pipeline

type Pipeline struct {
	common.Model
	Name          string         `json:"name" gorm:"index"`
	BlueprintId   uint64         `json:"blueprintId"`
	Plan          datatypes.JSON `json:"plan"`
	TotalTasks    int            `json:"totalTasks"`
	FinishedTasks int            `json:"finishedTasks"`
	BeganAt       *time.Time     `json:"beganAt"`
	FinishedAt    *time.Time     `json:"finishedAt" gorm:"index"`
	Status        string         `json:"status"`
	Message       string         `json:"message"`
	ErrorName     string         `json:"errorName"`
	SpentSeconds  int            `json:"spentSeconds"`
	Stage         int            `json:"stage"`
	Labels        []string       `json:"labels"`
	SkipOnFail    bool           `json:"skipOnFail"`
}

type Project added in v0.15.0

type Project struct {
	BaseProject `mapstructure:",squash"`
	common.NoPKModel
}

func (Project) TableName added in v0.15.0

func (Project) TableName() string

type ProjectMetricSetting added in v0.15.0

type ProjectMetricSetting struct {
	BaseProjectMetricSetting `mapstructure:",squash"`
	common.NoPKModel
}

func (ProjectMetricSetting) TableName added in v0.15.0

func (ProjectMetricSetting) TableName() string

type Subtask added in v0.13.0

type Subtask struct {
	common.Model
	TaskID       uint64     `json:"task_id" gorm:"index"`
	Name         string     `json:"name" gorm:"index"`
	Number       int        `json:"number"`
	BeganAt      *time.Time `json:"beganAt"`
	FinishedAt   *time.Time `json:"finishedAt" gorm:"index"`
	SpentSeconds int64      `json:"spentSeconds"`
}

func (Subtask) TableName added in v0.13.0

func (Subtask) TableName() string

type Task

type Task struct {
	common.Model
	Plugin         string              `json:"plugin" gorm:"index"`
	Subtasks       datatypes.JSON      `json:"subtasks"`
	Options        string              `json:"options" gorm:"serializer:encdec"`
	Status         string              `json:"status"`
	Message        string              `json:"message"`
	ErrorName      string              `json:"errorName"`
	Progress       float32             `json:"progress"`
	ProgressDetail *TaskProgressDetail `json:"progressDetail" gorm:"-"`

	FailedSubTask string     `json:"failedSubTask"`
	PipelineId    uint64     `json:"pipelineId" gorm:"index"`
	PipelineRow   int        `json:"pipelineRow"`
	PipelineCol   int        `json:"pipelineCol"`
	BeganAt       *time.Time `json:"beganAt"`
	FinishedAt    *time.Time `json:"finishedAt" gorm:"index"`
	SpentSeconds  int        `json:"spentSeconds"`
}

func (*Task) GetOptions added in v0.15.0

func (task *Task) GetOptions() (map[string]interface{}, errors.Error)

func (*Task) GetSubTasks added in v0.15.0

func (task *Task) GetSubTasks() ([]string, errors.Error)

func (Task) TableName

func (Task) TableName() string

type TaskProgressDetail

type TaskProgressDetail struct {
	TotalSubTasks    int    `json:"totalSubTasks"`
	FinishedSubTasks int    `json:"finishedSubTasks"`
	TotalRecords     int    `json:"totalRecords"`
	FinishedRecords  int    `json:"finishedRecords"`
	SubTaskName      string `json:"subTaskName"`
	SubTaskNumber    int    `json:"subTaskNumber"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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