dbclient

package
v1.3.0-rc.0...-d217119 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2024 License: Apache-2.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrZeroAffectedRows = errors.New("affected rows was 0")
	ErrRecordNotFound   = errors.New("not found")
)
View Source
var NotFoundBaseError = dbError{/* contains filtered or unexported fields */}

Functions

func IsNotFoundError

func IsNotFoundError(err error) bool

Types

type Client

type Client struct {
	*xorm.Engine
}

func New

func New() (*Client, error)

func (*Client) AppendPipelineEvent

func (client *Client) AppendPipelineEvent(pipelineID uint64, newEvents []*basepb.PipelineEvent, ops ...SessionOption) error

func (*Client) BatchCreatePipelineStages

func (client *Client) BatchCreatePipelineStages(stages []spec.PipelineStage, ops ...SessionOption) (err error)

func (*Client) BatchCreatePipelineTasks

func (client *Client) BatchCreatePipelineTasks(pts []spec.PipelineTask, ops ...SessionOption) (err error)

func (*Client) BatchInsertLabels

func (client *Client) BatchInsertLabels(labels []spec.PipelineLabel, ops ...SessionOption) (err error)

func (*Client) BatchListPipelineReportsByPipelineID

func (client *Client) BatchListPipelineReportsByPipelineID(pipelineIDs []uint64, types []string, ops ...SessionOption) (map[uint64][]spec.PipelineReport, error)

func (*Client) BatchUpdatePipelineBaseByDefinitionIDs

func (client *Client) BatchUpdatePipelineBaseByDefinitionIDs(ids []string, updateMap map[spec.Field]interface{}, ops ...SessionOption) error

func (*Client) CleanPipelineTaskResult

func (client *Client) CleanPipelineTaskResult(id uint64, ops ...SessionOption) error

func (*Client) ConvertPipelineReport

func (client *Client) ConvertPipelineReport(dbReport spec.PipelineReport) apistructs.PipelineReport

func (*Client) CreatePipeline

func (client *Client) CreatePipeline(p *spec.Pipeline, ops ...SessionOption) error

CreatePipeline: base + extra + labels

func (*Client) CreatePipelineBase

func (client *Client) CreatePipelineBase(base *spec.PipelineBase, ops ...SessionOption) error

func (*Client) CreatePipelineExtra

func (client *Client) CreatePipelineExtra(extra *spec.PipelineExtra, ops ...SessionOption) error

func (*Client) CreatePipelineLabels

func (client *Client) CreatePipelineLabels(p *spec.Pipeline, ops ...SessionOption) (err error)

func (*Client) CreatePipelineQueue

func (client *Client) CreatePipelineQueue(req *pb.QueueCreateRequest, ops ...SessionOption) (*pb.Queue, error)

CreatePipelineQueue

func (*Client) CreatePipelineReport

func (client *Client) CreatePipelineReport(report *spec.PipelineReport, ops ...SessionOption) error

func (*Client) CreatePipelineStage

func (client *Client) CreatePipelineStage(ps *spec.PipelineStage, ops ...SessionOption) (err error)

func (*Client) CreatePipelineTask

func (client *Client) CreatePipelineTask(pt *spec.PipelineTask, ops ...SessionOption) (err error)

func (*Client) DeletePipeline

func (client *Client) DeletePipeline(id uint64, ops ...SessionOption) error

func (*Client) DeletePipelineLabelsByPipelineID

func (client *Client) DeletePipelineLabelsByPipelineID(pipelineID uint64, ops ...SessionOption) error

func (*Client) DeletePipelineQueue

func (client *Client) DeletePipelineQueue(queueID uint64, ops ...SessionOption) error

DeletePipelineQueue

func (*Client) DeletePipelineRelated

func (client *Client) DeletePipelineRelated(pipelineID uint64, ops ...SessionOption) error

func (*Client) DeletePipelineReportsByPipelineID

func (client *Client) DeletePipelineReportsByPipelineID(pipelineID uint64, ops ...SessionOption) error

func (*Client) DeletePipelineStagesByPipelineID

func (client *Client) DeletePipelineStagesByPipelineID(pipelineID uint64, ops ...SessionOption) error

