Documentation ¶
Index ¶
- func BuildFactsFromFile(path string, file string) (map[string]*engine.Fact, []error)
- func Execute(esSearch *builder.EsSearch) (*reader.WidgetData, error)
- func FindIndicesWithDynamicDepth(dbClient *sqlx.DB, instance string, model string, t time.Time, ...) ([]string, error)
- func GetFactRangeFromHistory(factID int64, situationID int64, templateInstanceID int64, tsFrom time.Time, ...) (map[time.Time]reader.Item, error)
- func GetFactResultFromHistory(factID int64, t time.Time, situationID int64, templateInstanceID int64, ...) (*reader.Item, time.Time, error)
- func ParseFact(factName string, factData map[string]interface{}) (*engine.Fact, error)
- func PersistFactResult(factID int64, t time.Time, situationID int64, templateInstanceID int64, ...) error
- func Prepare(f *engine.Fact, nhit int, offset int, t time.Time, ...) (*builder.EsSearch, error)
- func ReplaceGlobals(repository Repository) func()
- func UpdateFactResult(factID int64, t time.Time, situationID int64, templateInstanceID int64, ...) error
- type HistoryRecord
- type NativeMapRepository
- func (r *NativeMapRepository) Create(fact engine.Fact) (int64, error)
- func (r *NativeMapRepository) Delete(id int64) error
- func (r *NativeMapRepository) Get(id int64) (engine.Fact, bool, error)
- func (r *NativeMapRepository) GetAll() (map[int64]engine.Fact, error)
- func (r *NativeMapRepository) GetByName(name string) (engine.Fact, bool, error)
- func (r *NativeMapRepository) Update(id int64, fact engine.Fact) error
- type PostgresRepository
- func (r *PostgresRepository) Create(fact engine.Fact) (int64, error)
- func (r *PostgresRepository) Delete(id int64) error
- func (r *PostgresRepository) Get(id int64) (engine.Fact, bool, error)
- func (r *PostgresRepository) GetAll() (map[int64]engine.Fact, error)
- func (r *PostgresRepository) GetByName(name string) (engine.Fact, bool, error)
- func (r *PostgresRepository) Update(id int64, fact engine.Fact) error
- type Repository
- type SituationHistoryRecord
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildFactsFromFile ¶
BuildFactsFromFile This functions creates the facts from the provided file
func Execute ¶
func Execute(esSearch *builder.EsSearch) (*reader.WidgetData, error)
Execute calculate a fact a specific time and returns the result in a standard format
func FindIndicesWithDynamicDepth ¶
func FindIndicesWithDynamicDepth(dbClient *sqlx.DB, instance string, model string, t time.Time, factCalculationDepthDays int64) ([]string, error)
FindIndicesWithDynamicDepth search in indices referential every indices between two dates (calculated using current time and depth)
func GetFactRangeFromHistory ¶
func GetFactRangeFromHistory(factID int64, situationID int64, templateInstanceID int64, tsFrom time.Time, tsTo time.Time) (map[time.Time]reader.Item, error)
GetFactRangeFromHistory get the facts history within a date range
func GetFactResultFromHistory ¶
func GetFactResultFromHistory(factID int64, t time.Time, situationID int64, templateInstanceID int64, closest bool, notOlderThan time.Duration) (*reader.Item, time.Time, error)
GetFactResultFromHistory returns the fact result matching the input timestamp. It can be based on an exact timestamp or approximated to the closest calculated result
func PersistFactResult ¶
func PersistFactResult(factID int64, t time.Time, situationID int64, templateInstanceID int64, item *reader.Item, success bool) error
PersistFactResult persists a fact result (related to a specific time) in postgresql
func Prepare ¶
func Prepare(f *engine.Fact, nhit int, offset int, t time.Time, placeholders map[string]string, update bool) (*builder.EsSearch, error)
Prepare enrich a fact by specifying the offset and the number of hits returned It also specify the target index based on the fact model The
func ReplaceGlobals ¶
func ReplaceGlobals(repository Repository) func()
ReplaceGlobals affect a new repository to the global repository singleton
Types ¶
type HistoryRecord ¶
type HistoryRecord struct { Fact engine.Fact ID int64 TS time.Time SituationID int64 TemplateInstanceID int64 SituationInstances []SituationHistoryRecord }
HistoryRecord fact history record
func GetFactSituationInstances ¶
func GetFactSituationInstances(factIDs []int64, from time.Time, to time.Time, lastDailyValue bool) ([]HistoryRecord, error)
GetFactSituationInstances get the situation instances for fact instances between to and from
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) GetAll ¶
func (r *NativeMapRepository) GetAll() (map[int64]engine.Fact, error)
GetAll returns all entities in the repository
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) GetAll ¶
func (r *PostgresRepository) GetAll() (map[int64]engine.Fact, error)
GetAll returns all entities in the repository
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) }
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