models

package
v0.0.0-...-1fa52ee Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2024 License: Apache-2.0, BSD-2-Clause, ISC, + 1 more 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_RESUME    = "TASK_RESUME"
	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

func DumpInfo

func DumpInfo(tbl DynamicTabler) map[string]any

DumpInfo Useful function for debugging purposes - to see what's in the struct at runtime

func UnwrapObject

func UnwrapObject(ifc any) any

UnwrapObject if the actual object is wrapped in some proxy, it unwinds and returns it, otherwise this is idempotent

Types

type ApiInputApiKey

type ApiInputApiKey struct {
	Name        string     `json:"name" validate:"required,max=255"`
	Type        string     `json:"type" validate:"required"`
	AllowedPath string     `json:"allowedPath" validate:"required"`
	ExpiredAt   *time.Time `json:"expiredAt" `
}

type ApiInputProject

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

type ApiKey

type ApiKey struct {
	common.Model
	common.Creator
	common.Updater
	Name        string     `json:"name"`
	ApiKey      string     `json:"apiKey,omitempty"`
	ExpiredAt   *time.Time `json:"expiredAt"`
	AllowedPath string     `json:"allowedPath"`
	Type        string     `json:"type"`
	Extra       string     `json:"extra"`
}

ApiKey is the basic of api key management.

func (*ApiKey) RemoveHashedApiKey

func (apiKey *ApiKey) RemoveHashedApiKey()

func (*ApiKey) TableName

func (apiKey *ApiKey) TableName() string

type ApiOutputApiKey

type ApiOutputApiKey = ApiKey

type ApiOutputProject

type ApiOutputProject struct {
	Project      `mapstructure:",squash"`
	Metrics      []*BaseMetric `json:"metrics" mapstructure:"metrics"`
	Blueprint    *Blueprint    `json:"blueprint" mapstructure:"blueprint"`
	LastPipeline *Pipeline     `json:"lastPipeline,omitempty" mapstructure:"lastPipeline"`
}

type ApiProjectCheck

type ApiProjectCheck struct {
	Exist bool `json:"exist" mapstructure:"exist"`
}

type BaseMetric

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

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

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         PipelinePlan           `json:"plan" gorm:"serializer:encdec"`
	Enable       bool                   `json:"enable"`
	CronConfig   string                 `json:"cronConfig" format:"* * * * *" example:"0 0 * * 1"`
	IsManual     bool                   `json:"isManual"`
	BeforePlan   PipelinePlan           `json:"beforePlan" gorm:"serializer:encdec"`
	AfterPlan    PipelinePlan           `json:"afterPlan" gorm:"serializer:encdec"`
	Labels       []string               `json:"labels" gorm:"-"`
	Connections  []*BlueprintConnection `json:"connections" gorm:"-"`
	SyncPolicy   `gorm:"embedded"`
	common.Model `swaggerignore:"true"`
}

@Description CronConfig

func (Blueprint) TableName

func (Blueprint) TableName() string

type BlueprintConnection

type BlueprintConnection struct {
	BlueprintId  uint64            `json:"-" gorm:"primaryKey" validate:"required"`
	PluginName   string            `json:"pluginName" gorm:"primaryKey;type:varchar(255)" validate:"required"`
	ConnectionId uint64            `json:"connectionId" gorm:"primaryKey" validate:"required"`
	Scopes       []*BlueprintScope `json:"scopes" gorm:"-"`
}

func (BlueprintConnection) TableName

func (BlueprintConnection) TableName() string

type BlueprintLabel

type BlueprintLabel 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 (BlueprintLabel) TableName

func (BlueprintLabel) TableName() string

type BlueprintScope

type BlueprintScope struct {
	BlueprintId  uint64 `json:"-" gorm:"primaryKey" validate:"required"`
	PluginName   string `json:"-" gorm:"primaryKey;type:varchar(255)" validate:"required"`
	ConnectionId uint64 `json:"-" gorm:"primaryKey" validate:"required"`
	ScopeId      string `json:"scopeId" gorm:"primaryKey;type:varchar(255)" validate:"required"`
}

