clickhouse

package
v0.11.2 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2025 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PipelinesTable              string = "pipelines"
	JobsTable                   string = "jobs"
	SectionsTable               string = "sections"
	BridgesTable                string = "bridges"
	TestReportsTable            string = "testreports"
	TestSuitesTable             string = "testsuites"
	TestCasesTable              string = "testcases"
	MergeRequestsTable          string = "mergerequests"
	MergeRequestNoteEventsTable string = "mergerequest_noteevents"
	MetricsTable                string = "metrics"
	ProjectsTable               string = "projects"
	TraceSpansTable             string = "traces"
	DeploymentsTable            string = "deployments"
)

Variables

View Source
var (
	ErrMigrateNoChange   = migrate.ErrNoChange
	ErrMigrateNilVersion = migrate.ErrNilVersion
)

Functions

func ClientOptions added in v0.6.1

func ClientOptions(cfg ClientConfig) clickhouse.Options

func Connect added in v0.6.1

func Connect(options *clickhouse.Options) (driver.Conn, error)

func DeduplicateTable

func DeduplicateTable(ctx context.Context, opt DeduplicateTableOptions, ch *Client) error

func GetLatestMigrationVersion added in v0.7.0

func GetLatestMigrationVersion(fsys fs.FS, path string) (uint, error)

func GetSchemaVersion added in v0.7.0

func GetSchemaVersion(c *Client, ctx context.Context) (uint, bool, error)

func InsertBridges

func InsertBridges(c *Client, ctx context.Context, bridges []*typespb.Job) (int, error)

func InsertDeployments added in v0.11.0

func InsertDeployments(c *Client, ctx context.Context, deployments []*typespb.Deployment) (int, error)

func InsertJobs

func InsertJobs(c *Client, ctx context.Context, jobs []*typespb.Job) (int, error)

func InsertMergeRequestNoteEvents added in v0.8.0

func InsertMergeRequestNoteEvents(c *Client, ctx context.Context, mres []*typespb.MergeRequestNoteEvent) (int, error)

func InsertMergeRequests added in v0.7.0

func InsertMergeRequests(c *Client, ctx context.Context, mrs []*typespb.MergeRequest) (int, error)

func InsertMetrics

func InsertMetrics(c *Client, ctx context.Context, metrics []*typespb.Metric) (int, error)

func InsertPipelines

func InsertPipelines(c *Client, ctx context.Context, pipelines []*typespb.Pipeline) (int, error)

func InsertProjects added in v0.7.0

func InsertProjects(c *Client, ctx context.Context, projects []*typespb.Project) (int, error)

func InsertSections

func InsertSections(c *Client, ctx context.Context, sections []*typespb.Section) (int, error)

func InsertTestCases

func InsertTestCases(c *Client, ctx context.Context, cases []*typespb.TestCase) (int, error)

func InsertTestReports

func InsertTestReports(c *Client, ctx context.Context, reports []*typespb.TestReport) (int, error)

func InsertTestSuites

func InsertTestSuites(c *Client, ctx context.Context, suites []*typespb.TestSuite) (int, error)

func InsertTraces

func InsertTraces(c *Client, ctx context.Context, traces []*typespb.Trace) (int, error)

func MigrateDown added in v0.10.0

func MigrateDown(opts MigrationOptions) error

func MigrateUp added in v0.7.0

func MigrateUp(opts MigrationOptions) error

func NewMigration added in v0.7.0

func NewMigration(opts MigrationOptions) (*migrate.Migrate, error)

func PrepareDeduplicateQuery

func PrepareDeduplicateQuery(opt DeduplicateTableOptions) (string, map[string]string)

func SelectPipelineMaxUpdatedAt

func SelectPipelineMaxUpdatedAt(c *Client, ctx context.Context) (map[int64]float64, error)

func SelectTableIDLastestUpdates added in v0.7.0

func SelectTableIDLastestUpdates(c *Client, ctx context.Context, table string, idColumn string, updatedAtColumn string) (map[int64]float64, error)

func SelectTableIDs

func SelectTableIDs[T int64 | string](c *Client, ctx context.Context, table string, column string) (map[T]struct{}, error)

func SelectTraceSpanIDs

func SelectTraceSpanIDs(c *Client, ctx context.Context) (map[string]struct{}, error)

func WithParameters

func WithParameters(ctx context.Context, params map[string]string) context.Context

Types

type Client

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

func NewClient

func NewClient(conn driver.Conn, database string) *Client

func (*Client) Exec

