fact

package
v5.5.6 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2024 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildFactsFromFile

func BuildFactsFromFile(path string, file string) (map[string]*engine.Fact, []error)

BuildFactsFromFile This functions creates the facts from the provided file

func ExecuteFact added in v5.2.0

func ExecuteFact(
	ti time.Time,
	f engine.Fact, situationID int64, situationInstanceID int64, parameters map[string]string,
	nhit int, offset int, update bool,
) (*reader.WidgetData, error)

func FindIndices added in v5.2.0

func FindIndices(f engine.Fact, ti time.Time, update bool) []string

func GetBaselineValues added in v5.3.6

func GetBaselineValues(widgetData *reader.WidgetData, factId int64, situationID int64, situationInstanceID int64, ti time.Time)

func ParseFact

func ParseFact(factName string, factData map[string]interface{}) (*engine.Fact, error)

ParseFact parse a fact configuration map and return a new instance of fact

func ReplaceGlobals

func ReplaceGlobals(repository Repository) func()

ReplaceGlobals affect a new repository to the global repository singleton

Types

type NativeMapRepository

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

NativeMapRepository is an implementation of entity.Repository, supported by standard native in-memory map

func (*NativeMapRepository) Create

func (r *NativeMapRepository) Create(fact engine.Fact) (int64, error)

Create stores the given new fact in the database as a json.

func (*NativeMapRepository) Delete

func (r *NativeMapRepository) Delete(id int64) error

Delete deletes an entity from the repository by its name

func (*NativeMapRepository) Get

func (r *NativeMapRepository) Get(id int64) (engine.Fact, bool, error)

Get search and returns an entity from the repository by its id

func (*NativeMapRepository) GetAll

func (r *NativeMapRepository) GetAll() (map[int64]engine.Fact, error)

GetAll returns all entities in the repository

func (*NativeMapRepository) GetAllByIDs

func (r *NativeMapRepository) GetAllByIDs(ids []int64) (map[int64]engine.Fact, error)

GetAllByIDs returns all entities in the repository

func (*NativeMapRepository) GetByName

func (r *NativeMapRepository) GetByName(name string) (engine.Fact, bool, error)

GetByName search and returns an entity from the repository by its name

func (*NativeMapRepository) Update

func (r *NativeMapRepository) Update(id int64, fact engine.Fact) error

Update updates an entity in the repository by its name

type PostgresRepository

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

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

func (*PostgresRepository) Create

func (r *PostgresRepository) Create(fact engine.Fact) (int64, error)

Create creates a new Fact definition in the repository

func (*PostgresRepository) Delete

func (r *PostgresRepository) Delete(id int64) error

Delete deletes an entity from the repository by its name

func (*PostgresRepository) Get

func (r *PostgresRepository) Get(id int64) (engine.Fact, bool, error)

Get search and returns an entity from the repository by its id

func (*PostgresRepository) GetAll

func (r *PostgresRepository) GetAll() (map[int64]engine.Fact, error)

GetAll returns all entities in the repository

func (*PostgresRepository) GetAllByIDs

func (r *PostgresRepository) GetAllByIDs(ids []int64) (map[int64]engine.Fact, error)

GetAllByIDs returns all entities filtered by IDs in the repository

func (*PostgresRepository) GetByName

func (r *PostgresRepository) GetByName(name string) (engine.Fact, bool, error)

GetByName search and returns an entity from the repository by its name

func (*PostgresRepository) Update

func (r *PostgresRepository) Update(id int64, fact engine.Fact) error

Update updates an entity in the repository by its name

type Repository

type Repository interface {
	Get(id int64) (engine.Fact, bool, error)
	GetByName(name string) (engine.Fact, bool, error)
	Create(fact engine.Fact) (int64, error)
	Update(id int64, fact engine.Fact) error
	Delete(id int64) error
	GetAll() (map[int64]engine.Fact, error)
	GetAllByIDs(ids []int64) (map[int64]engine.Fact, 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 facts

func NewNativeMapRepository

func NewNativeMapRepository() Repository

NewNativeMapRepository returns a new instance of NativeMapRepository

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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