engine

package
v4.1.3 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2022 License: MIT Imports: 11 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BooleanTokens = []BooleanToken{And, Or, Not}

BooleanTokens list every supported boolean token

ConditionTokens list every supported condition token

View Source
var DimensionTokens = []DimensionToken{By, Histogram, DateHistogram}

DimensionTokens list every supported dimension token

View Source
var IntentTokens = []IntentToken{Count, Sum, Avg, Min, Max, Select}

IntentTokens list every supported intent token

Functions

This section is empty.

Types

type BooleanFragment

type BooleanFragment struct {
	Operator   BooleanToken        `json:"operator"`
	Expression string              `json:"expression,omitempty"`
	Fragments  []ConditionFragment `json:"fragments"`
}

BooleanFragment is a fragment type allowing to combine multiple condition fragment with a boolean operator

func GetBooleanFragment

func GetBooleanFragment(name string) (*BooleanFragment, error)

GetBooleanFragment search and return a boolean fragment by it's name

func (*BooleanFragment) IsValid

func (frag *BooleanFragment) IsValid() (bool, error)

IsValid checks if an boolean fragment is valid and has no missing mandatory fields * Operator must not be empty (or 0 value) * Fragments must not be nil or empty

type BooleanToken

type BooleanToken int

BooleanToken enumeration for boolean tokens

const (
	// And boolean token
	And BooleanToken = iota + 1
	// Or boolean token
	Or
	// Not boolean token
	Not
	// If boolean token
	If
)

func GetBooleanToken

func GetBooleanToken(name string) *BooleanToken

GetBooleanToken search and return a boolean token from the standard supported operator list

func (BooleanToken) MarshalJSON

func (s BooleanToken) MarshalJSON() ([]byte, error)

MarshalJSON marshals the enum as a quoted json string

func (BooleanToken) String

func (s BooleanToken) String() string

func (*BooleanToken) UnmarshalJSON

func (s *BooleanToken) UnmarshalJSON(b []byte) error

UnmarshalJSON unmashals a quoted json string to the enum value

type ConditionFragment

type ConditionFragment interface {
	IsValid() (bool, error)
}

ConditionFragment is an interface for condition fragment (which can be boolean or leafcondition)

type ConditionToken

type ConditionToken int

ConditionToken enumeration for condition tokens

const (
	// For condition token
	For ConditionToken = iota + 1
	// From condition token
	From
	// To condition token
	To
	// Between condition token
	Between
	// Exists condition token
	Exists
	// Script condition token
	Script
	// OptionalFor condition token
	OptionalFor
)

func GetConditionToken

func GetConditionToken(name string) *ConditionToken

GetConditionToken search and return a condition token from the standard supported operator list

func (ConditionToken) MarshalJSON

func (s ConditionToken) MarshalJSON() ([]byte, error)

MarshalJSON marshals the enum as a quoted json string

func (ConditionToken) String

func (s ConditionToken) String() string

func (*ConditionToken) UnmarshalJSON

func (s *ConditionToken) UnmarshalJSON(b []byte) error

UnmarshalJSON unmashals a quoted json string to the enum value

type ConditionsAlias

type ConditionsAlias struct {
	Condition ConditionFragment `json:"condition,omitempty"`
	Comment   string            `json:"comment"`
}

ConditionsAlias ...

type DimensionFragment

type DimensionFragment struct {
	Name         string         `json:"name,omitempty"`
	Operator     DimensionToken `json:"operator"`
	Term         string         `json:"term"`
	Size         int            `json:"size,omitempty"`
	Interval     float64        `json:"interval,omitempty"`
	DateInterval string         `json:"dateinterval,omitempty"`
	TimeZone     string         `json:"timezone,omitempty"`
}

DimensionFragment is a fragment type which contains a single dimension definition

func GetDimensionFragment

func GetDimensionFragment(name string) (*DimensionFragment, error)

GetDimensionFragment search and return a dimension fragment by it's name

func (*DimensionFragment) IsValid

func (frag *DimensionFragment) IsValid() (bool, error)

IsValid checks if an intent fragment is valid and has no missing mandatory fields * Operator must not be empty (or 0 value) * Term must not be empty * Size must not be lesser than 0 * Interval must not be lesser than 0

type DimensionToken

type DimensionToken int

DimensionToken enumeration for dimension tokens

const (
	// By dimension token
	By DimensionToken = iota + 1
	// Histogram dimension token
	Histogram
	// DateHistogram dimension token
	DateHistogram
)

func GetDimensionToken

func GetDimensionToken(name string) *DimensionToken

GetDimensionToken search and return a dimension token from the standard supported operator list

func (DimensionToken) MarshalJSON

func (s DimensionToken) MarshalJSON() ([]byte, error)

MarshalJSON marshals the enum as a quoted json string

func (DimensionToken) String