func (c *Client) Exec(ctx context.Context, query string, args ...any) error

func (*Client) Ping

func (c *Client) Ping(ctx context.Context) error

func (*Client) PrepareBatch

func (c *Client) PrepareBatch(ctx context.Context, query string) (driver.Batch, error)

func (*Client) Select

func (c *Client) Select(ctx context.Context, dest any, query string, args ...any) error

func (*Client) SetMaxConcurrentQueries added in v0.9.0

func (c *Client) SetMaxConcurrentQueries(n int64)

type ClientConfig

type ClientConfig struct {
	Host     string
	Port     string
	Database string
	User     string
	Password string
}

type DeduplicateTableOptions

type DeduplicateTableOptions struct {
	Database    string
	Table       string
	Final       *bool
	By          []string
	Except      []string
	ThrowIfNoop *bool
}

type Deployment added in v0.11.0

type Deployment struct {
	Id  int64 `ch:"id"`
	Iid int64 `ch:"iid"`

	EnvironmentId   int64  `ch:"environment_id"`
	EnvironmentName string `ch:"environment_name"`
	EnvironmentTier string `ch:"environment_tier"`

	ProjectId int64 `ch:"project_id"`

	JobId      int64 `ch:"job_id"`
	PipelineId int64 `ch:"pipeline_id"`

	TriggererId       int64  `ch:"triggerer_id"`
	TriggererUsername string `ch:"triggerer_username"`
	TriggererName     string `ch:"triggerer_name"`

	CreatedAt  float64 `ch:"created_at"`
	FinishedAt float64 `ch:"finished_at"`
	UpdatedAt  float64 `ch:"updated_at"`

	Status string `ch:"status"`
	Ref    string `ch:"ref"`
	Sha    string `ch:"sha"`
}

type Job added in v0.10.0

type Job struct {
	Id         int64 `ch:"id"`
	PipelineId int64 `ch:"pipeline_id"`
	ProjectId  int64 `ch:"project_id"`

	Name          string `ch:"name"`
	Ref           string `ch:"ref"`
	Status        string `ch:"status"`
	FailureReason string `ch:"failure_reason"`

	CreatedAt  float64 `ch:"created_at"`
	QueuedAt   float64 `ch:"queued_at"`
	StartedAt  float64 `ch:"started_at"`
	FinishedAt float64 `ch:"finished_at"`
	ErasedAt   float64 `ch:"erased_at"`

	QueuedDuration float64 `ch:"queued_duration"`
	Duration       float64 `ch:"duration"`

	Coverage float64 `ch:"coverage"`

	Stage   string   `ch:"stage"`
	TagList []string `ch:"tag_list"`

	AllowFailure bool `ch:"allow_failure"`
	Manual       bool `ch:"manual"`
	Retried      bool `ch:"retried"`
	Retryable    bool `ch:"retryable"`

	Kind                        string `ch:"kind"`
	DownstreamPipelineId        int64  `ch:"downstream_pipeline_id"`
	DownstreamPipelineIid       int64  `ch:"downstream_pipeline_iid"`
	DownstreamPipelineProjectId int64  `ch:"downstream_pipeline_project_id"`

	RunnerId string `ch:"runner_id"`

	// deprecated
	Pipeline []any `ch:"pipeline"` // Tuple(id Int64, project_id Int64, ref String, sha String, status String)
}

type MergeRequest added in v0.10.0

