Documentation ¶
Index ¶
- type Alias
- type AliasMap
- type AliasName
- type Aliases
- type Constraint
- type ConstraintKey
- type ConstraintValue
- type Constraints
- func (c *Constraints) AreSatisfied(state *State) (bool, error)
- func (c *Constraints) Get(key RawConstraintKey) (RawConstraintValue, bool)
- func (c *Constraints) GetByDefinitionType(defType DefinitionType) (RawConstraintValue, bool)
- func (c *Constraints) GetPriority(state *State) int
- func (c *Constraints) ListUnsatisfied(state *State) (*Constraints, error)
- func (c *Constraints) Set(rawKey RawConstraintKey, value RawConstraintValue) error
- type Definition
- func ConstraintsSatisfiedDefinitionPicker(definitions *Definitions, state *State) ([]*Definition, error)
- func NewDefinition(rawDefinition *RawDefinition) (*Definition, error)
- func RandomWithWeightDefinitionPicker(definitions *Definitions, state *State) ([]*Definition, error)
- func SortByConstraintPriorityDefinitionPicker(definitions *Definitions, state *State) ([]*Definition, error)
- type DefinitionID
- type DefinitionPicker
- type DefinitionRepository
- func (d *DefinitionRepository) Add(rawDefs ...*RawDefinition) error
- func (d *DefinitionRepository) Generate(defType DefinitionType, initialState *State, num uint) (messages []Message, err error)
- func (d *DefinitionRepository) List(defType DefinitionType) (defs Definitions)
- func (d *DefinitionRepository) Start(defType DefinitionType, initialState *State) (msgChan chan Message, errChan chan error)
- type DefinitionRepositoryOption
- type DefinitionType
- type DefinitionTypes
- type DefinitionWeight
- type DefinitionWithAlias
- type Definitions
- type Message
- type MessageMap
- type PickedTemplateMap
- type RawConstraintKey
- type RawConstraintKeyRune
- type RawConstraintValue
- type RawConstraints
- type RawDefinition
- type RawTemplate
- type State
- func (s *State) AddPickedTemplate(defID DefinitionID, template *Template)
- func (s *State) Copy(order []DefinitionType) *State
- func (s *State) Get(defType DefinitionType) (Message, bool)
- func (s *State) IsPickedTemplate(defID DefinitionID, template *Template) bool
- func (s *State) Set(defType DefinitionType, msg Message)
- func (s *State) SetAlias(defID DefinitionID, aliasName AliasName, msg Message)
- func (s *State) SetByConstraint(constraint *Constraint) (bool, error)
- func (s *State) SetByConstraints(constraints *Constraints) (int, error)
- func (s *State) SetByDef(def *DefinitionWithAlias, msg Message) error
- func (s *State) Update(def *DefinitionWithAlias, pickedTemplate *Template, msg Message) error
- type Template
- func (t *Template) Equals(template *Template) bool
- func (t *Template) Execute(state *State) (Message, error)
- func (t *Template) ExecuteWithIncompleteState(state *State) (Message, []DefinitionType, error)
- func (t *Template) GetFirstUnsatisfiedDef(state *State) (DefinitionType, bool)
- func (t *Template) IsSatisfiedState(state *State) bool
- type TemplatePicker
- type TemplateValidator
- type Templates
- func AscendingOrderTemplatePicker(def *DefinitionWithAlias, state *State) (Templates, error)
- func NewTemplates(rawTemplates []RawTemplate, order []DefinitionType) (Templates, error)
- func NotAllowAliasDuplicateTemplatePicker(def *DefinitionWithAlias, state *State) (Templates, error)
- func RandomTemplatePicker(def *DefinitionWithAlias, state *State) (Templates, error)
- func (t *Templates) Add(template *Template)
- func (t *Templates) Copy(order []DefinitionType) (Templates, error)
- func (t *Templates) DeleteByIndex(i int)
- func (t *Templates) Has(template *Template) bool
- func (t *Templates) PopRandom() (*Template, bool)
- func (t *Templates) Subtract(templateList ...*Template) Templates
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 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 (c *Constraints) Get(key RawConstraintKey) (RawConstraintValue, bool)
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 NewDefinitionRepository ¶
func NewDefinitionRepository(opt *DefinitionRepositoryOption) *DefinitionRepository
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 MessageMap ¶
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) 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) 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)
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) ExecuteWithIncompleteState ¶
func (t *Template) ExecuteWithIncompleteState(state *State) (Message, []DefinitionType, error)
func (*Template) GetFirstUnsatisfiedDef ¶
func (t *Template) GetFirstUnsatisfiedDef(state *State) (DefinitionType, bool)
func (*Template) IsSatisfiedState ¶
type TemplatePicker ¶
type TemplatePicker func(def *DefinitionWithAlias, state *State) (Templates, error)
type TemplateValidator ¶
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) DeleteByIndex ¶
Click to show internal directories.
Click to hide internal directories.