Documentation ¶
Overview ¶
Package database provides the ability for Vela to integrate with different supported SQL backends.
Usage:
import "github.com/go-vela/server/database"
Index ¶
- Variables
- func ToContext(c Setter, d Interface)
- type EngineOpt
- func WithAddress(address string) EngineOpt
- func WithCompressionLevel(level int) EngineOpt
- func WithConnectionIdle(connectionIdle int) EngineOpt
- func WithConnectionLife(connectionLife time.Duration) EngineOpt
- func WithConnectionOpen(connectionOpen int) EngineOpt
- func WithContext(ctx context.Context) EngineOpt
- func WithDriver(driver string) EngineOpt
- func WithEncryptionKey(encryptionKey string) EngineOpt
- func WithLogLevel(logLevel string) EngineOpt
- func WithLogShowSQL(logShowSQL bool) EngineOpt
- func WithLogSkipNotFound(logSkipNotFound bool) EngineOpt
- func WithLogSlowThreshold(logSlowThreshold time.Duration) EngineOpt
- func WithSkipCreation(skipCreation bool) EngineOpt
- type GormLogger
- func (l *GormLogger) Error(ctx context.Context, msg string, args ...interface{})
- func (l *GormLogger) Info(ctx context.Context, msg string, args ...interface{})
- func (l *GormLogger) LogMode(logger.LogLevel) logger.Interface
- func (l *GormLogger) Trace(ctx context.Context, begin time.Time, fc func() (string, int64), err error)
- func (l *GormLogger) Warn(ctx context.Context, msg string, args ...interface{})
- type Interface
- type Setter
Constants ¶
This section is empty.
Variables ¶
var Flags = []cli.Flag{ &cli.StringFlag{ EnvVars: []string{"VELA_DATABASE_DRIVER", "DATABASE_DRIVER"}, FilePath: "/vela/database/driver", Name: "database.driver", Usage: "driver to be used for the database system", Value: "sqlite3", }, &cli.StringFlag{ EnvVars: []string{"VELA_DATABASE_ADDR", "DATABASE_ADDR"}, FilePath: "/vela/database/addr", Name: "database.addr", Usage: "fully qualified url (<scheme>://<host>) for the database", Value: "vela.sqlite", }, &cli.IntFlag{ EnvVars: []string{"VELA_DATABASE_CONNECTION_OPEN", "DATABASE_CONNECTION_OPEN"}, FilePath: "/vela/database/connection_open", Name: "database.connection.open", Usage: "maximum number of open connections to the database", Value: 0, }, &cli.IntFlag{ EnvVars: []string{"VELA_DATABASE_CONNECTION_IDLE", "DATABASE_CONNECTION_IDLE"}, FilePath: "/vela/database/connection_idle", Name: "database.connection.idle", Usage: "maximum number of idle connections to the database", Value: 2, }, &cli.DurationFlag{ EnvVars: []string{"VELA_DATABASE_CONNECTION_LIFE", "DATABASE_CONNECTION_LIFE"}, FilePath: "/vela/database/connection_life", Name: "database.connection.life", Usage: "duration of time a connection may be reused for the database", Value: 30 * time.Minute, }, &cli.IntFlag{ EnvVars: []string{"VELA_DATABASE_COMPRESSION_LEVEL", "DATABASE_COMPRESSION_LEVEL"}, FilePath: "/vela/database/compression_level", Name: "database.compression.level", Usage: "level of compression for logs stored in the database", Value: constants.CompressionThree, }, &cli.StringFlag{ EnvVars: []string{"VELA_DATABASE_ENCRYPTION_KEY", "DATABASE_ENCRYPTION_KEY"}, FilePath: "/vela/database/encryption_key", Name: "database.encryption.key", Usage: "AES-256 key for encrypting and decrypting values in the database", }, &cli.StringFlag{ EnvVars: []string{"VELA_DATABASE_LOG_LEVEL", "DATABASE_LOG_LEVEL"}, FilePath: "/vela/database/log_level", Name: "database.log.level", Usage: "set log level - options: (trace|debug|info|warn|error|fatal|panic)", Value: "warn", }, &cli.BoolFlag{ EnvVars: []string{"VELA_DATABASE_LOG_SHOW_SQL", "DATABASE_LOG_SHOW_SQL"}, FilePath: "/vela/database/log_show_sql", Name: "database.log.show_sql", Usage: "show the SQL query in the logs", }, &cli.BoolFlag{ EnvVars: []string{"VELA_DATABASE_LOG_SKIP_NOTFOUND", "DATABASE_LOG_SKIP_NOTFOUND"}, FilePath: "/vela/database/log_skip_notfound", Name: "database.log.skip_notfound", Usage: "skip logging when a resource is not found in the database", Value: true, }, &cli.DurationFlag{ EnvVars: []string{"VELA_DATABASE_LOG_SLOW_THRESHOLD", "DATABASE_LOG_SLOW_THRESHOLD"}, FilePath: "/vela/database/log_slow_threshold", Name: "database.log.slow_threshold", Usage: "queries that take longer than this threshold are considered slow and will be logged", Value: 200 * time.Millisecond, }, &cli.BoolFlag{ EnvVars: []string{"VELA_DATABASE_SKIP_CREATION", "DATABASE_SKIP_CREATION"}, FilePath: "/vela/database/skip_creation", Name: "database.skip_creation", Usage: "enables skipping the creation of tables and indexes in the database", }, }
Flags represents all supported command line interface (CLI) flags for the database.
Functions ¶
Types ¶
type EngineOpt ¶ added in v0.20.0
type EngineOpt func(*engine) error
EngineOpt represents a configuration option to initialize the database engine.
func WithAddress ¶ added in v0.20.0
WithAddress sets the address in the database engine.
func WithCompressionLevel ¶ added in v0.20.0
WithCompressionLevel sets the compression level in the database engine.
func WithConnectionIdle ¶ added in v0.20.0
WithConnectionIdle sets the idle connections in the database engine.
func WithConnectionLife ¶ added in v0.20.0
WithConnectionLife sets the life of connections in the database engine.
func WithConnectionOpen ¶ added in v0.20.0
WithConnectionOpen sets the open connections in the database engine.
func WithContext ¶ added in v0.21.0
WithContext sets the context in the database engine.
func WithDriver ¶ added in v0.20.0
WithDriver sets the driver in the database engine.
func WithEncryptionKey ¶ added in v0.20.0
WithEncryptionKey sets the encryption key in the database engine.
func WithLogLevel ¶ added in v0.24.0
WithLogLevel sets the log level in the database engine.
func WithLogShowSQL ¶ added in v0.24.0
WithLogShowSQL sets the log show SQL option in the database engine.
func WithLogSkipNotFound ¶ added in v0.24.0
WithLogSkipNotFound sets the log skip not found option in the database engine.
func WithLogSlowThreshold ¶ added in v0.24.0
WithLogSlowThreshold sets the log slow query threshold in the database engine.
func WithSkipCreation ¶ added in v0.20.0
WithSkipCreation sets the skip creation logic in the database engine.
type GormLogger ¶ added in v0.24.0
type GormLogger struct {
// contains filtered or unexported fields
}
GormLogger is a custom logger for Gorm.
func NewGormLogger ¶ added in v0.24.0
func NewGormLogger(logger *logrus.Entry, slowThreshold time.Duration, skipNotFound, showSQL bool) *GormLogger
NewGormLogger creates a new Gorm logger.
func (*GormLogger) Error ¶ added in v0.24.0
func (l *GormLogger) Error(ctx context.Context, msg string, args ...interface{})
Error implements the logger.Interface.
func (*GormLogger) Info ¶ added in v0.24.0
func (l *GormLogger) Info(ctx context.Context, msg string, args ...interface{})
Info implements the logger.Interface.
func (*GormLogger) LogMode ¶ added in v0.24.0
func (l *GormLogger) LogMode(logger.LogLevel) logger.Interface
LogMode sets the log mode for the logger.
type Interface ¶ added in v0.20.0
type Interface interface { // Close defines a function that stops and terminates the connection to the database. Close() error // Driver defines a function that outputs the configured database driver. Driver() string // Ping defines a function that sends a "ping" request to the configured database. Ping() error // SettingsInterface defines the interface for platform settings stored in the database. settings.SettingsInterface // BuildInterface defines the interface for builds stored in the database. build.BuildInterface // BuildExecutableInterface defines the interface for build executables stored in the database. executable.BuildExecutableInterface // DashboardInterface defines the interface for builds store in the database. dashboard.DashboardInterface // DeploymentInterface defines the interface for deployments stored in the database. deployment.DeploymentInterface // HookInterface defines the interface for hooks stored in the database. hook.HookInterface // JWKInterface defines the interface for JWKs stored in the database. jwk.JWKInterface // LogInterface defines the interface for logs stored in the database. log.LogInterface // PipelineInterface defines the interface for pipelines stored in the database. pipeline.PipelineInterface // RepoInterface defines the interface for repos stored in the database. repo.RepoInterface // ScheduleInterface defines the interface for schedules stored in the database. schedule.ScheduleInterface // SecretInterface defines the interface for secrets stored in the database. secret.SecretInterface // ServiceInterface defines the interface for services stored in the database. service.ServiceInterface // StepInterface defines the interface for steps stored in the database. step.StepInterface // UserInterface defines the interface for users stored in the database. user.UserInterface // WorkerInterface defines the interface for workers stored in the database. worker.WorkerInterface }
Interface represents the interface for integrating with the supported database providers.
func FromCLIContext ¶ added in v0.20.0
FromCLIContext creates and returns a database engine from the urfave/cli context.
func FromContext ¶
FromContext returns the database Interface associated with this context.