func (s DimensionToken) String() string

func (*DimensionToken) UnmarshalJSON

func (s *DimensionToken) UnmarshalJSON(b []byte) error

UnmarshalJSON unmashals a quoted json string to the enum value

type Fact

type Fact struct {
	ID               int64                `json:"id"`
	Name             string               `json:"name"`
	IsObject         bool                 `json:"isObject"`
	Model            string               `json:"model"`
	CalculationDepth int64                `json:"calculationDepth,omitempty"`
	Intent           *IntentFragment      `json:"intent,omitempty"`
	Dimensions       []*DimensionFragment `json:"dimensions,omitempty"`
	Condition        ConditionFragment    `json:"condition,omitempty"`
	Restitution      []Restitution        `json:"restitution,omitempty"`
	Comment          string               `json:"comment"`
	AdvancedSource   string               `json:"source,omitempty"`
	IsTemplate       bool                 `json:"isTemplate"`
	Variables        []string             `json:"variables,omitempty"`
}

Fact is the main structure used to for the full fact definition

func (*Fact) ContextualizeCondition

func (f *Fact) ContextualizeCondition(t time.Time, placeholders map[string]string) error

ContextualizeCondition contextualize fact condition tree placeholders (standard or custom) and set the right timezone if needed

func (*Fact) ContextualizeDimensions

func (f *Fact) ContextualizeDimensions(t time.Time, placeholders map[string]string)

ContextualizeDimensions contextualize fact dimensions placeholders (standard or custom) and set the right timezone if needed

func (*Fact) IsExecutable

func (f *Fact) IsExecutable() bool

IsExecutable check if a fact is complete and executable

func (*Fact) IsValid

func (f *Fact) IsValid() (bool, error)

IsValid checks if a fact definition is valid and has no missing mandatory fields * Name must not be empty * CalculationDepth must not be less than 0 * Intent must be valid * Dimensions must be valid * Condition must be valid

func (*Fact) ToElasticQuery

func (f *Fact) ToElasticQuery(t time.Time, placeholders map[string]string) (*builder.EsSearch, error)

ToElasticQuery convert the fact in an elasticsearch search query

func (*Fact) UnmarshalJSON

func (f *Fact) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshal a fact from a json string

type IntentFragment

type IntentFragment struct {
	Name     string      `json:"name,omitempty"`
	Operator IntentToken `json:"operator"`
	Term     string      `json:"term"`
	Script   bool        `json:"script,omitempty"`
}

IntentFragment is a fragment type which contains a single intent definition

func GetIntentFragment

func GetIntentFragment(name string) (*IntentFragment, error)

GetIntentFragment search and return an intent fragment by it's name

func (*IntentFragment) IsValid

func (frag *IntentFragment) IsValid() (bool, error)

IsValid checks if an intent fragment is valid and has no missing mandatory fields * Operator must not be empty (or 0 value) * Term must not be empty

type IntentToken

type IntentToken int

IntentToken enumeration for intent tokens

const (
	// Count intent token
	Count IntentToken = iota + 1
	// Sum intent token
	Sum
	// Avg intent token
	Avg
	// Min intent token
	Min
	// Max intent token
	Max
	// Select intent token
	Select
)

func GetIntentToken

func GetIntentToken(name string) *IntentToken

GetIntentToken search and return an intent token from the standard supported operator list

func (IntentToken) MarshalJSON

func (s IntentToken) MarshalJSON() ([]byte, error)

MarshalJSON marshals the enum as a quoted json string

func (IntentToken) String

func (s IntentToken) String() string

func (*IntentToken) UnmarshalJSON

func (s *IntentToken) UnmarshalJSON(b []byte) error

UnmarshalJSON unmashals a quoted json string to the enum value

type LeafConditionFragment

type LeafConditionFragment struct {
	Operator ConditionToken `json:"operator"`
	Field    string         `json:"term"`
	Value    interface{}    `json:"value,omitempty"`
	Value2   interface{}    `json:"value2,omitempty"`
	TimeZone string         `json:"timezone,omitempty"`
}

LeafConditionFragment is a fragment containing a single terminal condition

func GetLeafConditionFragment

func GetLeafConditionFragment(name string) (*LeafConditionFragment, error)

GetLeafConditionFragment search and return a leaf condition fragment by it's name

func (*LeafConditionFragment) IsValid

func (frag *LeafConditionFragment) IsValid() (bool, error)

IsValid checks if a leaf condition fragment is valid and has no missing mandatory fields * Operator must not be empty (or 0 value) * Fragments must not be nil or empty

type Restitution

type Restitution struct{}

Restitution ...

type Token

type Token interface {
	String() string
	MarshalJSON() ([]byte, error)
	UnmarshalJSON([]byte) error
}

Token interface for the fact fragment tokens

Jump to

Keyboard shortcuts

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