type MergeRequest struct {
	Id        int64 `ch:"id"`
	Iid       int64 `ch:"iid"`
	ProjectId int64 `ch:"project_id"`

	CreatedAt float64 `ch:"created_at"`
	UpdatedAt float64 `ch:"updated_at"`
	MergedAt  float64 `ch:"merged_at"`
	ClosedAt  float64 `ch:"closed_at"`

	Name   string   `ch:"name"`
	Title  string   `ch:"title"`
	Labels []string `ch:"labels"`

	State       string `ch:"state"`
	MergeStatus string `ch:"merge_status"`
	MergeError  string `ch:"merge_error"`

	SourceProjectId int64  `ch:"source_project_id"`
	SourceBranch    string `ch:"source_branch"`
	TargetProjectId int64  `ch:"target_project_id"`
	TargetBranch    string `ch:"target_branch"`

	Additions   int64 `ch:"additions"`
	Changes     int64 `ch:"changes"`
	Deletions   int64 `ch:"deletions"`
	FileCount   int64 `ch:"file_count"`
	CommitCount int64 `ch:"commit_count"`

	BaseSha         string `ch:"base_sha"`
	HeadSha         string `ch:"head_sha"`
	StartSha        string `ch:"start_sha"`
	MergeCommitSha  string `ch:"merge_commit_sha"`
	RebaseCommitSha string `ch:"rebase_commit_sha"`

	AuthorId          int64    `ch:"author_id"`
	AuthorUsername    string   `ch:"author_username"`
	AuthorName        string   `ch:"author_name"`
	AssigneesId       []int64  `ch:"assignees_id"`
	AssigneesUsername []string `ch:"assignees_username"`
	AssigneesName     []string `ch:"assignees_name"`
	ReviewersId       []int64  `ch:"reviewers_id"`
	ReviewersUsername []string `ch:"reviewers_username"`
	ReviewersName     []string `ch:"reviewers_name"`
	ApproversId       []int64  `ch:"approvers_id"`
	ApproversUsername []string `ch:"approvers_username"`
	ApproversName     []string `ch:"approvers_name"`
	MergeUserId       int64    `ch:"merge_user_id"`
	MergeUserUsername string   `ch:"merge_user_username"`
	MergeUserName     string   `ch:"merge_user_name"`

	Approved  bool `ch:"approved"`
	Conflicts bool `ch:"conflicts"`
	Draft     bool `ch:"draft"`
	Mergeable bool `ch:"mergeable"`

	MilestoneId        int64 `ch:"milestone_id"`
	MilestoneIid       int64 `ch:"milestone_iid"`
	MilestoneProjectId int64 `ch:"milestone_project_id"`
}

type MergeRequestNoteEvent added in v0.10.0

type MergeRequestNoteEvent struct {
	Id                    int64 `ch:"id"`
	MergeRequestId        int64 `ch:"mergerequest_id"`
	MergeRequestIid       int64 `ch:"mergerequest_iid"`
	MergeRequestProjectId int64 `ch:"mergerequest_project_id"`

	CreatedAt  float64 `ch:"created_at"`
	UpdatedAt  float64 `ch:"updated_at"`
	ResolvedAt float64 `ch:"resolved_at"`

	Type     string `ch:"type"`
	System   bool   `ch:"system"`
	Internal bool   `ch:"internal"`

	AuthorId       int64  `ch:"author_id"`
	AuthorUsername string `ch:"author_username"`
	AuthorName     string `ch:"author_name"`

	Resolvable       bool   `ch:"resolvable"`
	Resolved         bool   `ch:"resolved"`
	ResolverId       int64  `ch:"resolver_id"`
	ResolverUsername string `ch:"resolver_username"`
	ResolverName     string `ch:"resolver_name"`
}

type Metric added in v0.10.0

type Metric struct {
	Id         string `ch:"id"`
	Iid        int64  `ch:"iid"`
	JobId      int64  `ch:"job_id"`
	PipelineId int64  `ch:"pipeline_id"`
	ProjectId  int64  `ch:"project_id"`

	Name      string            `ch:"name"`
	Labels    map[string]string `ch:"labels"`
	Value     float64           `ch:"value"`
	Timestamp int64             `ch:"timestamp"`
}

type MigrationOptions added in v0.7.0

type MigrationOptions struct {
	ClientConfig

	FileSystem fs.FS
	Path       string
}

type Pipeline added in v0.10.0

type Pipeline struct {
	Id        int64 `ch:"id"`
	Iid       int64 `ch:"iid"`
	ProjectId int64 `ch:"project_id"`

	Name          string `ch:"name"`
	Ref           string `ch:"ref"`
	Sha           string `ch:"sha"`
	Source        string `ch:"source"`
	Status        string `ch:"status"`
	FailureReason string `ch:"failure_reason"`

	CommittedAt float64 `ch:"committed_at"`
	CreatedAt   float64 `ch:"created_at"`
	UpdatedAt   float64 `ch:"updated_at"`
	StartedAt   float64 `ch:"started_at"`
	FinishedAt  float64 `ch:"finished_at"`

	QueuedDuration float64 `ch:"queued_duration"`
	Duration       float64 `ch:"duration"`

	Coverage float64 `ch:"coverage"`

	Warnings   bool `ch:"warnings"`
	YamlErrors bool `ch:"yaml_errors"`

	Child                     bool  `ch:"child"`
	UpstreamPipelineId        int64 `ch:"upstream_pipeline_id"`
	UpstreamPipelineIid       int64 `ch:"upstream_pipeline_iid"`
	UpstreamPipelineProjectId int64 `ch:"upstream_pipeline_project_id"`

	MergeRequestId        int64 `ch:"merge_request_id"`
	MergeRequestIid       int64 `ch:"merge_request_iid"`
	MergeRequestProjectId int64 `ch:"merge_request_project_id"`

	UserId int64 `ch:"user_id"`
}

