statemachine

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

This file is generated by VectorSigma. DO NOT EDIT.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action struct {
	Name    ActionName
	Params  []string
	Execute func(...string) error
}

Action represents a function that can be executed in a state and may return an error.

type ActionName

type ActionName string
const (
	CreateOutputFolder     ActionName = "CreateOutputFolder"
	ExtractUML             ActionName = "ExtractUML"
	FilterGeneratedFiles   ActionName = "FilterGeneratedFiles"
	FormatCode             ActionName = "FormatCode"
	GenerateModuleFiles    ActionName = "GenerateModuleFiles"
	GenerateStateMachine   ActionName = "GenerateStateMachine"
	Initialize             ActionName = "Initialize"
	LoadInput              ActionName = "LoadInput"
	MakeIncrementalUpdates ActionName = "MakeIncrementalUpdates"
	ParseUML               ActionName = "ParseUML"
	WriteGeneratedFiles    ActionName = "WriteGeneratedFiles"
)

type CompositeState

type CompositeState struct {
	InitialState StateName
	StateConfigs map[StateName]StateConfig
}

type Context

type Context struct {
	Logger    *slog.Logger // Do NOT delete this!
	Generator *generator.Generator
}

A struct that holds the items needed for the actions to do their work. Things like client libraries and loggers, go here.

type ExtendedState

type ExtendedState struct {
	GeneratedFiles     map[string]GeneratedFile
	Init               bool
	PackageExits       bool
	Operator           bool
	APIVersion         string
	APIKind            string
	Group              string
	Input              string
	InputData          string
	Module             string
	Output             string
	Package            string
	Error              error
	VectorSigmaVersion string
}

A struct that holds the "extended state" of the state machine, including data being fetched and read. This should only be modified by actions, while guards should only read the extended state to assess their value.

type GeneratedFile

type GeneratedFile struct {
	Content           []byte
	IncrementalChange bool
}

type Guard

type Guard struct {
	Name   GuardName
	Check  func() bool
	Action *Action
}

Guard represents a function that returns a boolean indicating if a transition should occur.

type GuardName

type GuardName string
const (
	IsError              GuardName = "IsError"
	IsInitializingModule GuardName = "IsInitializingModule"
	IsMarkdown           GuardName = "IsMarkdown"
	PackageExists        GuardName = "PackageExists"
)

type StateConfig

type StateConfig struct {
	Actions     []Action
	Guards      []Guard
	Transitions map[int]StateName // Maps guard index to the next state
	Composite   CompositeState
}

StateConfig holds the actions and guards for a state.

type StateName

type StateName string
const (
	CreatingInternalOutputFolder StateName = "CreatingInternalOutputFolder"
	CreatingOutputFolder         StateName = "CreatingOutputFolder"
	ExtractingUML                StateName = "ExtractingUML"
	FilteringGeneratedFiles      StateName = "FilteringGeneratedFiles"
	FinalState                   StateName = "FinalState"
	FormattingCode               StateName = "FormattingCode"
	GeneratingModuleFiles        StateName = "GeneratingModuleFiles"
	GeneratingStateMachine       StateName = "GeneratingStateMachine"
	InitialState                 StateName = "InitialState"
	Initializing                 StateName = "Initializing"
	LoadingInput                 StateName = "LoadingInput"
	MakingIncrementalUpdates     StateName = "MakingIncrementalUpdates"
	ParsingUML                   StateName = "ParsingUML"
	WritingGeneratedFiles        StateName = "WritingGeneratedFiles"
)

type VectorSigma

type VectorSigma struct {
	Context       *Context
	CurrentState  StateName
	ExtendedState *ExtendedState
	StateConfigs  map[StateName]StateConfig
}

VectorSigma represents the Finite State Machine (fsm) for VectorSigma.

func New

func New() *VectorSigma

New initializes a new FSM.

func (*VectorSigma) CreateOutputFolderAction

func (fsm *VectorSigma) CreateOutputFolderAction(params ...string) error

+vectorsigma:action:CreateOutputFolder

func (*VectorSigma) ExtractUMLAction

func (fsm *VectorSigma) ExtractUMLAction(_ ...string) error

+vectorsigma:action:ExtractUML

func (*VectorSigma) FilterGeneratedFilesAction

func (fsm *VectorSigma) FilterGeneratedFilesAction(_ ...string) error

+vectorsigma:action:FilterGeneratedFiles

func (*VectorSigma) FormatCodeAction

func (fsm *VectorSigma) FormatCodeAction(_ ...string) error

+vectorsigma:action:FormatCode

func (*VectorSigma) GenerateModuleFilesAction

func (fsm *VectorSigma) GenerateModuleFilesAction(_ ...string) error

+vectorsigma:action:GenerateModuleFiles

func (*VectorSigma) GenerateStateMachineAction

func (fsm *VectorSigma) GenerateStateMachineAction(_ ...string) error

+vectorsigma:action:GenerateStateMachine

func (*VectorSigma) InitializeAction

func (fsm *VectorSigma) InitializeAction(_ ...string) error

+vectorsigma:action:Initialize

func (*VectorSigma) IsErrorGuard

func (fsm *VectorSigma) IsErrorGuard() bool

+vectorsigma:guard:IsError

func (*VectorSigma) IsInitializingModuleGuard

func (fsm *VectorSigma) IsInitializingModuleGuard() bool

+vectorsigma:guard:IsInitializingModule

func (*VectorSigma) IsMarkdownGuard

func (fsm *VectorSigma) IsMarkdownGuard() bool

+vectorsigma:guard:IsMarkdown

func (*VectorSigma) LoadInputAction

func (fsm *VectorSigma) LoadInputAction(_ ...string) error

+vectorsigma:action:LoadInput

func (*VectorSigma) MakeIncrementalUpdatesAction

func (fsm *VectorSigma) MakeIncrementalUpdatesAction(_ ...string) error

+vectorsigma:action:MakeIncrementalUpdates

func (*VectorSigma) PackageExistsGuard

func (fsm *VectorSigma) PackageExistsGuard() bool

+vectorsigma:guard:PackageExists

func (*VectorSigma) ParseUMLAction

func (fsm *VectorSigma) ParseUMLAction(_ ...string) error

+vectorsigma:action:ParseUML

func (*VectorSigma) Run

func (fsm *VectorSigma) Run() error

Run handles the state transitions based on the current state.

func (*VectorSigma) WriteGeneratedFilesAction

func (fsm *VectorSigma) WriteGeneratedFilesAction(_ ...string) error

+vectorsigma:action:WriteGeneratedFiles

Jump to

Keyboard shortcuts

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