internal

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2019 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Alias

type Alias struct {
	ReferType      DefinitionType
	AllowDuplicate bool
}

type AliasMap

type AliasMap map[DefinitionID][]AliasName

type AliasName

type AliasName string

type Aliases

type Aliases map[AliasName]*Alias

func (Aliases) IsAlias

func (a Aliases) IsAlias(defType DefinitionType) bool

type Constraint

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

func NewConstraint

func NewConstraint(rawKey RawConstraintKey, rawValue RawConstraintValue) (*Constraint, error)

func (*Constraint) IsSatisfied

func (c *Constraint) IsSatisfied(state *State) bool

type ConstraintKey

type ConstraintKey struct {
	Raw                 RawConstraintKey
	DefinitionType      DefinitionType
	HasRegExpValue      bool
	IsAllowedToNotExist bool
	MustNotExist        bool
	WillAddValue        bool
	Priority            int
}

func (*ConstraintKey) IsValid

func (l *ConstraintKey) IsValid() (bool, string)

type ConstraintValue

type ConstraintValue struct {
	Raw      RawConstraintValue
	IsRegExp bool
	// contains filtered or unexported fields
}

func (*ConstraintValue) Match

func (c *ConstraintValue) Match(msg Message) bool

func (*ConstraintValue) ToMessage

func (c *ConstraintValue) ToMessage() (Message, error)

type Constraints

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

func NewConstraints

func NewConstraints(raw RawConstraints) (*Constraints, error)

func (*Constraints) AreSatisfied

func (c *Constraints) AreSatisfied(state *State) (bool, error)

func (*Constraints) Get

func (*Constraints) GetByDefinitionType

func (c *Constraints) GetByDefinitionType(defType DefinitionType) (RawConstraintValue, bool)

func (*Constraints) GetPriority

func (c *Constraints) GetPriority(state *State) int

func (*Constraints) ListUnsatisfied

func (c *Constraints) ListUnsatisfied(state *State) (*Constraints, error)

func (*Constraints) Set

func (c *Constraints) Set(rawKey RawConstraintKey, value RawConstraintValue) error

type Definition

type Definition struct {
	*RawDefinition
	Constraints *Constraints
	ID          DefinitionID
	Templates   Templates
}

func ConstraintsSatisfiedDefinitionPicker

func ConstraintsSatisfiedDefinitionPicker(definitions *Definitions, state *State) ([]*Definition, error)

func NewDefinition

func NewDefinition(rawDefinition *RawDefinition) (*Definition, error)

func RandomWithWeightDefinitionPicker

func RandomWithWeightDefinitionPicker(definitions *Definitions, state *State) ([]*Definition, error)

func SortByConstraintPriorityDefinitionPicker

func SortByConstraintPriorityDefinitionPicker(definitions *Definitions, state *State) ([]*Definition, error)

func (*Definition) CanBePicked

func (d *Definition) CanBePicked(state *State) (bool, error)

func (*Definition) Copy

func (d *Definition) Copy() (*Definition, error)

func (*Definition) IsAlias

func (d *Definition) IsAlias(defType DefinitionType) bool

type DefinitionID

type DefinitionID int

type DefinitionPicker

type DefinitionPicker func(defs *Definitions, state *State) ([]*Definition, error)

type DefinitionRepository

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

func (*DefinitionRepository) Add

func (d *DefinitionRepository) Add(rawDefs ...*RawDefinition) error

func (*DefinitionRepository) Generate

func (d *DefinitionRepository) Generate(defType DefinitionType, initialState *State, num uint) (messages []Message, err error)

func (*DefinitionRepository) List

func (d *DefinitionRepository) List(defType DefinitionType) (defs Definitions)

func (*DefinitionRepository) Start

func (d *DefinitionRepository) Start(defType DefinitionType, initialState *State) (msgChan chan Message, errChan chan error)

type DefinitionRepositoryOption

type DefinitionRepositoryOption struct {
	TemplatePickers    []TemplatePicker
	DefinitionPickers  []DefinitionPicker
	TemplateValidators []TemplateValidator
}

type DefinitionType

type DefinitionType string

type DefinitionTypes

type DefinitionTypes []DefinitionType

type DefinitionWeight

type DefinitionWeight float32

type DefinitionWithAlias

type DefinitionWithAlias struct {
	*Definition
	// contains filtered or unexported fields
}

type Definitions

type Definitions []*Definition

func (*Definitions) Copy

func (d *Definitions) Copy() (Definitions, error)

func (*Definitions) DeleteByIndex

func (d *Definitions) DeleteByIndex(i int)

func (*Definitions) PopByIndex

func (d *Definitions) PopByIndex(index int) *Definition

