search

package
v5.4.4 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: MIT Imports: 13 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 DownSampling

type DownSampling struct {
	Granularity        time.Duration `json:"granularity"`
	GranularitySpecial string        `json:"granularitySpecial"`
	Operation          string        `json:"operation"`
}

DownSampling downscale definition

func (*DownSampling) UnmarshalJSON

func (d *DownSampling) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals a quoted json string to a valid DownSampling struct

type ErrDatabase

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

ErrDatabase wraps a database error

func NewErrDatabase

func NewErrDatabase(message string) ErrDatabase

NewErrDatabase returns a new ErrDatabase

func (ErrDatabase) Error

func (e ErrDatabase) Error() string

type ErrResourceNotFound

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

ErrResourceNotFound wraps a ressource not found error

func NewErrResourceNotFound

func NewErrResourceNotFound(resourceType string) ErrResourceNotFound

NewErrResourceNotFound returns a new ErrResourceNotFound

func (ErrResourceNotFound) Error

func (e ErrResourceNotFound) Error() string

type FactHistoryRecord

type FactHistoryRecord struct {
	DateTime  time.Time                         `json:"dateTime"`
	FactID    int64                             `json:"factId"`
	FactName  string                            `json:"factName"`
	Value     interface{}                       `json:"value,omitempty"`
	DocCount  interface{}                       `json:"docCount,omitempty"`
	Buckets   map[string][]*reader.Item         `json:"buckets,omitempty"`
	Baselines map[string]baseline.BaselineValue `json:"baselines,omitempty"`
}

FactHistoryRecord struct to represent a fact history record

type PostgresRepository

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

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

func (*PostgresRepository) GetSituationHistoryRecords

func (r *PostgresRepository) GetSituationHistoryRecords(s situation.Situation, templateInstanceID int64, t time.Time, start time.Time, end time.Time,
	factSource interface{}, expressionFactsSource interface{}, metaDataSource interface{}, parametersSource interface{},
	downSampling DownSampling) (QueryResult, error)

GetSituationHistoryRecords returns the situations records at a specific time

type Query

type Query struct {
	SituationID         int64         `json:"situationId"`
	SituationInstanceID int64         `json:"situationInstanceId"`
	Time                time.Time     `json:"time"`
	Start               time.Time     `json:"start"`
	End                 time.Time     `json:"end"`
	Range               time.Duration `json:"range"`
	Facts               interface{}   `json:"facts"`
	ExpressionFacts     interface{}   `json:"expressionFacts"`
	MetaData            interface{}   `json:"metaDatas"`
	Parameters          interface{}   `json:"parameters"`
	DownSampling        DownSampling  `json:"downSampling"`
}

Query is a struct used to represent a query

func (Query) Execute

func (q Query) Execute() (QueryResult, error)

Execute executes the query and return a QueryResult or an error

func (*Query) UnmarshalJSON

func (q *Query) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals a quoted json string to a valid Query struct

type QueryResult

type QueryResult []SituationHistoryRecords

QueryResult is a struct used to represent a query result

type RawSituationRecord

type RawSituationRecord struct {
	RawFactIDs         []byte
	RawParams          []byte
	RawExpressionFacts []byte
	RawMetadatas       []byte
	TS                 time.Time
	InstanceID         int64
	InstanceName       interface{}
}

type Repository

type Repository interface {
	GetSituationHistoryRecords(s situation.Situation, templateInstanceID int64, t time.Time, start time.Time, end time.Time,
		factSource interface{}, factExpressionsSource interface{}, metaDataSource interface{}, parametersSource interface{}, downSampling DownSampling) (QueryResult, 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 situations

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

type SituationHistoryCalendarRecord added in v5.0.12

type SituationHistoryCalendarRecord struct {
	Id          int64  `json:"id"`
	Name        string `json:"name"`
	Description string `json:"description"`
	Timezone    string `json:"timezone"`
}

type SituationHistoryRecord

type SituationHistoryRecord struct {
	SituationID           int64                           `json:"situationId"`
	SituationName         string                          `json:"situationName"`
	SituationInstanceID   int64                           `json:"situationInstanceId"`
	SituationInstanceName string                          `json:"situationInstanceName"`
	Calendar              *SituationHistoryCalendarRecord `json:"calendar,omitempty"`
	Parameters            map[string]interface{}          `json:"parameters,omitempty"`
	ExpressionFacts       map[string]interface{}          `json:"expressionFacts,omitempty"`
	MetaData              map[string]interface{}          `json:"metaDatas,omitempty"`
	Facts                 []FactHistoryRecord             `json:"facts,omitempty"`
	DateTime              time.Time                       `json:"dateTime"`
}

SituationHistoryRecord struct used to represent a situation history record

type SituationHistoryRecords

type SituationHistoryRecords struct {
	DateTime   time.Time                `json:"dateTime"`
	Situations []SituationHistoryRecord `json:"situations"`
}

SituationHistoryRecords struct used to group situation history records by datetime

Jump to

Keyboard shortcuts

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