func (BlueprintScope) TableName

func (BlueprintScope) TableName() string

type CollectorLatestState

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"`
	TimeAfter          *time.Time
	LatestSuccessStart *time.Time
}

func (CollectorLatestState) TableName

func (CollectorLatestState) TableName() string

type DbPipelineLabel

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

func (DbPipelineLabel) TableName() string

type DynamicTabler

type DynamicTabler interface {
	dal.Tabler
	json.Marshaler
	json.Unmarshaler
	NewValue() any
	New() DynamicTabler
	NewSlice() DynamicTabler
	From(src any) errors.Error
	To(target any) errors.Error
	Unwrap() any
	UnwrapPtr() *any
	UnwrapSlice() []any
}

DynamicTabler is a core.Tabler that wraps a runtime (anonymously) generated data-model. Due to limitations of reflection in Go and the GORM framework, the underlying model and the table have to be explicitly passed into dal.Dal's API via Unwrap() and TableName()

func NewDynamicTabler

func NewDynamicTabler(tableName string, objType reflect.Type) DynamicTabler

type DynamicTablerImpl

type DynamicTablerImpl struct {
	// contains filtered or unexported fields
}

DynamicTablerImpl the implementation of DynamicTabler

func (*DynamicTablerImpl) From

func (d *DynamicTablerImpl) From(src any) errors.Error

func (*DynamicTablerImpl) MarshalJSON

func (d *DynamicTablerImpl) MarshalJSON() ([]byte, error)

func (*DynamicTablerImpl) New

func (*DynamicTablerImpl) NewSlice

func (d *DynamicTablerImpl) NewSlice() DynamicTabler

func (*DynamicTablerImpl) NewValue

func (d *DynamicTablerImpl) NewValue() any

func (*DynamicTablerImpl) TableName

func (d *DynamicTablerImpl) TableName() string

func (*DynamicTablerImpl) To

func (d *DynamicTablerImpl) To(target any) errors.Error

func (*DynamicTablerImpl) UnmarshalJSON

func (d *DynamicTablerImpl) UnmarshalJSON(b []byte) error

func (*DynamicTablerImpl) Unwrap

func (d *DynamicTablerImpl) Unwrap() any

func (*DynamicTablerImpl) UnwrapPtr

func (d *DynamicTablerImpl) UnwrapPtr() *any

func (*DynamicTablerImpl) UnwrapSlice

func (d *DynamicTablerImpl) UnwrapSlice() []any

type GenericPipelinePlan

type GenericPipelinePlan[T any] []GenericPipelineStage[T]

type GenericPipelineStage

type GenericPipelineStage[T any] []*GenericPipelineTask[T]

type GenericPipelineTask

type GenericPipelineTask[T any] struct {
	Plugin   string   `json:"plugin" binding:"required"`
	Subtasks []string `json:"subtasks"`
	Options  T        `json:"options"`
}

type LatestSyncState

type LatestSyncState struct {
	RawDataTable       string     `json:"raw_data_table"`
	RawDataParams      string     `json:"raw_data_params"`
	LatestSuccessStart *time.Time `json:"latest_success_start"`
}

type LockingHistory

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

func (LockingHistory) TableName() string

type LockingStub

type LockingStub struct {
	Stub string `gorm:"primaryKey;type:varchar(255)"`
}

LockingStub does nothing but offer a locking target

func (LockingStub) TableName

func (LockingStub) TableName() string

type NewPipeline

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

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
	*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          PipelinePlan `json:"plan" gorm:"serializer:encdec"`
	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" gorm:"-"`
	SyncPolicy    `gorm:"embedded"`
}

func (Pipeline) TableName

func (Pipeline) TableName() string

type PipelinePlan

type PipelinePlan []PipelineStage

PipelinePlan consist of multiple PipelineStages, they will be executed in sequential order

func (PipelinePlan) IsEmpty

