operation

package
v0.0.17 Latest Latest
Warning

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

Go to latest
Published: May 27, 2022 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action struct {
	Path   string   `yaml:"path" json:"path"`
	Script string   `yaml:"script" json:"script"`
	Exe    string   `yaml:"exe,omitempty" json:"exe,omitempty"`
	Args   []string `yaml:"args,omitempty" json:"args,omitempty"`
}

Actions ---------------------------------------------------------------

func (Action) Empty

func (actn Action) Empty() bool

func (Action) HashKeys

func (actn Action) HashKeys() []string

type ActionResult

type ActionResult struct {
	Succeeded bool   `yaml:"succeeded" json:"succeeded"`
	Output    string `yaml:"output" json:"output"`
	Logs      string `yaml:"logs" json:"logs"`
	Action    Action `yaml:"action" json:"action"`
}

type ActionResults

type ActionResults struct {
	Actions map[string]ActionResult `json:"actions"`
}

type Condition

type Condition struct {
	Check string      `yaml:"check" json:"check"`
	Value interface{} `yaml:"value" json:"value"`
}

Reactions ---------------------------------------------------------------

type Correction

type Correction struct {
	Entity      string   `yaml:"entity" json:"entity"`
	Query       string   `yaml:"query" json:"query"`
	Starts_From []string `yaml:"starts_from" json:"starts_from"`
	Results_In  string   `yaml:"results_in" json:"results_in"`
}

Implements ---------------------------------------------------------------

type Implement

type Implement struct {
	Path     string               `yaml:"path,omitempty" json:"path,omitempty"`
	Script   string               `yaml:"script,omitempty" json:"script,omitempty"`
	Exe      string               `yaml:"exe" json:"exe"`
	Reacts   ReactionImplement    `yaml:"reacts,omitempty" json:"reacts,omitempty"`
	Observes ObservationImplement `yaml:"observes,omitempty" json:"observes,omitempty"`
}

func (Implement) Empty

func (impl Implement) Empty() bool

I'm not positive this is true, but can't think of whether or not an implement can omit both reacting and observing (I'm pretty sure they are useless without that)

func (Implement) HashKeys

func (impl Implement) HashKeys() []string

Implements have very specific collision behavior:

If the implement can react _and_ correct then it can conflict with other implements if they both attempt to correct the same thing. Implements that have the same value for all correction fields conflict.

If the implement can observe then it conflicts with any other implement that observes the same entity/query

type Observation

type Observation struct {
	Entity   string `yaml:"entity" json:"entity"`
	Query    string `yaml:"query" json:"query"`
	Instance string `yaml:"instance" json:"instance"`
	Expect   string `yaml:"expect,omitempty" json:"expect,omitempty"`
}

OAR definitions Observations ---------------------------------------------------------------

func (Observation) Empty

func (obsv Observation) Empty() bool

func (Observation) HashKeys

func (obsv Observation) HashKeys() []string

Observations can only conflict if

  1. they expect something
  2. they share all fields with another observation but expect something different

This makes checking for conflicts a pain because in all other cases for the other operations we want to check things via hash collision but for observations it's okay if two observations collide as long as they don't expect two different things.

What we end up having to do is special case the collision check for observations so that if we find a collision we go the extra step to see if the two observations expect different things.

type ObservationImplement

type ObservationImplement struct {
	Entity string   `yaml:"entity" json:"entity"`
	Query  string   `yaml:"query" json:"query"`
	Args   []string `yaml:"args" json:"args"`
}

type ObservationResult

type ObservationResult struct {
	Succeeded   bool        `yaml:"succeeded" json:"succeeded"`
	Result      string      `yaml:"result" json:"result"`
	Expected    bool        `yaml:"expected" json:"expected"`
	Logs        string      `yaml:"logs" json:"logs"`
	Observation Observation `yaml:"observation" json:"observation"`
}

type ObservationResults

type ObservationResults struct {
	Observations            map[string]ObservationResult `yaml:"observations" json:"observations"`
	Total_Observations      int                          `yaml:"total_observations" json:"total_observations"`
	Failed_Observations     int                          `yaml:"failed_observations" json:"failed_observations"`
	Unexpected_Observations int                          `yaml:"unexpected_observations" json:"unexpected_observations"`
}

type Operation

type Operation interface {
	// Operation conflicts are checked by building
	// a hash and checking if the hashed value of the
	// Operation already exists.
	//
	// Some operations have multiple hash keys, because
	// they can conflict in multiple ways
	HashKeys() []string
	Empty() bool
}

Definitions of the language paradigms.

type Operations added in v0.0.9

type Operations struct {
	Reactions    map[string]Reaction    `yaml:"reactions,omitempty" json:"reactions,omitempty"`
	Observations map[string]Observation `yaml:"observations,omitempty" json:"observations,omitempty"`
	Implements   map[string]Implement   `yaml:"implements,omitempty" json:"implements,omitempty"`
	Actions      map[string]Action      `yaml:"actions,omitempty" json:"actions,omitempty"`
}

Everything together ---------------------------------------------------------------

type Reaction

type Reaction struct {
	Observation string    `yaml:"observation" json:"observation"`
	Action      string    `yaml:"action" json:"action"`
	Condition   Condition `yaml:"condition" json:"condition"`
}

func (Reaction) Empty

func (rctn Reaction) Empty() bool

func (Reaction) HashKeys

func (rctn Reaction) HashKeys() []string

type ReactionImplement

type ReactionImplement struct {
	Corrects Correction `yaml:"corrects,omitempty" json:"corrects,omitempty"`
	Args     []string   `yaml:"args" json:"args"`
}

type ReactionResult

type ReactionResult struct {
	Succeeded bool     `yaml:"succeeded" json:"succeeded"`
	Skipped   bool     `yaml:"skipped" json:"skipped"`
	Output    string   `yaml:"output" json:"output"`
	Logs      string   `yaml:"logs" json:"logs"`
	Message   string   `yaml:"message" json:"message"`
	Reaction  Reaction `yaml:"reaction" json:"reaction"`
}

type ReactionResults

type ReactionResults struct {
	Reactions               map[string]ReactionResult    `yaml:"reactions" json:"reactions"`
	Observations            map[string]ObservationResult `yaml:"observations" json:"observations"`
	Total_Observations      int                          `yaml:"total_observations" json:"total_observations"`
	Failed_Observations     int                          `yaml:"failed_observations" json:"failed_observations"`
	Unexpected_Observations int                          `yaml:"unexpected_observations" json:"unexpected_observations"`
	Total_Reactions         int                          `yaml:"total_reactions" json:"total_reactions"`
	Failed_Reactions        int                          `yaml:"failed_reactions" json:"failed_reactions"`
	Skipped_Reactions       int                          `yaml:"skipped_reactions" json:"skipped_reactions"`
}

Jump to

Keyboard shortcuts

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