Documentation
¶
Overview ¶
Package postgres implementation relies on gorm for queries which is very very inefficient at the moment, we are trading convenience with performance for example in lot of select stmts, we pull all related relations as well even when we don't really need to, most of the times these relation queries even in update gets executed for no reason even if user didn't intend to update them.
Index ¶
- func Connect(dbConf config.DBConfig, writer io.Writer) (*gorm.DB, error)
- func InitTrace(db *gorm.DB) error
- func NewBackupRepository(db *gorm.DB) *backupRepository
- func NewJobDeploymentRepository(db *gorm.DB) *jobDeploymentRepository
- func NewJobSourceRepository(db *gorm.DB) store.JobSourceRepository
- func NewJobSpecRepository(db *gorm.DB, adapter *JobSpecAdapter) (store.JobSpecRepository, error)
- func NewMigration(logger log.Logger, incomingOptimusVersion, dbConnURL string) (store.Migration, error)
- func NewNamespaceRepository(db *gorm.DB, hash models.ApplicationKey) *namespaceRepository
- func NewProjectResourceSpecRepository(db *gorm.DB, project models.ProjectSpec, ds models.Datastorer) *projectResourceSpecRepository
- func NewReplayRepository(db *gorm.DB, jobAdapter *JobSpecAdapter) *replayRepository
- func NewResourceSpecRepository(db *gorm.DB, namespace models.NamespaceSpec, ds models.Datastorer, ...) *resourceSpecRepository
- func NewSecretRepository(db *gorm.DB, hash models.ApplicationKey) *secretRepository
- type Backup
- type BackupDetail
- type ExecutionTree
- type HookRun
- type HookRunRepository
- func (repo *HookRunRepository) GetHookRun(ctx context.Context, jobRunSpec models.JobRunSpec) (models.HookRunSpec, error)
- func (repo *HookRunRepository) Save(ctx context.Context, event models.JobEvent, jobRunSpec models.JobRunSpec) error
- func (repo *HookRunRepository) Update(ctx context.Context, event models.JobEvent, jobRunSpec models.JobRunSpec) error
- type Job
- type JobAsset
- type JobBehavior
- type JobBehaviorNotifier
- type JobBehaviorRetry
- type JobDeployment
- type JobHook
- type JobRunMetrics
- type JobRunMetricsRepository
- func (repo *JobRunMetricsRepository) Get(ctx context.Context, event models.JobEvent, namespaceSpec models.NamespaceSpec, ...) (models.JobRunSpec, error)
- func (repo *JobRunMetricsRepository) GetByID(ctx context.Context, jobRunID uuid.UUID, jobSpec models.JobSpec) (models.JobRunSpec, error)
- func (repo *JobRunMetricsRepository) GetLatestJobRunByScheduledTime(ctx context.Context, scheduledAt string, namespaceSpec models.NamespaceSpec, ...) (models.JobRunSpec, error)
- func (repo *JobRunMetricsRepository) Save(ctx context.Context, event models.JobEvent, namespaceSpec models.NamespaceSpec, ...) error
- func (repo *JobRunMetricsRepository) Update(ctx context.Context, event models.JobEvent, namespaceSpec models.NamespaceSpec, ...) error
- type JobSource
- type JobSpecAdapter
- type Namespace
- func (Namespace) FromSpec(spec models.NamespaceSpec) Namespace
- func (p Namespace) FromSpecWithProject(spec models.NamespaceSpec, proj models.ProjectSpec) Namespace
- func (p Namespace) ToSpec(project models.ProjectSpec) (models.NamespaceSpec, error)
- func (p Namespace) ToSpecWithProjectSecrets(hash models.ApplicationKey) (models.NamespaceSpec, error)
- type Project
- type ProjectRepository
- func (repo *ProjectRepository) GetAll(ctx context.Context) ([]models.ProjectSpec, error)
- func (repo *ProjectRepository) GetByName(ctx context.Context, name string) (models.ProjectSpec, error)
- func (repo *ProjectRepository) Insert(ctx context.Context, resource models.ProjectSpec) error
- func (repo *ProjectRepository) Save(ctx context.Context, spec models.ProjectSpec) error
- type Replay
- type Resource
- type Secret
- type SensorRun
- type SensorRunRepository
- func (repo *SensorRunRepository) GetSensorRun(ctx context.Context, jobRunSpec models.JobRunSpec) (models.SensorRunSpec, error)
- func (repo *SensorRunRepository) Save(ctx context.Context, event models.JobEvent, jobRunSpec models.JobRunSpec) error
- func (repo *SensorRunRepository) Update(ctx context.Context, event models.JobEvent, jobRunSpec models.JobRunSpec) error
- type TaskRun
- type TaskRunRepository
- func (repo *TaskRunRepository) GetTaskRun(ctx context.Context, jobRunSpec models.JobRunSpec) (models.TaskRunSpec, error)
- func (repo *TaskRunRepository) Save(ctx context.Context, event models.JobEvent, jobRunSpec models.JobRunSpec) error
- func (repo *TaskRunRepository) Update(ctx context.Context, event models.JobEvent, jobRunSpec models.JobRunSpec) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewBackupRepository ¶
func NewJobSourceRepository ¶
func NewJobSourceRepository(db *gorm.DB) store.JobSourceRepository
func NewJobSpecRepository ¶
func NewJobSpecRepository(db *gorm.DB, adapter *JobSpecAdapter) (store.JobSpecRepository, error)
NewJobSpecRepository initializes job spec repository
func NewMigration ¶
func NewMigration(logger log.Logger, incomingOptimusVersion, dbConnURL string) (store.Migration, error)
NewMigration initializes migration mechanism specific for postgres
func NewNamespaceRepository ¶
func NewNamespaceRepository(db *gorm.DB, hash models.ApplicationKey) *namespaceRepository
func NewProjectResourceSpecRepository ¶
func NewProjectResourceSpecRepository(db *gorm.DB, project models.ProjectSpec, ds models.Datastorer) *projectResourceSpecRepository
func NewReplayRepository ¶
func NewReplayRepository(db *gorm.DB, jobAdapter *JobSpecAdapter) *replayRepository
func NewResourceSpecRepository ¶
func NewResourceSpecRepository(db *gorm.DB, namespace models.NamespaceSpec, ds models.Datastorer, projectResourceSpecRepo store.ProjectResourceSpecRepository) *resourceSpecRepository
func NewSecretRepository ¶
func NewSecretRepository(db *gorm.DB, hash models.ApplicationKey) *secretRepository
Types ¶
type Backup ¶
type Backup struct {
ID uuid.UUID `gorm:"primary_key;type:uuid;default:uuid_generate_v4()"`
ResourceID uuid.UUID
Resource Resource `gorm:"foreignKey:ResourceID"`
Spec datatypes.JSON
CreatedAt time.Time `gorm:"not null" json:"created_at"`
UpdatedAt time.Time `gorm:"not null" json:"updated_at"`
}
func (Backup) ToSpec ¶
func (b Backup) ToSpec(ds models.Datastorer) (models.BackupSpec, error)
type BackupDetail ¶
type ExecutionTree ¶
type ExecutionTree struct {
JobSpec Job
Dependents []*ExecutionTree
Runs []time.Time
}
type HookRun ¶
type HookRun struct {
HookRunID uuid.UUID `gorm:"primary_key;type:uuid;default:uuid_generate_v4()"`
JobRunID uuid.UUID
StartTime time.Time `gorm:"not null"`
EndTime time.Time
Status string
Attempt int
JobRunAttempt int
Duration int64
CreatedAt time.Time `gorm:"not null" json:"created_at"`
UpdatedAt time.Time `gorm:"not null" json:"updated_at"`
}
type HookRunRepository ¶
type HookRunRepository struct {
// contains filtered or unexported fields
}
func NewHookRunRepository ¶
func NewHookRunRepository(db *gorm.DB) *HookRunRepository
func (*HookRunRepository) GetHookRun ¶
func (repo *HookRunRepository) GetHookRun(ctx context.Context, jobRunSpec models.JobRunSpec) (models.HookRunSpec, error)
func (*HookRunRepository) Save ¶
func (repo *HookRunRepository) Save(ctx context.Context, event models.JobEvent, jobRunSpec models.JobRunSpec) error
func (*HookRunRepository) Update ¶
func (repo *HookRunRepository) Update(ctx context.Context, event models.JobEvent, jobRunSpec models.JobRunSpec) error
type Job ¶
type Job struct {
ID uuid.UUID `gorm:"primary_key;type:uuid;default:uuid_generate_v4()"`
Version int
Name string `gorm:"not null" json:"name"`
Owner string
Description string
Labels datatypes.JSON
StartDate time.Time
EndDate *time.Time
Interval *string
Destination string
Dependencies datatypes.JSON
Behavior datatypes.JSON
ProjectID uuid.UUID
Project Project `gorm:"foreignKey:ProjectID"`
NamespaceID uuid.UUID
Namespace Namespace `gorm:"foreignKey:NamespaceID"`
TaskName string
TaskConfig datatypes.JSON
WindowSize string
WindowOffset string
WindowTruncateTo string
Assets datatypes.JSON
Hooks datatypes.JSON
Metadata datatypes.JSON
ExternalDependencies datatypes.JSON // store external dependencies
CreatedAt time.Time `gorm:"not null" json:"created_at"`
UpdatedAt time.Time `gorm:"not null" json:"updated_at"`
DeletedAt gorm.DeletedAt
// Deprecated: do not use it unless WindowSize is empty
OldWindowSize *int64 // duration in nanos
// Deprecated: do not use it unless WindowOffset is empty
OldWindowOffset *int64
}
Job are inputs from user to create a job postgres representation of the job
type JobBehavior ¶
type JobBehavior struct {
DependsOnPast bool
CatchUp bool
Retry JobBehaviorRetry
Notify []JobBehaviorNotifier
}
type JobBehaviorNotifier ¶
type JobBehaviorRetry ¶
type JobDeployment ¶
type JobDeployment struct {
ID uuid.UUID `gorm:"not null" json:"id"`
ProjectID uuid.UUID `gorm:"not null" json:"project_id"`
Project Project `gorm:"foreignKey:ProjectID"`
Status string `gorm:"not null;default:null"`
Details datatypes.JSON
CreatedAt time.Time `gorm:"not null" json:"created_at"`
UpdatedAt time.Time `gorm:"not null" json:"updated_at"`
}
func (JobDeployment) FromSpec ¶
func (JobDeployment) FromSpec(deployment models.JobDeployment) (JobDeployment, error)
func (JobDeployment) ToSpec ¶
func (d JobDeployment) ToSpec() (models.JobDeployment, error)
type JobHook ¶
func (JobHook) ToSpec ¶
func (a JobHook) ToSpec(pluginRepo models.PluginRepository) (models.JobSpecHook, error)
ToSpec converts the postgres' JobHook representation to the optimus' models.JobSpecHook
type JobRunMetrics ¶
type JobRunMetrics struct {
JobRunID uuid.UUID `gorm:"primary_key;type:uuid;default:uuid_generate_v4()"`
JobID uuid.UUID
NamespaceID uuid.UUID
ProjectID uuid.UUID
ScheduledAt time.Time `gorm:"not null"`
StartTime time.Time `gorm:"not null"`
EndTime time.Time
Status string
Attempt int
SLAMissDelay int
Duration int64
SLADefinition int64
CreatedAt time.Time `gorm:"not null" json:"created_at"`
UpdatedAt time.Time `gorm:"not null" json:"updated_at"`
}
func (JobRunMetrics) TableName ¶
func (JobRunMetrics) TableName() string
TableName overrides the table name used by User to `profiles`
type JobRunMetricsRepository ¶
type JobRunMetricsRepository struct {
// contains filtered or unexported fields
}
func NewJobRunMetricsRepository ¶
func NewJobRunMetricsRepository(db *gorm.DB) *JobRunMetricsRepository
func (*JobRunMetricsRepository) Get ¶
func (repo *JobRunMetricsRepository) Get(ctx context.Context, event models.JobEvent, namespaceSpec models.NamespaceSpec, jobSpec models.JobSpec) (models.JobRunSpec, error)
func (*JobRunMetricsRepository) GetByID ¶
func (repo *JobRunMetricsRepository) GetByID(ctx context.Context, jobRunID uuid.UUID, jobSpec models.JobSpec) (models.JobRunSpec, error)
func (*JobRunMetricsRepository) GetLatestJobRunByScheduledTime ¶
func (repo *JobRunMetricsRepository) GetLatestJobRunByScheduledTime(ctx context.Context, scheduledAt string, namespaceSpec models.NamespaceSpec, jobSpec models.JobSpec) (models.JobRunSpec, error)
GetLatestJobRunByScheduledTime get the latest jobRun instance for a given schedule time
type JobSpecAdapter ¶
type JobSpecAdapter struct {
// contains filtered or unexported fields
}
func NewAdapter ¶
func NewAdapter(pluginRepo models.PluginRepository) *JobSpecAdapter
func (JobSpecAdapter) FromJobSpec ¶
FromJobSpec converts the optimus representation of JobSpec to postgres' Job
type Namespace ¶
type Namespace struct {
ID uuid.UUID `gorm:"primary_key;type:uuid;default:uuid_generate_v4()"`
Name string `gorm:"not null;unique"`
Config datatypes.JSON
ProjectID uuid.UUID
Project Project `gorm:"foreignKey:ProjectID"`
CreatedAt time.Time `gorm:"not null" json:"created_at"`
UpdatedAt time.Time `gorm:"not null" json:"updated_at"`
DeletedAt gorm.DeletedAt
}
func (Namespace) FromSpecWithProject ¶
func (p Namespace) FromSpecWithProject(spec models.NamespaceSpec, proj models.ProjectSpec) Namespace
func (Namespace) ToSpec ¶
func (p Namespace) ToSpec(project models.ProjectSpec) (models.NamespaceSpec, error)
func (Namespace) ToSpecWithProjectSecrets ¶
func (p Namespace) ToSpecWithProjectSecrets(hash models.ApplicationKey) (models.NamespaceSpec, error)
type Project ¶
type Project struct {
ID uuid.UUID `gorm:"primary_key;type:uuid;default:uuid_generate_v4()"`
Name string `gorm:"not null;unique"`
Config datatypes.JSON
// Secrets are read only and will not be saved by updating it here
Secrets []Secret
CreatedAt time.Time `gorm:"not null" json:"created_at"`
UpdatedAt time.Time `gorm:"not null" json:"updated_at"`
DeletedAt gorm.DeletedAt
}
func (Project) ToSpec ¶
func (p Project) ToSpec() models.ProjectSpec
func (Project) ToSpecWithSecrets ¶
func (p Project) ToSpecWithSecrets(h models.ApplicationKey) (models.ProjectSpec, error)
type ProjectRepository ¶
type ProjectRepository struct {
// contains filtered or unexported fields
}
func NewProjectRepository ¶
func NewProjectRepository(db *gorm.DB, hash models.ApplicationKey) *ProjectRepository
func (*ProjectRepository) GetAll ¶
func (repo *ProjectRepository) GetAll(ctx context.Context) ([]models.ProjectSpec, error)
func (*ProjectRepository) GetByName ¶
func (repo *ProjectRepository) GetByName(ctx context.Context, name string) (models.ProjectSpec, error)
func (*ProjectRepository) Insert ¶
func (repo *ProjectRepository) Insert(ctx context.Context, resource models.ProjectSpec) error
func (*ProjectRepository) Save ¶
func (repo *ProjectRepository) Save(ctx context.Context, spec models.ProjectSpec) error
type Replay ¶
type Replay struct {
ID uuid.UUID `gorm:"primary_key;type:uuid;default:uuid_generate_v4()"`
JobID uuid.UUID `gorm:"not null"`
Job Job `gorm:"foreignKey:JobID"`
StartDate time.Time `gorm:"not null"`
EndDate time.Time `gorm:"not null"`
Status string `gorm:"not null"`
Message datatypes.JSON
ExecutionTree datatypes.JSON
Config datatypes.JSON
CreatedAt time.Time `gorm:"not null" json:"created_at"`
UpdatedAt time.Time `gorm:"not null" json:"updated_at"`
}
type Resource ¶
type Resource struct {
ID uuid.UUID `gorm:"primary_key;type:uuid;default:uuid_generate_v4()"`
ProjectID uuid.UUID
Project Project `gorm:"foreignKey:ProjectID"`
NamespaceID uuid.UUID
Namespace Namespace `gorm:"foreignKey:NamespaceID"`
Version int
Name string `gorm:"not null"`
Type string `gorm:"not null"`
Datastore string `gorm:"not null"`
URN string `gorm:"not null"`
Spec []byte
Assets datatypes.JSON
Labels datatypes.JSON
CreatedAt time.Time `gorm:"not null" json:"created_at"`
UpdatedAt time.Time `gorm:"not null" json:"updated_at"`
DeletedAt gorm.DeletedAt
}
func (Resource) FromSpec ¶
func (Resource) FromSpec(resourceSpec models.ResourceSpec) (Resource, error)
func (Resource) FromSpecWithNamespace ¶
func (r Resource) FromSpecWithNamespace(resourceSpec models.ResourceSpec, namespace models.NamespaceSpec) (Resource, error)
func (Resource) ToSpec ¶
func (r Resource) ToSpec(ds models.Datastorer) (models.ResourceSpec, error)
type Secret ¶
type Secret struct {
ID uuid.UUID `gorm:"primary_key;type:uuid;default:uuid_generate_v4()"`
ProjectID uuid.UUID
Project Project `gorm:"foreignKey:ProjectID"`
NamespaceID uuid.UUID `gorm:"default:null"`
Namespace Namespace `gorm:"foreignKey:NamespaceID"`
Name string `gorm:"not null;default:null"`
Value string
Type string
CreatedAt time.Time `gorm:"not null" json:"created_at"`
UpdatedAt time.Time `gorm:"not null" json:"updated_at"`
DeletedAt gorm.DeletedAt
}
func (Secret) FromSpec ¶
func (Secret) FromSpec(spec models.ProjectSecretItem, proj models.ProjectSpec, namespace models.NamespaceSpec, hash models.ApplicationKey) (Secret, error)
func (Secret) ToSecretItemInfo ¶
func (p Secret) ToSecretItemInfo() (models.SecretItemInfo, error)
func (Secret) ToSpec ¶
func (p Secret) ToSpec(key models.ApplicationKey) (models.ProjectSecretItem, error)
ToSpec TODO: move decryption of secret to service
type SensorRun ¶
type SensorRun struct {
SensorRunID uuid.UUID `gorm:"primary_key;type:uuid;default:uuid_generate_v4()"`
JobRunID uuid.UUID
StartTime time.Time `gorm:"not null"`
EndTime time.Time
Status string
Attempt int
JobRunAttempt int
Duration int64
CreatedAt time.Time `gorm:"not null" json:"created_at"`
UpdatedAt time.Time `gorm:"not null" json:"updated_at"`
}
type SensorRunRepository ¶
type SensorRunRepository struct {
// contains filtered or unexported fields
}
func NewSensorRunRepository ¶
func NewSensorRunRepository(db *gorm.DB) *SensorRunRepository
func (*SensorRunRepository) GetSensorRun ¶
func (repo *SensorRunRepository) GetSensorRun(ctx context.Context, jobRunSpec models.JobRunSpec) (models.SensorRunSpec, error)
func (*SensorRunRepository) Save ¶
func (repo *SensorRunRepository) Save(ctx context.Context, event models.JobEvent, jobRunSpec models.JobRunSpec) error
func (*SensorRunRepository) Update ¶
func (repo *SensorRunRepository) Update(ctx context.Context, event models.JobEvent, jobRunSpec models.JobRunSpec) error
type TaskRun ¶
type TaskRun struct {
TaskRunID uuid.UUID `gorm:"primary_key;type:uuid;default:uuid_generate_v4()"`
JobRunID uuid.UUID
StartTime time.Time `gorm:"not null"`
EndTime time.Time
Status string
Attempt int
JobRunAttempt int
Duration int64
CreatedAt time.Time `gorm:"not null" json:"created_at"`
UpdatedAt time.Time `gorm:"not null" json:"updated_at"`
}
type TaskRunRepository ¶
type TaskRunRepository struct {
// contains filtered or unexported fields
}
func NewTaskRunRepository ¶
func NewTaskRunRepository(db *gorm.DB) *TaskRunRepository
func (*TaskRunRepository) GetTaskRun ¶
func (repo *TaskRunRepository) GetTaskRun(ctx context.Context, jobRunSpec models.JobRunSpec) (models.TaskRunSpec, error)
func (*TaskRunRepository) Save ¶
func (repo *TaskRunRepository) Save(ctx context.Context, event models.JobEvent, jobRunSpec models.JobRunSpec) error
func (*TaskRunRepository) Update ¶
func (repo *TaskRunRepository) Update(ctx context.Context, event models.JobEvent, jobRunSpec models.JobRunSpec) error
Source Files
¶
- adapter.go
- backup_repository.go
- hook_run_repository.go
- job_deployment_repository.go
- job_run_repository.go
- job_source_repository.go
- job_spec_repository.go
- migration.go
- namespace_repository.go
- postgres.go
- project_repository.go
- replay_repository.go
- resource_spec_repository.go
- secret_repository.go
- sensor_run_repository.go
- task_run_repository.go