func (plan PipelinePlan) IsEmpty() bool

IsEmpty checks if a PipelinePlan is empty

type PipelineStage

type PipelineStage []*PipelineTask

PipelineStage consist of multiple PipelineTasks, they will be executed in parallel

type PipelineTask

type PipelineTask GenericPipelineTask[map[string]interface{}]

PipelineTask represents a smallest unit of execution inside a PipelinePlan

type Project

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

func (Project) TableName

func (Project) TableName() string

type ProjectMetricSetting

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

func (ProjectMetricSetting) TableName

func (ProjectMetricSetting) TableName() string

type Store

type Store struct {
	StoreKey   string          `gorm:"primaryKey;type:varchar(255)"`
	StoreValue json.RawMessage `gorm:"type:json;serializer:json"`
	CreatedAt  time.Time       `json:"createdAt" mapstructure:"createdAt"`
	UpdatedAt  time.Time       `json:"updatedAt" mapstructure:"updatedAt"`
}

func (Store) TableName

func (Store) TableName() string

type SubTasksOuput

type SubTasksOuput struct {
	SubtasksInfo   []SubtasksInfo `json:"subtasks"`
	CompletionRate float64        `json:"completionRate"`
	Status         string         `json:"status"`
	Count          int64          `json:"count"`
}

type Subtask

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"`
	FinishedRecords int        `json:"finishedRecords"`
	Sequence        int        `json:"sequence"`
	IsCollector     bool       `json:"isCollector"`
	IsFailed        bool       `json:"isFailed"`
	Message         string     `json:"message"`
}

func (Subtask) TableName

func (Subtask) TableName() string

type SubtaskDetails

type SubtaskDetails struct {
	ID              uint64     `json:"id"`
	CreatedAt       time.Time  `json:"createdAt"`
	UpdatedAt       time.Time  `json:"updatedAt"`
	TaskID          uint64     `json:"taskId"`
	Name            string     `json:"name"`
	Number          int        `json:"number"`
	BeganAt         *time.Time `json:"beganAt"`
	FinishedAt      *time.Time `json:"finishedAt"`
	SpentSeconds    int64      `json:"spentSeconds"`
	FinishedRecords int        `json:"finishedRecords"`
	Sequence        int        `json:"sequence"`
	IsCollector     bool       `json:"isCollector"`
	IsFailed        bool       `json:"isFailed"`
	Message         string     `json:"message"`
}

type SubtasksInfo

type SubtasksInfo struct {
	ID             uint64            `json:"id"`
	PipelineID     uint64            `json:"pipelineId"`
	CreatedAt      time.Time         `json:"createdAt"`
	UpdatedAt      time.Time         `json:"updatedAt"`
	BeganAt        *time.Time        `json:"beganAt"`
	FinishedAt     *time.Time        `json:"finishedAt"`
	Plugin         string            `json:"plugin"`
	Options        any               `json:"options"`
	Status         string            `json:"status"`
	FailedSubTask  string            `json:"failedSubTask"`
	Message        string            `json:"message"`
	ErrorName      string            `json:"errorName"`
	SpentSeconds   int               `json:"spentSeconds"`
	SubtaskDetails []*SubtaskDetails `json:"subtaskDetails"`
}

type SyncPolicy

type SyncPolicy struct {
	SkipOnFail     bool       `json:"skipOnFail"`
	FullSync       bool       `json:"fullSync"`
	SkipCollectors bool       `json:"skipCollectors"`
	TimeAfter      *time.Time `json:"timeAfter"`
}

type Task

type Task struct {
	common.Model
	Plugin         string                 `json:"plugin" gorm:"index"`
	Subtasks       []string               `json:"subtasks" gorm:"type:json;serializer:json"`
	Options        map[string]interface{} `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) 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"`
	CollectSubtaskNumber int    `json:"collectSubtaskNumber"`
	OtherSubtaskNumber   int    `json:"otherSubtaskNumber"`
}

Jump to

Keyboard shortcuts

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