func (*Client) DeletePipelineTasksByPipelineID

func (client *Client) DeletePipelineTasksByPipelineID(pipelineID uint64, ops ...SessionOption) error

func (*Client) FindCauseFailedPipelineTasks

func (client *Client) FindCauseFailedPipelineTasks(pipelineID uint64) (spec.RerunFailedDetail, error)

FindCauseFailedPipelineTasks 寻找导致失败的节点

func (*Client) FindLifecycleHookClientList

func (client *Client) FindLifecycleHookClientList(ops ...SessionOption) (clients []*PipelineLifecycleHookClient, err error)

func (*Client) FindPipelineTaskByName

func (client *Client) FindPipelineTaskByName(pipelineID uint64, name string) (spec.PipelineTask, error)

func (*Client) FindSnippetClientList

func (client *Client) FindSnippetClientList() (clients []*DicePipelineSnippetClient, err error)

func (*Client) GetLabel

func (client *Client) GetLabel(id uint64) (label *spec.PipelineLabel, err error)

func (*Client) GetPipeline

func (client *Client) GetPipeline(id uint64, ops ...SessionOption) (spec.Pipeline, error)

GetPipeline: base + extra + labels

func (*Client) GetPipelineBase

func (client *Client) GetPipelineBase(id uint64, ops ...SessionOption) (spec.PipelineBase, bool, error)

func (*Client) GetPipelineBaseByFilter

func (client *Client) GetPipelineBaseByFilter(filter *PipelineBaseFilter, ops ...SessionOption) ([]spec.PipelineBase, error)

func (*Client) GetPipelineDefinition

func (client *Client) GetPipelineDefinition(id string, ops ...SessionOption) (*db.PipelineDefinition, error)

func (*Client) GetPipelineDefinitionByIDs

func (client *Client) GetPipelineDefinitionByIDs(ids []string, ops ...SessionOption) ([]*db.PipelineDefinition, error)

func (*Client) GetPipelineDefinitionByPipelineID

func (client *Client) GetPipelineDefinitionByPipelineID(pipelineID uint64, ops ...SessionOption) (*db.PipelineDefinition, bool, error)

func (*Client) GetPipelineEvents

func (client *Client) GetPipelineEvents(pipelineID uint64, ops ...SessionOption) (*spec.PipelineReport, []*basepb.PipelineEvent, error)

GetPipelineEvents get pipeline events from reports. return: report, events, error

func (*Client) GetPipelineExtraByPipelineID

func (client *Client) GetPipelineExtraByPipelineID(pipelineID uint64, ops ...SessionOption) (spec.PipelineExtra, bool, error)

func (*Client) GetPipelineOutputs

func (client *Client) GetPipelineOutputs(pipelineID uint64) (map[string]map[string]string, error)

GetPipelineOutputs 返回 pipeline 下所有 task 的 output

func (*Client) GetPipelineQueue

func (client *Client) GetPipelineQueue(queueID uint64, ops ...SessionOption) (*pb.Queue, bool, error)

GetPipelineQueue

func (*Client) GetPipelineStage

func (client *Client) GetPipelineStage(id uint64, ops ...SessionOption) (spec.PipelineStage, error)

func (*Client) GetPipelineStageWithPreStatus

func (client *Client) GetPipelineStageWithPreStatus(id uint64, ops ...SessionOption) (spec.PipelineStage, error)

func (*Client) GetPipelineStatus

func (client *Client) GetPipelineStatus(id uint64, ops ...SessionOption) (apistructs.PipelineStatus, error)

func (*Client) GetPipelineTask

func (client *Client) GetPipelineTask(id uint64) (spec.PipelineTask, error)

func (*Client) GetPipelineWithExistInfo

func (client *Client) GetPipelineWithExistInfo(id uint64, ops ...SessionOption) (spec.Pipeline, bool, error)

GetPipelineWithExistInfo 当 id 对应的流水线记录不存在时,error = nil, found = false

func (*Client) GetPipelineWithTasks

func (client *Client) GetPipelineWithTasks(id uint64) (*spec.PipelineWithTasks, error)

GetPipelineWithTasks

func (*Client) IncreaseExecutedActionNum

