Documentation ¶
Index ¶
- Constants
- Variables
- func OpenDbConnection(config DbConnectionConfigProvider) *gorm.DB
- func SeedProjects(db *gorm.DB, projects []string) error
- type BaseConfig
- type DbConfig
- type DbConnectionConfigProvider
- type ExecutionKey
- type NodeExecution
- type NodeExecutionKey
- type PostgresConfigProvider
- type TaskExecution
- type TaskExecutionKey
- type TaskKey
Constants ¶
View Source
const Postgres = "postgres"
Variables ¶
View Source
var Migrations = []*gormigrate.Migration{ { ID: "2019-05-22-projects", Migrate: func(tx *gorm.DB) error { return tx.AutoMigrate(&models.Project{}).Error }, Rollback: func(tx *gorm.DB) error { return tx.DropTable("projects").Error }, }, { ID: "2018-05-23-tasks", Migrate: func(tx *gorm.DB) error { return tx.AutoMigrate(&models.Task{}).Error }, Rollback: func(tx *gorm.DB) error { return tx.DropTable("tasks").Error }, }, { ID: "2018-05-23-workflows", Migrate: func(tx *gorm.DB) error { return tx.AutoMigrate(&models.Workflow{}).Error }, Rollback: func(tx *gorm.DB) error { return tx.DropTable("workflows").Error }, }, { ID: "2019-05-23-lp", Migrate: func(tx *gorm.DB) error { return tx.AutoMigrate(&models.LaunchPlan{}).Error }, Rollback: func(tx *gorm.DB) error { return tx.DropTable("launch_plans").Error }, }, { ID: "2019-05-23-executions", Migrate: func(tx *gorm.DB) error { return tx.AutoMigrate(&models.Execution{}).Error }, Rollback: func(tx *gorm.DB) error { return tx.DropTable("executions").Error }, }, { ID: "2019-01-29-executions-events", Migrate: func(tx *gorm.DB) error { return tx.AutoMigrate(&models.ExecutionEvent{}).Error }, Rollback: func(tx *gorm.DB) error { return tx.DropTable("executions_events").Error }, }, { ID: "2019-04-17-node-executions", Migrate: func(tx *gorm.DB) error { return tx.AutoMigrate(&NodeExecution{}).Error }, Rollback: func(tx *gorm.DB) error { return tx.DropTable("node_executions").Error }, }, { ID: "2019-01-29-node-executions-events", Migrate: func(tx *gorm.DB) error { return tx.AutoMigrate(&models.NodeExecutionEvent{}).Error }, Rollback: func(tx *gorm.DB) error { return tx.DropTable("node_executions_events").Error }, }, { ID: "2019-03-16-task-executions", Migrate: func(tx *gorm.DB) error { return tx.AutoMigrate(&TaskExecution{}).Error }, Rollback: func(tx *gorm.DB) error { return tx.DropTable("task_executions").Error }, }, { ID: "2019-04-17-node-executions-backfill", Migrate: func(tx *gorm.DB) error { return tx.Exec("update node_executions set parent_task_execution_id = NULL where parent_task_execution_id = 0").Error }, }, { ID: "2019-09-27-executions", Migrate: func(tx *gorm.DB) error { return tx.AutoMigrate(&models.Execution{}).Error }, Rollback: func(tx *gorm.DB) error { return tx.Exec("ALTER TABLE executions DROP COLUMN IF EXISTS cluster").Error }, }, { ID: "2019-10-09-project-description", Migrate: func(tx *gorm.DB) error { return tx.AutoMigrate(&models.Project{}).Error }, Rollback: func(tx *gorm.DB) error { return tx.Exec("ALTER TABLE projects DROP COLUMN IF EXISTS description").Error }, }, { ID: "2019-10-15-offload-inputs", Migrate: func(tx *gorm.DB) error { return tx.AutoMigrate(&models.Execution{}).Error }, Rollback: func(tx *gorm.DB) error { return tx.Exec("ALTER TABLE executions DROP COLUMN IF EXISTS InputsURI, DROP COLUMN IF EXISTS UserInputsURI").Error }, }, { ID: "2019-11-05-named-entity-metadata", Migrate: func(tx *gorm.DB) error { return tx.AutoMigrate(&models.NamedEntityMetadata{}).Error }, Rollback: func(tx *gorm.DB) error { return tx.DropTable("named_entity_metadata").Error }, }, { ID: "2020-01-10-resource", Migrate: func(tx *gorm.DB) error { return tx.AutoMigrate(&models.Resource{}).Error }, Rollback: func(tx *gorm.DB) error { return tx.DropTable("resources").Error }, }, { ID: "2020-03-17-task-type", Migrate: func(tx *gorm.DB) error { return tx.AutoMigrate(&models.Task{}).Error }, Rollback: func(tx *gorm.DB) error { return tx.Exec("ALTER TABLE tasks DROP COLUMN IF EXISTS type").Error }, }, { ID: "2020-04-03-named-entity-state", Migrate: func(tx *gorm.DB) error { return tx.AutoMigrate(&models.NamedEntityMetadata{}).Error }, Rollback: func(tx *gorm.DB) error { return tx.Table("named_entity_metadata").DropColumn("state").Error }, }, { ID: "2020-04-03-named-entity-state-default", Migrate: func(tx *gorm.DB) error { return tx.Exec("UPDATE named_entity_metadata SET state = 0").Error }, Rollback: func(tx *gorm.DB) error { return tx.Exec("UPDATE named_entity_metadata set state = NULL").Error }, }, { ID: "2020-04-03-workflow-state", Migrate: func(tx *gorm.DB) error { return tx.Exec("ALTER TABLE workflows DROP COLUMN IF EXISTS state").Error }, Rollback: func(tx *gorm.DB) error { return tx.Exec("ALTER TABLE workflows ADD COLUMN IF NOT EXISTS state integer;").Error }, }, { ID: "2020-04-29-executions", Migrate: func(tx *gorm.DB) error { return tx.AutoMigrate(&models.Execution{}, &models.NodeExecution{}).Error }, Rollback: func(tx *gorm.DB) error { if err := tx.Model(&models.Execution{}).DropColumn("error_code").DropColumn("error_kind").Error; err != nil { return err } return tx.Model(&models.NodeExecution{}).DropColumn("error_code").DropColumn("error_kind").Error }, }, { ID: "2020-04-14-task-type", Migrate: func(tx *gorm.DB) error { return tx.AutoMigrate(&models.Execution{}).Error }, Rollback: func(tx *gorm.DB) error { return tx.Exec("ALTER TABLE executions DROP COLUMN IF EXISTS task_id").Error }, }, { ID: "2020-07-27-cachestatus", Migrate: func(tx *gorm.DB) error { return tx.AutoMigrate(&models.NodeExecution{}).Error }, Rollback: func(tx *gorm.DB) error { return tx.Model(&models.NodeExecution{}).DropColumn("cache_status").Error }, }, { ID: "2020-07-31-node-execution", Migrate: func(tx *gorm.DB) error { return tx.AutoMigrate(&models.NodeExecution{}).Error }, Rollback: func(tx *gorm.DB) error { return tx.Model(&models.NodeExecution{}).DropColumn("parent_id").DropColumn("node_execution_metadata").Error }, }, { ID: "2020-08-13-node-execution", Migrate: func(tx *gorm.DB) error { return tx.AutoMigrate(&models.NodeExecution{}).Error }, Rollback: func(tx *gorm.DB) error { return tx.Model(&models.NodeExecution{}).DropColumn("parent_id").DropColumn("node_execution_metadata").Error }, }, { ID: "2020-08-17-labels-addition", Migrate: func(tx *gorm.DB) error { return tx.AutoMigrate(&models.Project{}).Error }, Rollback: func(tx *gorm.DB) error { return tx.Model(&models.Project{}).DropColumn("labels").Error }, }, { ID: "2020-09-01-task-exec-idx", Migrate: func(tx *gorm.DB) error { return tx.AutoMigrate(&TaskExecution{}).Error }, Rollback: func(tx *gorm.DB) error { return tx.Model(&TaskExecution{}).RemoveIndex("idx_task_executions_exec").Error }, }, { ID: "2020-11-03-project-state-addition", Migrate: func(tx *gorm.DB) error { return tx.AutoMigrate(&models.Project{}).Error }, Rollback: func(tx *gorm.DB) error { return tx.Model(&models.Project{}).DropColumn("state").Error }, }, { ID: "2020-11-03-project-state-default", Migrate: func(tx *gorm.DB) error { return tx.Exec("UPDATE projects set state = 0").Error }, Rollback: func(tx *gorm.DB) error { return tx.Exec("UPDATE projects set state = NULL").Error }, }, }
Functions ¶
func OpenDbConnection ¶
func OpenDbConnection(config DbConnectionConfigProvider) *gorm.DB
Opens a connection to the database specified in the config. You must call CloseDbConnection at the end of your session!
Types ¶
type BaseConfig ¶
type BaseConfig struct {
IsDebug bool
}
type DbConfig ¶
type DbConfig struct { BaseConfig Host string `json:"host"` Port int `json:"port"` DbName string `json:"dbname"` User string `json:"user"` Password string `json:"password"` ExtraOptions string `json:"options"` }
Database config. Contains values necessary to open a database connection.
type DbConnectionConfigProvider ¶
type DbConnectionConfigProvider interface { // Returns the database type. For instance PostgreSQL or MySQL. GetType() string // Returns arguments specific for the database type necessary to open a database connection. GetArgs() string // Enables verbose logging. WithDebugModeEnabled() // Disables verbose logging. WithDebugModeDisabled() // Returns whether verbose logging is enabled or not. IsDebug() bool }
Generic interface for providing a config necessary to open a database connection.
func NewPostgresConfigProvider ¶
func NewPostgresConfigProvider(config DbConfig, scope promutils.Scope) DbConnectionConfigProvider
TODO : Make the Config provider itself env based
type ExecutionKey ¶
type NodeExecution ¶
type NodeExecution struct { models.BaseModel NodeExecutionKey // Also stored in the closure, but defined as a separate column because it's useful for filtering and sorting. Phase string InputURI string Closure []byte StartedAt *time.Time // Corresponds to the CreatedAt field in the NodeExecution closure // Prefixed with NodeExecution to avoid clashes with gorm.Model CreatedAt NodeExecutionCreatedAt *time.Time // Corresponds to the UpdatedAt field in the NodeExecution closure // Prefixed with NodeExecution to avoid clashes with gorm.Model UpdatedAt NodeExecutionUpdatedAt *time.Time Duration time.Duration NodeExecutionEvents []models.NodeExecutionEvent // The task execution (if any) which launched this node execution. ParentTaskExecutionID uint `sql:"default:null" gorm:"index"` // The workflow execution (if any) which this node execution launched LaunchedExecution models.Execution `gorm:"foreignkey:ParentNodeExecutionID"` }
type NodeExecutionKey ¶
type NodeExecutionKey struct { ExecutionKey NodeID string `gorm:"primary_key;index"` }
type PostgresConfigProvider ¶
type PostgresConfigProvider struct {
// contains filtered or unexported fields
}
PostgreSQL implementation for DbConnectionConfigProvider.
func (*PostgresConfigProvider) GetArgs ¶
func (p *PostgresConfigProvider) GetArgs() string
func (*PostgresConfigProvider) GetType ¶
func (p *PostgresConfigProvider) GetType() string
func (*PostgresConfigProvider) IsDebug ¶
func (p *PostgresConfigProvider) IsDebug() bool
func (*PostgresConfigProvider) WithDebugModeDisabled ¶
func (p *PostgresConfigProvider) WithDebugModeDisabled()
func (*PostgresConfigProvider) WithDebugModeEnabled ¶
func (p *PostgresConfigProvider) WithDebugModeEnabled()
type TaskExecution ¶
type TaskExecution struct { models.BaseModel TaskExecutionKey Phase string PhaseVersion uint32 InputURI string Closure []byte StartedAt *time.Time // Corresponds to the CreatedAt field in the TaskExecution closure // This field is prefixed with TaskExecution because it signifies when // the execution was createdAt, not to be confused with gorm.Model.CreatedAt TaskExecutionCreatedAt *time.Time // Corresponds to the UpdatedAt field in the TaskExecution closure // This field is prefixed with TaskExecution because it signifies when // the execution was UpdatedAt, not to be confused with gorm.Model.UpdatedAt TaskExecutionUpdatedAt *time.Time Duration time.Duration // The child node executions (if any) launched by this task execution. ChildNodeExecution []NodeExecution `gorm:"foreignkey:ParentTaskExecutionID"` }
type TaskExecutionKey ¶
type TaskExecutionKey struct { TaskKey Project string `gorm:"primary_key;column:execution_project;index:idx_task_executions_exec"` Domain string `gorm:"primary_key;column:execution_domain;index:idx_task_executions_exec"` Name string `gorm:"primary_key;column:execution_name;index:idx_task_executions_exec"` NodeID string `gorm:"primary_key;index:idx_task_executions_exec;index"` // *IMPORTANT* This is a pointer to an int in order to allow setting an empty ("0") value according to gorm convention. // Because RetryAttempt is part of the TaskExecution primary key is should *never* be null. RetryAttempt *uint32 `gorm:"primary_key;AUTO_INCREMENT:FALSE"` }
Click to show internal directories.
Click to hide internal directories.