app

package
v0.0.0-...-96ebf97 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2023 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Curves []CurveData
)

Functions

func AddToMetricCounter

func AddToMetricCounter(key string, value float64, info string, labels map[string]string)

Set a Metric Counter, and create it if it doesn/t already exist

func AdminClearCommandHistory

func AdminClearCommandHistory()

ADMIN: Clear the Command History to make the demo look nicer. Only available if Demo is enabled

func AreAllConditionLockTimersAvailable

func AreAllConditionLockTimersAvailable(action data.Condition, botGroup *data.BotGroup) bool

For a given Condition, does this Bot Group have all the Lock Timers available to be locked?

func AreAllConditionStatesActive

func AreAllConditionStatesActive(action data.Condition, bot *data.Bot) bool

For a given Condition, does this Bot have all the RequiredStates active?

func AverageAndFixup

func AverageAndFixup(runningScore float64, considerCount int) (float64, []string)

This is the heuristic we use to get a good "modified average" of the Considerations to a Consideration Final Score This works well when all the ConditionConsideration.Weight values are ~1.0, so that they have relative importance to each other. Try to keep ConditionConsideration.Weight values between 0.1 and 10.0 for a good result.

func CalculateScore

func CalculateScore(action data.Condition, actionData data.BotConditionData) (float64, []string)

Calculate the Utility Score for a given Condition using a Bots BotConditionData

func CleanMetricKeyString

func CleanMetricKeyString(key string) string

For dynamic metric keys, this will clean them for Prometheus

func FormatBotVariable

func FormatBotVariable(format data.BotVariableFormat, value float64) string

Bot.VariableValues are all floats, but we want them to have human readable strings

func GetAPIPlotData

func GetAPIPlotData(c *fiber.Ctx) string

Returns JSON data needed to create a Plotly graph for our Curves

func GetAPIPlotMetrics

func GetAPIPlotMetrics(c *fiber.Ctx) string

func GetBot

func GetBot(botGroup *data.BotGroup, botName string) (data.Bot, error)

Get a Bot from the BotGroup

func GetBotCurrentStateAndIndex

func GetBotCurrentStateAndIndex(botGroup *data.BotGroup, bot *data.Bot, stateBase string) (string, int, error)

Returns the index of the State currently for this Bot, with the stateBase (BotForwardSequenceState.Name)

func GetBotForwardSequenceState

func GetBotForwardSequenceState(botGroup *data.BotGroup, name string) (data.BotForwardSequenceState, error)

func GetBotGroup

func GetBotGroup(interactiveControl data.InteractiveControl, site *data.Site, botGroupName string) (data.BotGroup, error)

Gets a BotGroup from the Site, using the InteractiveControl

func GetBotGroupAllBotVariablesByName

func GetBotGroupAllBotVariablesByName(botGroup data.BotGroup, varName string) []map[string]string

Returns an array of maps, formatted with the BotVariable name and value

func GetBotVariableData

func GetBotVariableData(botGroup *data.BotGroup, varName string) (data.BotVariable, error)

Returns a BotGroup variable, by name

func GetBotsInState

func GetBotsInState(botGroup *data.BotGroup, stateName string, stateLabel string) []data.Bot

Returns a slice of Bots in this BotGroup that have this state

func GetCommandHistoryAll

func GetCommandHistoryAll(session *data.InteractiveSession, count int) []data.ConditionCommandResult

Returns all the ConditionCommandResults for all Bots in the BotGroups in this Session, sorted by time, descending

func GetCondition

func GetCondition(botGroup *data.BotGroup, actionName string) (data.Condition, error)

Get a Condition from a BotGroup, by name

func GetConditionConsideration

func GetConditionConsideration(action data.Condition, considerName string) (data.ConditionConsideration, error)

Get a ConditionConsideration from a Condition, by name

func GetConditionLastExecuteTime

func GetConditionLastExecuteTime(session *data.InteractiveSession, botGroup *data.BotGroup, bot *data.Bot, action data.Condition, stopLookingAfter data.Duration) (time.Time, error)

func GetCurveDataX

func GetCurveDataX(curveData CurveData) []float64

Get all X axis values, which is just the step from 0-1 at 0.1 intervals

func GetCurveValue

func GetCurveValue(curveData CurveData, x float64) float64

Get the Y value, at an X position, in the curve

func GetInteractiveSession

func GetInteractiveSession(interactiveControl data.InteractiveControl, site *data.Site) data.InteractiveSession

