Documentation ¶
Index ¶
- func ReplaceGlobals(repository Repository) func()
- type PostgresRepository
- func (r *PostgresRepository) CheckExists(tx *sqlx.Tx, issueID int64) (bool, error)
- func (r *PostgresRepository) CheckExistsWithUUID(tx *sqlx.Tx, issueID int64, uuid string) (bool, error)
- func (r *PostgresRepository) Create(tx *sqlx.Tx, issueID int64, draft models.FrontDraft) error
- func (r *PostgresRepository) Get(issueID int64) (models.FrontDraft, bool, error)
- func (r *PostgresRepository) Update(tx *sqlx.Tx, issueID int64, draft models.FrontDraft) error
- type Repository
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 ¶
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) 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) }
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