db

package
v0.4.0-beta Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2023 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Migrate

func Migrate(db *gorm.DB) error

func SqlError2Error

func SqlError2Error(err error) error

Types

type Entity

type Entity struct {
	*gorm.DB
}

func NewDbEntity

func NewDbEntity(db *gorm.DB) (*Entity, error)

func (*Entity) DeleteChunkSegment

func (e *Entity) DeleteChunkSegment(ctx context.Context, segID int64) error

func (*Entity) DeleteFinishedScheduledTask

func (e *Entity) DeleteFinishedScheduledTask(ctx context.Context, aliveTime time.Duration) error

func (*Entity) DeleteObject

func (e *Entity) DeleteObject(ctx context.Context, srcObj, obj *types.Object) error

func (*Entity) DeletePluginRecord

func (e *Entity) DeletePluginRecord(ctx context.Context, plugin types.PlugScope, rid string) error

func (*Entity) DeleteWorkflow

func (e *Entity) DeleteWorkflow(ctx context.Context, wfID string) error

func (*Entity) DeleteWorkflowJob

func (e *Entity) DeleteWorkflowJob(ctx context.Context, wfJobID ...string) error

func (*Entity) GetLabels

func (e *Entity) GetLabels(ctx context.Context, refType string, refID int64) (*types.Labels, error)

func (*Entity) GetObjectByID

func (e *Entity) GetObjectByID(ctx context.Context, oid int64) (*types.Object, error)

func (*Entity) GetObjectExtendData

func (e *Entity) GetObjectExtendData(ctx context.Context, obj *types.Object) error

func (*Entity) GetPluginRecord

func (e *Entity) GetPluginRecord(ctx context.Context, plugin types.PlugScope, rid string, record interface{}) error

func (*Entity) GetWorkflow

func (e *Entity) GetWorkflow(ctx context.Context, wfID string) (*types.WorkflowSpec, error)

func (*Entity) InsertChunkSegment

func (e *Entity) InsertChunkSegment(ctx context.Context, seg types.ChunkSeg) (*types.Object, error)

func (*Entity) ListChunkSegments

func (e *Entity) ListChunkSegments(ctx context.Context, oid, chunkID int64, allChunk bool) ([]types.ChunkSeg, error)

func (*Entity) ListObjectChildren

func (e *Entity) ListObjectChildren(ctx context.Context, filter types.Filter) ([]*types.Object, error)

func (*Entity) ListPluginRecords

func (e *Entity) ListPluginRecords(ctx context.Context, plugin types.PlugScope, groupId string) ([]string, error)

func (*Entity) ListScheduledTask

func (e *Entity) ListScheduledTask(ctx context.Context, taskID string, filter types.ScheduledTaskFilter) ([]*types.ScheduledTask, error)

func (*Entity) ListWorkflow

func (e *Entity) ListWorkflow(ctx context.Context) ([]*types.WorkflowSpec, error)

func (*Entity) ListWorkflowJob

func (e *Entity) ListWorkflowJob(ctx context.Context, filter types.JobFilter) ([]*types.WorkflowJob, error)

func (*Entity) NextSegmentID

func (e *Entity) NextSegmentID(ctx context.Context) (nextID int64, err error)

func (*Entity) SaveChangeParentObject

func (e *Entity) SaveChangeParentObject(ctx context.Context, srcParent, dstParent, obj *types.Object, opt types.ChangeParentOption) error

func (*Entity) SaveMirroredObject

func (e *Entity) SaveMirroredObject(ctx context.Context, srcObj, dstParent, object *types.Object) error

func (*Entity) SaveObjects

func (e *Entity) SaveObjects(ctx context.Context, objects ...*types.Object) error

func (*Entity) SavePluginRecord

func (e *Entity) SavePluginRecord(ctx context.Context, plugin types.PlugScope, groupId, rid string, record interface{}) error

func (*Entity) SaveScheduledTask

func (e *Entity) SaveScheduledTask(ctx context.Context, task *types.ScheduledTask) error

func (*Entity) SaveWorkflow

func (e *Entity) SaveWorkflow(ctx context.Context, wf *types.WorkflowSpec) error

func (*Entity) SaveWorkflowJob

func (e *Entity) SaveWorkflowJob(ctx context.Context, job *types.WorkflowJob) error