func (client *Client) IncreaseExecutedActionNum(id string, ops ...SessionOption) error

func (*Client) InsertOrUpdateLifeCycleClient

func (client *Client) InsertOrUpdateLifeCycleClient(hookClient *PipelineLifecycleHookClient, ops ...SessionOption) error

func (*Client) ListLabelsByPipelineID

func (client *Client) ListLabelsByPipelineID(pipelineID uint64, ops ...SessionOption) ([]spec.PipelineLabel, error)

ListLabelsByPipelineID 根据 pipelineID 获取 labels

func (*Client) ListPipelineBaseWithDefinitionByIDs

func (client *Client) ListPipelineBaseWithDefinitionByIDs(pipelineIDs []uint64, ops ...SessionOption) (map[uint64]spec.PipelineBaseWithDefinition, error)

func (*Client) ListPipelineBasesByIDs

func (client *Client) ListPipelineBasesByIDs(pipelineIDs []uint64, ops ...SessionOption) (map[uint64]spec.PipelineBase, error)

func (*Client) ListPipelineConfigsOfActionExecutor

func (client *Client) ListPipelineConfigsOfActionExecutor() (configs []spec.PipelineConfig, cfgChan chan spec.ActionExecutorConfig, err error)

func (*Client) ListPipelineExtrasByPipelineIDs

func (client *Client) ListPipelineExtrasByPipelineIDs(pipelineIDs []uint64, ops ...SessionOption) (map[uint64]spec.PipelineExtra, error)

func (*Client) ListPipelineIDsByStatuses

func (client *Client) ListPipelineIDsByStatuses(status ...apistructs.PipelineStatus) ([]uint64, error)

ListPipelineIDsByStatuses

func (*Client) ListPipelineLabels

func (client *Client) ListPipelineLabels(req *pb.PipelineLabelListRequest, ops ...SessionOption) ([]spec.PipelineLabel, int64, error)

func (*Client) ListPipelineLabelsByTypeAndTargetIDs

func (client *Client) ListPipelineLabelsByTypeAndTargetIDs(_type apistructs.PipelineLabelType, targetIDs []uint64, ops ...SessionOption) (map[uint64][]spec.PipelineLabel, error)

func (*Client) ListPipelineSources

func (client *Client) ListPipelineSources() ([]apistructs.PipelineSource, error)

func (*Client) ListPipelineStageByPipelineID

func (client *Client) ListPipelineStageByPipelineID(pipelineID uint64, ops ...SessionOption) ([]spec.PipelineStage, error)

func (*Client) ListPipelineStageByStatuses

func (client *Client) ListPipelineStageByStatuses(statuses ...apistructs.PipelineStatus) ([]spec.PipelineStage, error)

func (*Client) ListPipelineTasksByPipelineID

func (client *Client) ListPipelineTasksByPipelineID(pipelineID uint64, ops ...SessionOption) ([]spec.PipelineTask, error)

func (*Client) ListPipelineTasksByStageID

func (client *Client) ListPipelineTasksByStageID(stageID uint64) ([]*spec.PipelineTask, error)

func (*Client) ListPipelineTasksByTypeStatuses

func (client *Client) ListPipelineTasksByTypeStatuses(typ string, statuses ...apistructs.PipelineStatus) ([]spec.PipelineTask, error)

func (*Client) ListPipelinesByIDs

func (client *Client) ListPipelinesByIDs(pipelineIDs []uint64, needQueryDefinition bool, ops ...SessionOption) ([]spec.Pipeline, error)

func (*Client) MakePipelineReportTypeLabelKey

func (client *Client) MakePipelineReportTypeLabelKey(typ apistructs.PipelineReportType) (string, string)

func (*Client) NewSession

func (client *Client) NewSession(ops ...SessionOption) *Session

func (*Client) PageListPipelines

func (client *Client) PageListPipelines(req *pipelinepb.PipelinePagingRequest, ops ...SessionOption) (*PageListPipelinesResult, error)

PageListPipelines return pagingPipelines, pagingPipelineIDs, total, currentPageSize, error

func (*Client) PagingPipelineQueues