type Project added in v0.10.0

type Project struct {
	Id          int64 `ch:"id"`
	NamespaceId int64 `ch:"namespace_id"`

	Name     string `ch:"name"`
	FullName string `ch:"full_name"`
	Path     string `ch:"path"`
	FullPath string `ch:"full_path"`

	Description string   `ch:"description"`
	Topics      []string `ch:"topics"`

	CreatedAt      float64 `ch:"created_at"`
	UpdatedAt      float64 `ch:"updated_at"`
	LastActivityAt float64 `ch:"last_activity_at"`

	JobArtifactsSize      int64 `ch:"job_artifacts_size"`
	ContainerRegistrySize int64 `ch:"container_registry_size"`
	LfsObjectsSize        int64 `ch:"lfs_objects_size"`
	PackagesSize          int64 `ch:"packages_size"`
	PipelineArtifactsSize int64 `ch:"pipeline_artifacts_size"`
	RepositorySize        int64 `ch:"repository_size"`
	SnippetsSize          int64 `ch:"snippets_size"`
	StorageSize           int64 `ch:"storage_size"`
	UploadsSize           int64 `ch:"uploads_size"`
	WikiSize              int64 `ch:"wiki_size"`

	ForksCount      int64 `ch:"forks_count"`
	StarsCount      int64 `ch:"stars_count"`
	CommitCount     int64 `ch:"commit_count"`
	OpenIssuesCount int64 `ch:"open_issues_count"`

	Archived   bool   `ch:"archived"`
	Visibility string `ch:"visibility"`
}

type Section added in v0.10.0

type Section struct {
	Id         int64 `ch:"id"`
	JobId      int64 `ch:"job_id"`
	PipelineId int64 `ch:"pipeline_id"`
	ProjectId  int64 `ch:"project_id"`

	Name string `ch:"name"`

	StartedAt  float64 `ch:"started_at"`
	FinishedAt float64 `ch:"finished_at"`

	Duration float64 `ch:"duration"`

	// deprecated
	Job      []any `ch:"job"`      // Tuple(id Int64, name String, status String)
	Pipeline []any `ch:"pipeline"` // Tuple(id Int64, project_id Int64, ref String, sha String, status String)
}

type TestCase added in v0.10.0

type TestCase struct {
	Id           string `ch:"id"`
	TestSuiteId  string `ch:"testsuite_id"`
	TestReportId string `ch:"testreport_id"`
	JobId        int64  `ch:"job_id"`
	PipelineId   int64  `ch:"pipeline_id"`
	ProjectId    int64  `ch:"project_id"`

	Status        string  `ch:"status"`
	Name          string  `ch:"name"`
	Classname     string  `ch:"classname"`
	File          string  `ch:"file"`
	ExecutionTime float64 `ch:"execution_time"`
	SystemOutput  string  `ch:"system_output"`
	AttachmentUrl string  `ch:"attachment_url"`

	Properties [][]string `ch:"properties"`
}

type TestReport added in v0.10.0

type TestReport struct {
	Id         string `ch:"id"`
	JobId      int64  `ch:"job_id"`
	PipelineId int64  `ch:"pipeline_id"`
	ProjectId  int64  `ch:"project_id"`

	TotalTime    float64 `ch:"total_time"`
	TotalCount   int64   `ch:"total_count"`
	ErrorCount   int64   `ch:"error_count"`
	FailedCount  int64   `ch:"failed_count"`
	SkippedCount int64   `ch:"skipped_count"`
	SuccessCount int64   `ch:"success_count"`
}

type TestSuite added in v0.10.0

type TestSuite struct {
	Id           string `ch:"id"`
	TestReportId string `ch:"testreport_id"`
	JobId        int64  `ch:"job_id"`
	PipelineId   int64  `ch:"pipeline_id"`
	ProjectId    int64  `ch:"project_id"`

	Name         string  `ch:"name"`
	TotalTime    float64 `ch:"total_time"`
	TotalCount   int64   `ch:"total_count"`
	ErrorCount   int64   `ch:"error_count"`
	FailedCount  int64   `ch:"failed_count"`
	SkippedCount int64   `ch:"skipped_count"`
	SuccessCount int64   `ch:"success_count"`

	Properties [][]string `ch:"properties"`
}

Jump to

Keyboard shortcuts

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