func (*Entity) SystemInfo

func (e *Entity) SystemInfo(ctx context.Context) (*types.SystemInfo, error)

type Label

type Label struct {
	ID        int64  `gorm:"column:id;autoIncrement"`
	RefID     int64  `gorm:"column:ref_id;index:label_refid"`
	RefType   string `gorm:"column:ref_type;index:label_reftype"`
	Key       string `gorm:"column:key"`
	Value     string `gorm:"column:value"`
	SearchKey string `gorm:"column:search_key;index:label_search_key"`
}

func (Label) TableName

func (o Label) TableName() string

type Logger

type Logger struct {
	*zap.SugaredLogger
}

func NewDbLogger

func NewDbLogger() *Logger

func (*Logger) Error

func (l *Logger) Error(ctx context.Context, s string, i ...interface{})

func (*Logger) Info

func (l *Logger) Info(ctx context.Context, s string, i ...interface{})

func (*Logger) LogMode

func (l *Logger) LogMode(level glogger.LogLevel) glogger.Interface

func (*Logger) Trace

func (l *Logger) Trace(ctx context.Context, begin time.Time, fc func() (sql string, rowsAffected int64), err error)

func (*Logger) Warn

func (l *Logger) Warn(ctx context.Context, s string, i ...interface{})

type Notification

type Notification struct {
	ID      string    `gorm:"column:id;primaryKey"`
	Title   string    `gorm:"column:title"`
	Message string    `gorm:"column:message"`
	Type    string    `gorm:"column:type"`
	Source  string    `gorm:"column:source"`
	Action  string    `gorm:"column:action"`
	Status  string    `gorm:"column:status"`
	Time    time.Time `gorm:"column:time;index:notif_time"`
}

func (*Notification) TableName

func (o *Notification) TableName() string

type Object

type Object struct {
	ID         int64  `gorm:"column:id;primaryKey"`
	Name       string `gorm:"column:name;index:obj_name"`
	Aliases    string `gorm:"column:aliases"`
	ParentID   int64  `gorm:"column:parent_id;index:parent_id"`
	RefID      int64  `gorm:"column:ref_id;index:ref_id"`
	RefCount   int    `gorm:"column:ref_count"`
	Kind       string `gorm:"column:kind"`
	Hash       string `gorm:"column:hash"`
	Size       int64  `gorm:"column:size"`
	Dev        int64  `gorm:"column:dev"`
	Owner      int64  `gorm:"column:owner"`
	GroupOwner int64  `gorm:"column:group_owner"`
	Permission int64  `gorm:"column:permission"`
	Storage    string `gorm:"column:storage"`
	Namespace  string `gorm:"column:namespace;index:obj_ns"`
	CreatedAt  int64  `gorm:"column:created_at"`
	ChangedAt  int64  `gorm:"column:changed_at"`
	ModifiedAt int64  `gorm:"column:modified_at"`
	AccessAt   int64  `gorm:"column:access_at"`
}

func (*Object) Object

func (o *Object) Object() *types.Object

func (*Object) TableName

func (o *Object) TableName() string

func (*Object) Update

func (o *Object) Update(obj *types.Object)

type ObjectChunk

type ObjectChunk struct {
	ID       int64 `gorm:"column:id;primaryKey"`
	OID      int64 `gorm:"column:oid;index:ck_oid"`
	ChunkID  int64 `gorm:"column:chunk_id;index:ck_id"`
	Off      int64 `gorm:"column:off"`
	Len      int64 `gorm:"column:len"`
	State    int16 `gorm:"column:state"`
	AppendAt int64 `gorm:"column:append_at;index:ck_append_at"`
}

func (ObjectChunk) TableName

func (o ObjectChunk) TableName() string

type ObjectExtend

type ObjectExtend struct {
	ID          int64  `gorm:"column:id;primaryKey"`
	Symlink     string `gorm:"column:symlink"`
	GroupFilter []byte `gorm:"column:group_filter"`
	PlugScope   []byte `gorm:"column:plug_scope"`
}

func (*ObjectExtend) TableName

func (o *ObjectExtend) TableName() string

func (*ObjectExtend) ToExtData

func (o *ObjectExtend) ToExtData() types.ExtendData

