rootcause

package
v4.1.3 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2022 License: MIT Imports: 6 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 RootCause definition based on a PSQL database and implementing the repository interface

func (*PostgresRepository) Create

func (r *PostgresRepository) Create(tx *sqlx.Tx, rootCause models.RootCause) (int64, error)

Create method used to create an rootCause

func (*PostgresRepository) Delete

func (r *PostgresRepository) Delete(tx *sqlx.Tx, id int64) error

Delete use to retrieve an rootCause by id

func (*PostgresRepository) Get

Get use to retrieve an rootCause by id

func (*PostgresRepository) GetAll

func (r *PostgresRepository) GetAll() (map[int64]models.RootCause, error)

GetAll method used to get all rootCauses

func (*PostgresRepository) GetAllBySituationID

func (r *PostgresRepository) GetAllBySituationID(situationID int64) (map[int64]models.RootCause, error)

GetAllBySituationID method used to get all rootCauses for a specific situation ID

func (*PostgresRepository) GetAllBySituationIDRuleID

func (r *PostgresRepository) GetAllBySituationIDRuleID(situationID int64, ruleID int64) (map[int64]models.RootCause, error)

GetAllBySituationIDRuleID method used to get all rootCauses for a specific situation ID and rule ID

func (*PostgresRepository) Update

func (r *PostgresRepository) Update(tx *sqlx.Tx, id int64, rootCause models.RootCause) error

Update method used to update un rootCause

type Repository

type Repository interface {
	Get(id int64) (models.RootCause, bool, error)
	Create(tx *sqlx.Tx, rootCause models.RootCause) (int64, error)
	Update(tx *sqlx.Tx, id int64, rootCause models.RootCause) error
	Delete(tx *sqlx.Tx, id int64) error
	GetAll() (map[int64]models.RootCause, error)
	GetAllBySituationID(situationID int64) (map[int64]models.RootCause, error)
	GetAllBySituationIDRuleID(situationID int64, ruleID int64) (map[int64]models.RootCause, 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