config

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2019 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

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
		},
	},
}

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!

func SeedProjects

func SeedProjects(db *gorm.DB, projects []string) error

Returns a function to seed the database with default values.

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 ExecutionKey struct {
	Project string `gorm:"primary_key;column:execution_project"`
	Domain  string `gorm:"primary_key;column:execution_domain"`
	Name    string `gorm:"primary_key;column:execution_name"`
}

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"`
	// 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
	NodeExecutionKey
	// *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"`
}

type TaskKey

type TaskKey struct {
	Project string `gorm:"primary_key"`
	Domain  string `gorm:"primary_key"`
	Name    string `gorm:"primary_key"`
	Version string `gorm:"primary_key"`
}

Jump to

Keyboard shortcuts

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