Documentation
¶
Overview ¶
Package repository reads and writes application templates and batch deployments.
Index ¶
- type BatchDeploymentRepository
- func (r *BatchDeploymentRepository) Delete(ctx context.Context, d *model.BatchDeployment) error
- func (r *BatchDeploymentRepository) ExistsByTemplateID(ctx context.Context, templateID string) (bool, error)
- func (r *BatchDeploymentRepository) FindAll(ctx context.Context) ([]model.BatchDeployment, error)
- func (r *BatchDeploymentRepository) FindByID(ctx context.Context, id string) (*model.BatchDeployment, error)
- func (r *BatchDeploymentRepository) FindByTemplateID(ctx context.Context, templateID string) ([]model.BatchDeployment, error)
- func (r *BatchDeploymentRepository) Save(ctx context.Context, d *model.BatchDeployment) error
- func (r *BatchDeploymentRepository) SaveConfig(ctx context.Context, c *model.BatchJobConfig) error
- func (r *BatchDeploymentRepository) WithTx(tx *gorm.DB) *BatchDeploymentRepository
- type TemplateRepository
- func (r *TemplateRepository) Delete(ctx context.Context, t *model.Template) error
- func (r *TemplateRepository) ExistsByName(ctx context.Context, name string) (bool, error)
- func (r *TemplateRepository) FindAll(ctx context.Context) ([]model.Template, error)
- func (r *TemplateRepository) FindByID(ctx context.Context, id string) (*model.Template, error)
- func (r *TemplateRepository) ReplaceChildren(ctx context.Context, templateID string, inputs []model.TemplateInput, ...) error
- func (r *TemplateRepository) SaveTemplate(ctx context.Context, t *model.Template) error
- func (r *TemplateRepository) WithTx(tx *gorm.DB) *TemplateRepository
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BatchDeploymentRepository ¶
type BatchDeploymentRepository struct {
// contains filtered or unexported fields
}
BatchDeploymentRepository reads and writes deployments.
func NewBatchDeploymentRepository ¶
func NewBatchDeploymentRepository(db *gorm.DB) *BatchDeploymentRepository
NewBatchDeploymentRepository returns a repository backed by db.
func (*BatchDeploymentRepository) Delete ¶
func (r *BatchDeploymentRepository) Delete(ctx context.Context, d *model.BatchDeployment) error
Delete removes a deployment; the AfterDelete hook removes its owned config.
func (*BatchDeploymentRepository) ExistsByTemplateID ¶
func (r *BatchDeploymentRepository) ExistsByTemplateID(ctx context.Context, templateID string) (bool, error)
ExistsByTemplateID reports whether a template still has deployments. This is what blocks template deletion with a conflict.
func (*BatchDeploymentRepository) FindAll ¶
func (r *BatchDeploymentRepository) FindAll(ctx context.Context) ([]model.BatchDeployment, error)
FindAll returns every deployment with its owned batch job config.
func (*BatchDeploymentRepository) FindByID ¶
func (r *BatchDeploymentRepository) FindByID(ctx context.Context, id string) (*model.BatchDeployment, error)
FindByID returns one deployment, or gorm.ErrRecordNotFound.
func (*BatchDeploymentRepository) FindByTemplateID ¶
func (r *BatchDeploymentRepository) FindByTemplateID(ctx context.Context, templateID string) ([]model.BatchDeployment, error)
FindByTemplateID returns every deployment of one template.
func (*BatchDeploymentRepository) Save ¶
func (r *BatchDeploymentRepository) Save(ctx context.Context, d *model.BatchDeployment) error
Save writes the deployment row. The owned config is written separately by SaveConfig, so that an update mutates the existing config row rather than replacing it and leaving an orphan.
func (*BatchDeploymentRepository) SaveConfig ¶
func (r *BatchDeploymentRepository) SaveConfig(ctx context.Context, c *model.BatchJobConfig) error
SaveConfig inserts or updates an owned batch job config.
func (*BatchDeploymentRepository) WithTx ¶
func (r *BatchDeploymentRepository) WithTx(tx *gorm.DB) *BatchDeploymentRepository
WithTx returns a repository bound to tx.
type TemplateRepository ¶
type TemplateRepository struct {
// contains filtered or unexported fields
}
TemplateRepository reads and writes application templates and their owned input/output declarations.
func NewTemplateRepository ¶
func NewTemplateRepository(db *gorm.DB) *TemplateRepository
NewTemplateRepository returns a repository backed by db.
func (*TemplateRepository) Delete ¶
Delete removes a template; its declarations go with it via the cascade.
func (*TemplateRepository) ExistsByName ¶
ExistsByName reports whether a template of that name exists. Declared but never called in the Java service.
func (*TemplateRepository) FindByID ¶
FindByID returns one template with its declarations, or gorm.ErrRecordNotFound.
func (*TemplateRepository) ReplaceChildren ¶
func (r *TemplateRepository) ReplaceChildren(ctx context.Context, templateID string, inputs []model.TemplateInput, outputs []model.TemplateOutput) error
ReplaceChildren swaps a template's declarations for the given ones.
The Java service replaced the collections wholesale on every update, so child ids are regenerated and any id supplied on the request is ignored. That is preserved here: an update declares what the inputs and outputs now are, not a patch of them.
func (*TemplateRepository) SaveTemplate ¶
SaveTemplate writes the template row only, leaving its declarations alone. Children are replaced explicitly by ReplaceChildren rather than cascaded from here, so an update cannot quietly drop declarations the caller did not mention.
func (*TemplateRepository) WithTx ¶
func (r *TemplateRepository) WithTx(tx *gorm.DB) *TemplateRepository
WithTx returns a repository bound to tx.