type Message

type Message string

type MessageMap

type MessageMap map[string]Message

type PickedTemplateMap

type PickedTemplateMap map[DefinitionID]*Templates

type RawConstraintKey

type RawConstraintKey string

func (RawConstraintKey) Parse

func (r RawConstraintKey) Parse() (*ConstraintKey, error)

type RawConstraintKeyRune

type RawConstraintKeyRune rune

func (RawConstraintKeyRune) IsSpecial

func (r RawConstraintKeyRune) IsSpecial() bool

type RawConstraintValue

type RawConstraintValue string

func (RawConstraintValue) Compile

func (r RawConstraintValue) Compile() (*regexp.Regexp, error)

func (RawConstraintValue) Match

func (r RawConstraintValue) Match(msg Message) bool

func (RawConstraintValue) Parse

func (r RawConstraintValue) Parse(isRegExp bool) (*ConstraintValue, error)

type RawConstraints

type RawConstraints map[RawConstraintKey]RawConstraintValue

type RawDefinition

type RawDefinition struct {
	Type           DefinitionType
	RawTemplates   []RawTemplate
	RawConstraints RawConstraints
	Aliases        Aliases
	AllowDuplicate bool
	Order          []DefinitionType
	Weight         DefinitionWeight
}

type RawTemplate

type RawTemplate string

type State

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

func NewState

func NewState(m MessageMap) *State

func (*State) AddPickedTemplate

func (s *State) AddPickedTemplate(defID DefinitionID, template *Template)

func (*State) Copy

func (s *State) Copy(order []DefinitionType) *State

func (*State) Get

func (s *State) Get(defType DefinitionType) (Message, bool)

func (*State) IsPickedTemplate

func (s *State) IsPickedTemplate(defID DefinitionID, template *Template) bool

func (*State) Set

func (s *State) Set(defType DefinitionType, msg Message)

func (*State) SetAlias

func (s *State) SetAlias(defID DefinitionID, aliasName AliasName, msg Message)

func (*State) SetByConstraint

func (s *State) SetByConstraint(constraint *Constraint) (bool, error)

func (*State) SetByConstraints

func (s *State) SetByConstraints(constraints *Constraints) (int, error)

func (*State) SetByDef

func (s *State) SetByDef(def *DefinitionWithAlias, msg Message) error

func (*State) Update

func (s *State) Update(def *DefinitionWithAlias, pickedTemplate *Template, msg Message) error

type Template

type Template struct {
	Raw     RawTemplate
	Depends *DefinitionTypes
	// contains filtered or unexported fields
}

func NewTemplate

func NewTemplate(rawTemplate RawTemplate, order []DefinitionType) (*Template, error)

func (*Template) Equals

func (t *Template) Equals(template *Template) bool

func (*Template) Execute

func (t *Template) Execute(state *State) (Message, error)

func (*Template) ExecuteWithIncompleteState

func (t *Template) ExecuteWithIncompleteState(state *State) (Message, []DefinitionType, error)

func (*Template) GetFirstUnsatisfiedDef

func (t *Template) GetFirstUnsatisfiedDef(state *State) (DefinitionType, bool)

func (*Template) IsSatisfiedState

func (t *Template) IsSatisfiedState(state *State) bool

type TemplatePicker

type TemplatePicker func(def *DefinitionWithAlias, state *State) (Templates, error)

type TemplateValidator

type TemplateValidator = func(template *Template, state *State) (bool, error)

func MaxStrLenValidator

func MaxStrLenValidator(maxLen int) TemplateValidator

type Templates

type Templates []*Template

func AscendingOrderTemplatePicker

func AscendingOrderTemplatePicker(def *DefinitionWithAlias, state *State) (Templates, error)

func NewTemplates

func NewTemplates(rawTemplates []RawTemplate, order []DefinitionType) (Templates, error)

func NotAllowAliasDuplicateTemplatePicker

func NotAllowAliasDuplicateTemplatePicker(def *DefinitionWithAlias, state *State) (Templates, error)

func RandomTemplatePicker

func RandomTemplatePicker(def *DefinitionWithAlias, state *State) (Templates, error)

func (*Templates) Add

func (t *Templates) Add(template *Template)

func (*Templates) Copy

func (t *Templates) Copy(order []DefinitionType) (Templates, error)

func (*Templates) DeleteByIndex

func (t *Templates) DeleteByIndex(i int)

func (*Templates) Has

func (t *Templates) Has(template *Template) bool

func (*Templates) PopRandom

func (t *Templates) PopRandom() (*Template, bool)

func (*Templates) Subtract

func (t *Templates) Subtract(templateList ...*Template) Templates

Jump to

Keyboard shortcuts

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