func (*ObjectExtend) Update

func (o *ObjectExtend) Update(obj *types.Object)

type ObjectProperty

type ObjectProperty struct {
	ID    int64  `gorm:"column:id;autoIncrement"`
	OID   int64  `gorm:"column:oid;index:prop_oid"`
	Name  string `gorm:"column:key;index:prop_name"`
	Value string `gorm:"column:value"`
}

func (ObjectProperty) TableName

func (o ObjectProperty) TableName() string

type PluginData

type PluginData struct {
	ID         int64            `gorm:"column:id;autoIncrement"`
	PluginName string           `gorm:"column:plugin_name;index:plugin_name"`
	Version    string           `gorm:"column:version"`
	Type       types.PluginType `gorm:"column:type"`
	GroupId    string           `gorm:"column:group_id;index:group_id"`
	RecordId   string           `gorm:"column:record_id;index:record_id"`
	Content    string           `gorm:"column:content"`
}

func (PluginData) TableName

func (d PluginData) TableName() string

type ScheduledTask

type ScheduledTask struct {
	ID             int64     `gorm:"column:id;autoIncrement"`
	TaskID         string    `gorm:"column:task_id;index:st_task_id"`
	RefType        string    `gorm:"column:ref_type;index:sche_task_reftype"`
	RefID          int64     `gorm:"column:ref_id;index:sche_task_refid"`
	Status         string    `gorm:"column:status;index:st_task_status"`
	Result         string    `gorm:"column:result"`
	CreatedTime    time.Time `gorm:"column:created_time"`
	ExecutionTime  time.Time `gorm:"column:execution_time"`
	ExpirationTime time.Time `gorm:"column:expiration_time"`
	Event          string    `gorm:"column:event"`
}

func (ScheduledTask) TableName

func (d ScheduledTask) TableName() string

type SystemInfo

type SystemInfo struct {
	FsID     string `gorm:"column:fs_id;primaryKey"`
	ChunkSeg int64  `gorm:"column:chunk_seg"`
}

func (SystemInfo) TableName

func (i SystemInfo) TableName() string

type Workflow

type Workflow struct {
	ID              string    `gorm:"column:id;primaryKey"`
	Name            string    `gorm:"column:name"`
	Rule            string    `gorm:"column:rule"`
	Steps           string    `gorm:"column:steps"`
	Enable          bool      `gorm:"column:enable;index:wf_enable"`
	CreatedAt       time.Time `gorm:"column:created_at;index:wf_creat"`
	UpdatedAt       time.Time `gorm:"column:updated_at"`
	LastTriggeredAt time.Time `gorm:"column:last_triggered_at"`
}

func (*Workflow) TableName

func (o *Workflow) TableName() string

func (*Workflow) ToWorkflowSpec

func (o *Workflow) ToWorkflowSpec() (*types.WorkflowSpec, error)

func (*Workflow) Update

func (o *Workflow) Update(wf *types.WorkflowSpec) error

type WorkflowJob

type WorkflowJob struct {
	ID            string    `gorm:"column:id;autoIncrement"`
	Workflow      string    `gorm:"column:workflow;index:job_wf_id"`
	TriggerReason string    `gorm:"column:trigger_reason"`
	TargetEntry   int64     `gorm:"column:target_entry;index:job_tgt_en"`
	Target        string    `gorm:"column:target"`
	Steps         string    `gorm:"column:steps"`
	Status        string    `gorm:"column:status;index:job_status"`
	Message       string    `gorm:"column:message"`
	Executor      string    `gorm:"column:executor;index:job_executor"`
	StartAt       time.Time `gorm:"column:start_at"`
	FinishAt      time.Time `gorm:"column:finish_at"`
	CreatedAt     time.Time `gorm:"column:created_at;index:job_created_at"`
	UpdatedAt     time.Time `gorm:"column:updated_at"`
}

func (*WorkflowJob) TableName

func (o *WorkflowJob) TableName() string

func (*WorkflowJob) ToWorkflowJobSpec

func (o *WorkflowJob) ToWorkflowJobSpec() (*types.WorkflowJob, error)

func (*WorkflowJob) Update

func (o *WorkflowJob) Update(job *types.WorkflowJob) error

Jump to

Keyboard shortcuts

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