func (client *Client) PagingPipelineQueues(req *pb.QueuePagingRequest, ops ...SessionOption) (*pb.QueuePagingResponse, error)

func (*Client) PagingPipelineReportSets

func (client *Client) PagingPipelineReportSets(req *pb.PipelineReportSetPagingRequest, ops ...SessionOption) ([]*pb.PipelineReportSet, int, error)

func (*Client) ParseRerunFailedDetail

func (client *Client) ParseRerunFailedDetail(detail *spec.RerunFailedDetail) (
	map[string]*spec.PipelineTask, map[string]*spec.PipelineTask, error)

func (*Client) PipelineStatistic

func (client *Client) PipelineStatistic(source, clusterName string) (*pipelinepb.PipelineStatisticResponseData, error)

PipelineStatistic pipeline operation statistics

func (*Client) RefreshPipeline

func (client *Client) RefreshPipeline(p *spec.Pipeline) error

RefreshPipeline 更新 pipeline

func (*Client) RefreshPipelineTask

func (client *Client) RefreshPipelineTask(task *spec.PipelineTask) error

func (*Client) SelectTargetIDsByLabels

func (client *Client) SelectTargetIDsByLabels(req apistructs.TargetIDSelectByLabelRequest, ops ...SessionOption) (targetIDs []uint64, err error)

func (*Client) StoreAnalyzedCrossCluster

func (client *Client) StoreAnalyzedCrossCluster(pipelineID uint64, analyzedCrossCluster bool, ops ...SessionOption) error

func (*Client) UpdatePipelineBase

func (client *Client) UpdatePipelineBase(id uint64, base *spec.PipelineBase, ops ...SessionOption) error

func (*Client) UpdatePipelineBaseStatus

func (client *Client) UpdatePipelineBaseStatus(id uint64, status apistructs.PipelineStatus, ops ...SessionOption) error

func (*Client) UpdatePipelineDefinition

func (client *Client) UpdatePipelineDefinition(id string, pipelineDefinition *db.PipelineDefinition, ops ...SessionOption) error

func (*Client) UpdatePipelineExtraByPipelineID

func (client *Client) UpdatePipelineExtraByPipelineID(pipelineID uint64, extra *spec.PipelineExtra, ops ...SessionOption) error

func (*Client) UpdatePipelineExtraExtraInfoByPipelineID

func (client *Client) UpdatePipelineExtraExtraInfoByPipelineID(pipelineID uint64, extraInfo spec.PipelineExtraInfo, ops ...SessionOption) error

func (*Client) UpdatePipelineExtraSnapshot

func (client *Client) UpdatePipelineExtraSnapshot(pipelineID uint64, snapshot spec.Snapshot, ops ...SessionOption) error

func (*Client) UpdatePipelineProgress

func (client *Client) UpdatePipelineProgress(pipelineID uint64, progress int, ops ...SessionOption) error

func (*Client) UpdatePipelineQueue

func (client *Client) UpdatePipelineQueue(req *pb.QueueUpdateRequest, ops ...SessionOption) (*pb.Queue, error)

UpdatePipelineQueue

func (*Client) UpdatePipelineReport

func (client *Client) UpdatePipelineReport(report *spec.PipelineReport, ops ...SessionOption) error

func (*Client) UpdatePipelineShowMessage

func (client *Client) UpdatePipelineShowMessage(pipelineID uint64, showMessage basepb.ShowMessage, ops ...SessionOption) error

UpdatePipelineShowMessage 更新 extra.ExtraInfo.ShowMessage

func (*Client) UpdatePipelineStage

func (client *Client) UpdatePipelineStage(id uint64, stage *spec.PipelineStage) error

func (*Client) UpdatePipelineTask

func (client *Client) UpdatePipelineTask(id uint64, task *spec.PipelineTask, ops ...SessionOption) error

func (*Client) UpdatePipelineTaskContext

func (client *Client) UpdatePipelineTaskContext(id uint64, ctx spec.PipelineTaskContext, ops ...SessionOption) error

func (*Client) UpdatePipelineTaskExtra

func (client *Client) UpdatePipelineTaskExtra(id uint64, extra spec.PipelineTaskExtra, ops ...SessionOption) error