Takes an InteractiveControl struct, and creates a InteractiveSession, which is used everywhere and contains live BotGroups

func GetLockTimer

func GetLockTimer(botGroup *data.BotGroup, lockTimerName string) (*data.BotLockTimer, error)

Get a BotLockTimer from the BotGroup

func GetMetricCounter

func GetMetricCounter(key string, labels map[string]string) (*data.PrometheusMetricCounter, error)

Get an existing Metric Counter

func GetMetricGauge

func GetMetricGauge(key string, labels map[string]string) (*data.PrometheusMetricGauge, error)

Get an existing Metric Counter

func GetMetricLabelsAndInfo_Bot

func GetMetricLabelsAndInfo_Bot(botGroup *data.BotGroup, bot *data.Bot) map[string]string

Returns the map used for Labels in a Metric, for a Bot

func GetMetricLabelsAndInfo_BotVariable

func GetMetricLabelsAndInfo_BotVariable(botGroup *data.BotGroup, bot *data.Bot, varName string) map[string]string

Returns the map used for Labels in a Metric, for a Bot's Variable

func GetMetricLabelsAndInfo_Condition

func GetMetricLabelsAndInfo_Condition(botGroup *data.BotGroup, bot *data.Bot, condition data.Condition) map[string]string

Returns the map used for Labels in a Metric, for a Condition

func GetProductionInteractiveControl

func GetProductionInteractiveControl() data.InteractiveControl

GetProductionInteractiveControl returns a SessionUUID==0 data set for production data. TODO(ghowland): These should be altered by AppConfig

func GetQuery

func GetQuery(botGroup *data.BotGroup, queryName string) (data.BotQuery, error)

Gets a query, scope per BotGroup

func GetQueryResultByQueryKey

func GetQueryResultByQueryKey(site *data.Site, queryKey string) (data.QueryResultPoolItem, bool)

func GetQueryServer

func GetQueryServer(site *data.Site, name string) (data.QueryServer, error)

Returns a QueryServer, scope is per Site

func GetRawMetricsJSON

func GetRawMetricsJSON(c *fiber.Ctx) string

func GetStateIndex

func GetStateIndex(botGroup *data.BotGroup, state string) (int, error)

Returns the index of the State inside it's BotForwardSequenceState. Important because States can only increase or reset to 0 index.

func GetVariable

func GetVariable(botGroup *data.BotGroup, varName string) (data.BotVariable, error)

Get a Variable defintion from BotGroup, by name. Not the Variable Value, which is stored in Bot.

func IsEqualMapStringString

func IsEqualMapStringString(m1 map[string]string, m2 map[string]string) bool

func LoadBotGroupConfig

func LoadBotGroupConfig(path string) data.BotGroup

Load the BotGroup config from a path

func LoadConfig

func LoadConfig(path string) data.AppConfig

Load the Server config

func LoadSiteConfig

func LoadSiteConfig(appConfig data.AppConfig) data.Site

Load our Site config for a path

func ResetBotState

func ResetBotState(botGroup *data.BotGroup, bot *data.Bot, stateBase string) error

func SetAllConditionLockTimers

func SetAllConditionLockTimers(action data.Condition, botGroup *data.BotGroup, duration data.Duration)

When executing a Condition, we will set all the Lock Timers that Condition required, for the duration specified in the ConditionCommand

func SetBotStates

func SetBotStates(botGroup *data.BotGroup, bot *data.Bot, setStates []string) error

When executing a Condition, we want to update the Bots States, to move it forward

func SetLockTimer

func SetLockTimer(botGroup *data.BotGroup, lockTimerName string, duration data.Duration)

func SetMetricGauge

func SetMetricGauge(key string, value float64, info string, labels map[string]string)

Set a Metric Gauge, and create it if it doesn/t already exist

func SortMapStringConditionDataByFinalScore

func SortMapStringConditionDataByFinalScore(input map[string]data.BotConditionData, sortForward bool) data.PairBotConditionDataList

Go doesnt handle map sorting easily, so this is the fix-up

Types

type CurveData

type CurveData struct {
	Name   string    `json:"name"`
	Values []float64 `json:"values"`
}

Points to create a curve. Standard is 0-1 at 0.1 steps, so 1000 points

func GetCurve

func GetCurve(name string) (CurveData, error)

func LoadCurveData

func LoadCurveData(name string) (CurveData, error)

Load the Curve data off the disk

Jump to

Keyboard shortcuts

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