draft

package
v5.3.6 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReplaceGlobals

func ReplaceGlobals(repository Repository) func()

ReplaceGlobals affect a new repository to the global repository singleton

Types

type PostgresRepository

type PostgresRepository struct {
	// contains filtered or unexported fields
}

PostgresRepository is a repository containing the FrontDraft definition based on a PSQL database and implementing the repository interface

func (*PostgresRepository) CheckExists

func (r *PostgresRepository) CheckExists(tx *sqlx.Tx, issueID int64) (bool, error)

CheckExists check if a draft already exists on an issue

func (*PostgresRepository) CheckExistsWithUUID

func (r *PostgresRepository) CheckExistsWithUUID(tx *sqlx.Tx, issueID int64, uuid string) (bool, error)

CheckExistsWithUUID double check if a draft already exists on an issue AND if the timestamp match the existing one In case it doesn't match, it means the draft has already been modified

func (*PostgresRepository) Create

func (r *PostgresRepository) Create(tx *sqlx.Tx, issueID int64, draft models.FrontDraft) error

Create method used to create a draft

func (*PostgresRepository) DeleteOldIssueResolutionsDrafts added in v5.3.2

func (r *PostgresRepository) DeleteOldIssueResolutionsDrafts(ts time.Time) error

DeleteOldIssueResolutionsDrafts deletes issue resolution drafts based on the provided timestamp

func (*PostgresRepository) Get

func (r *PostgresRepository) Get(issueID int64) (models.FrontDraft, bool, error)

Get use to retrieve a draft by id

func (*PostgresRepository) Update

func (r *PostgresRepository) Update(tx *sqlx.Tx, issueID int64, draft models.FrontDraft) error

Update method used to update a draft

type Repository

type Repository interface {
	Get(issueID int64) (models.FrontDraft, bool, error)
	Create(tx *sqlx.Tx, issueID int64, draft models.FrontDraft) error
	Update(tx *sqlx.Tx, issueID int64, draft models.FrontDraft) error
	// Delete(tx *sqlx.Tx, id int64) error)
	CheckExists(tx *sqlx.Tx, issueID int64) (bool, error)
	CheckExistsWithUUID(tx *sqlx.Tx, issueID int64, uuid string) (bool, error)
	DeleteOldIssueResolutionsDrafts(ts time.Time) error
}

Repository is a storage interface which can be implemented by multiple backend (in-memory map, sql database, in-memory cache, file system, ...) It allows standard CRUD operation on RootCauses

func NewPostgresRepository

func NewPostgresRepository(dbClient *sqlx.DB) Repository

NewPostgresRepository returns a new instance of PostgresRepository

func R

func R() Repository

R is used to access the global repository singleton

Jump to

Keyboard shortcuts

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