Documentation
¶
Index ¶
- Constants
- type CleanupResult
- type Engine
- func (e *Engine) CleanLogs(ctx context.Context, before int64, batchSize int, withVacuum bool, ...) (*CleanupResult, error)
- func (e *Engine) CountLogs(ctx context.Context) (int64, error)
- func (e *Engine) CountLogsForBuild(ctx context.Context, b *api.Build) (int64, error)
- func (e *Engine) CreateLog(ctx context.Context, l *api.Log) error
- func (e *Engine) CreateLogIndexes(ctx context.Context) error
- func (e *Engine) CreateLogTable(ctx context.Context, driver string) error
- func (e *Engine) DeleteLog(ctx context.Context, l *api.Log) error
- func (e *Engine) GetLog(ctx context.Context, id int64) (*api.Log, error)
- func (e *Engine) GetLogForService(ctx context.Context, s *api.Service) (*api.Log, error)
- func (e *Engine) GetLogForStep(ctx context.Context, s *api.Step) (*api.Log, error)
- func (e *Engine) ListLogs(ctx context.Context) ([]*api.Log, error)
- func (e *Engine) ListLogsForBuild(ctx context.Context, b *api.Build, page, perPage int) ([]*api.Log, error)
- func (e *Engine) UpdateLog(ctx context.Context, l *api.Log) error
- type EngineOpt
- func WithClient(client *gorm.DB) EngineOpt
- func WithCompressionLevel(level int) EngineOpt
- func WithContext(ctx context.Context) EngineOpt
- func WithLogPartitionPattern(pattern string) EngineOpt
- func WithLogPartitionSchema(schema string) EngineOpt
- func WithLogPartitioned(partitioned bool) EngineOpt
- func WithLogger(logger *logrus.Entry) EngineOpt
- func WithSkipCreation(skipCreation bool) EngineOpt
- type LogInterface
Constants ¶
const ( // CreateBuildIDIndex represents a query to create an // index on the logs table for the build_id column. CreateBuildIDIndex = ` CREATE INDEX IF NOT EXISTS logs_build_id ON logs (build_id); ` // CreateCreatedAtIndex represents a query to create an // index on the logs table for the created_at column. CreateCreatedAtIndex = ` CREATE INDEX IF NOT EXISTS logs_created_at ON logs (created_at); ` )
const ( // CreatePostgresTable represents a query to create the Postgres logs table. CreatePostgresTable = `` /* 251-byte string literal not displayed */ // CreateSqliteTable represents a query to create the Sqlite logs table. CreateSqliteTable = `` /* 267-byte string literal not displayed */ )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CleanupResult ¶ added in v0.27.0
CleanupResult represents the result of a log cleanup operation.
type Engine ¶ added in v0.27.0
type Engine struct {
// contains filtered or unexported fields
}
Engine represents the log functionality that implements the LogInterface interface.
func (*Engine) CleanLogs ¶ added in v0.27.0
func (e *Engine) CleanLogs(ctx context.Context, before int64, batchSize int, withVacuum bool, driver string) (*CleanupResult, error)
CleanLogs deletes log records created before the specified timestamp in batches. This function processes deletions in configurable batches with sleep intervals to reduce database load and prevent timeouts on large datasets. It uses a database-based lock to prevent multiple concurrent cleanup operations. If partitioned mode is enabled and the database is PostgreSQL, it will use partition-aware cleanup for better performance.
func (*Engine) CountLogsForBuild ¶ added in v0.27.0
CountLogsForBuild gets the count of logs by build ID from the database.
func (*Engine) CreateLogIndexes ¶ added in v0.27.0
CreateLogIndexes creates the indexes for the logs table in the database.
func (*Engine) CreateLogTable ¶ added in v0.27.0
CreateLogTable creates the logs table in the database.
func (*Engine) GetLogForService ¶ added in v0.27.0
GetLogForService gets a log by service ID from the database.
func (*Engine) GetLogForStep ¶ added in v0.27.0
GetLogForStep gets a log by step ID from the database.
type EngineOpt ¶
EngineOpt represents a configuration option to initialize the database engine for Logs.
func WithClient ¶
WithClient sets the gorm.io/gorm client in the database engine for Logs.
func WithCompressionLevel ¶
WithCompressionLevel sets the compression level in the database engine for Logs.
func WithContext ¶ added in v0.21.0
WithContext sets the context in the database engine for Logs.
func WithLogPartitionPattern ¶ added in v0.27.0
WithLogPartitionPattern sets the log partition pattern in the log engine.
func WithLogPartitionSchema ¶ added in v0.27.0
WithLogPartitionSchema sets the log partition schema in the log engine.
func WithLogPartitioned ¶ added in v0.27.0
WithLogPartitioned sets the log partitioned flag in the log engine.
func WithLogger ¶
WithLogger sets the github.com/sirupsen/logrus logger in the database engine for Logs.
func WithSkipCreation ¶
WithSkipCreation sets the skip creation logic in the database engine for Logs.
type LogInterface ¶ added in v0.20.0
type LogInterface interface {
// CreateLogIndexes defines a function that creates the indexes for the logs table.
CreateLogIndexes(context.Context) error
// CreateLogTable defines a function that creates the logs table.
CreateLogTable(context.Context, string) error
// CountLogs defines a function that gets the count of all logs.
CountLogs(context.Context) (int64, error)
// CountLogsForBuild defines a function that gets the count of logs by build ID.
CountLogsForBuild(context.Context, *api.Build) (int64, error)
// CreateLog defines a function that creates a new log.
CreateLog(context.Context, *api.Log) error
// DeleteLog defines a function that deletes an existing log.
DeleteLog(context.Context, *api.Log) error
// GetLog defines a function that gets a log by ID.
GetLog(context.Context, int64) (*api.Log, error)
// GetLogForService defines a function that gets a log by service ID.
GetLogForService(context.Context, *api.Service) (*api.Log, error)
// GetLogForStep defines a function that gets a log by step ID.
GetLogForStep(context.Context, *api.Step) (*api.Log, error)
// ListLogs defines a function that gets a list of all logs.
ListLogs(context.Context) ([]*api.Log, error)
// ListLogsForBuild defines a function that gets a list of logs by build ID.
ListLogsForBuild(context.Context, *api.Build, int, int) ([]*api.Log, error)
// UpdateLog defines a function that updates an existing log.
UpdateLog(context.Context, *api.Log) error
// CleanLogs defines a function that deletes logs older than a specified timestamp in batches.
CleanLogs(context.Context, int64, int, bool, string) (*CleanupResult, error)
}