func (*Client) UpdatePipelineTaskInspect

func (client *Client) UpdatePipelineTaskInspect(id uint64, inspect taskinspect.Inspect) error

func (*Client) UpdatePipelineTaskMetadata

func (client *Client) UpdatePipelineTaskMetadata(id uint64, result *taskresult.Result) error

func (*Client) UpdatePipelineTaskSnippetDetail

func (client *Client) UpdatePipelineTaskSnippetDetail(id uint64, snippetDetail apistructs.PipelineTaskSnippetDetail, ops ...SessionOption) error

UpdatePipelineTaskSnippetDetail 更新 snippet task 的 snippet 信息

func (*Client) UpdatePipelineTaskStatus

func (client *Client) UpdatePipelineTaskStatus(id uint64, status apistructs.PipelineStatus, ops ...SessionOption) error

func (*Client) UpdatePipelineTaskTime

func (client *Client) UpdatePipelineTaskTime(p *spec.Pipeline, ops ...SessionOption) error

UpdatePipelineTaskTime update the costTime,timeBegin and timeEnd of pipeline task

func (*Client) UpdateWholeStatusBorn

func (client *Client) UpdateWholeStatusBorn(pipelineID uint64, ops ...SessionOption) (err error)

UpdateWholeStatusBorn 状态更新顺序:task -> stage -> pipeline

type DicePipelineSnippetClient

type DicePipelineSnippetClient struct {
	ID    uint64                     `json:"id" xorm:"pk autoincr"`
	Name  string                     `json:"name"`
	Host  string                     `json:"host"`
	Extra PipelineSnippetClientExtra `json:"extra" xorm:"json"`
}

func (*DicePipelineSnippetClient) TableName

func (ps *DicePipelineSnippetClient) TableName() string

type PageListPipelinesResult

type PageListPipelinesResult struct {
	Pipelines         []spec.Pipeline
	PagingPipelineIDs []uint64
	Total             int64
	CurrentPageSize   int64
}

func (*PageListPipelinesResult) GetMaxPipelineID

func (p *PageListPipelinesResult) GetMaxPipelineID() uint64

func (*PageListPipelinesResult) GetMinPipelineID

func (p *PageListPipelinesResult) GetMinPipelineID() uint64

type PipelineBaseFilter

type PipelineBaseFilter struct {
	ID                   []uint64
	PipelineSource       []apistructs.PipelineSource
	PipelineYmName       []string
	ClusterName          []string
	Status               []apistructs.PipelineStatus
	Type                 []apistructs.PipelineType
	TriggerMode          []apistructs.PipelineTriggerMode
	CronID               []uint64
	IsSnippet            []uint64
	StartTimeCreated     *time.Time
	EndTimeCreated       *time.Time
	StartTimeUpdated     *time.Time
	EndTimeUpdated       *time.Time
	PipelineDefinitionID []string
}

type PipelineLifecycleHookClient

type PipelineLifecycleHookClient struct {
	ID     uint64 `json:"id" xorm:"pk autoincr"`
	Name   string `json:"name"`
	Host   string `json:"host"`
	Prefix string `json:"prefix"`
}

func (*PipelineLifecycleHookClient) TableName

func (ps *PipelineLifecycleHookClient) TableName() string

type PipelineSnippetClientExtra

type PipelineSnippetClientExtra struct {
	UrlPathPrefix string `json:"urlPathPrefix"`
}

type Session

type Session struct {
	*xorm.Session
	AllowZeroAffectedRows bool
	NeedAutoClose         bool
	NeedNoAutoTime        bool
}

func (*Session) Close

func (session *Session) Close()

type SessionOption

type SessionOption func(*Session)

func WithAllowZeroAffectedRows

func WithAllowZeroAffectedRows(allow bool) SessionOption

func WithNoAutoTime

func WithNoAutoTime() SessionOption

WithNoAutoTime 仅作用在当前 session 若该 op 后接 WithTxSession 等其他从外部传入 session 的 op,则 WithNoAutoTime 不会在传入的 session 上生效 因此需要注意 op 顺序

func WithTxSession

func WithTxSession(_session *xorm.Session) SessionOption

Jump to

Keyboard shortcuts

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