fz

package module
v0.0.0-...-3a4fc69 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2022 License: Apache-2.0 Imports: 39 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrActionNotRegistered = errors.New("action not registered")
View Source
var KVResultNotFound = kvResultNotFound{}
View Source
var KVResultTimeout = kvResultTimeout{}
View Source
var PorcupineKVModel = porcupine.Model{
	Partition:      porcupine.NoPartition,
	PartitionEvent: porcupine.NoPartitionEvent,

	Init: func() any {

		return make(map[any]any)
	},

	Step: func(state any, input any, output any) (ok bool, newState any) {
		m := state.(map[any]any)
		arg := input.([2]any)
		op := arg[0].(string)
		key := arg[1]

		switch op {

		case "get":
			if output == KVResultNotFound {
				_, ok := m[key]
				return !ok, state
			} else if output == KVResultTimeout {
				return true, state
			}
			return m[key] == output, state

		case "set":
			if output == KVResultTimeout {
				return true, state
			}
			newMap := make(map[any]any, len(m)+1)
			for k, v := range m {
				newMap[k] = v
			}
			newMap[key] = output
			return true, newMap

		}

		panic("impossible")
	},

	Equal: func(state1, state2 any) bool {
		m1 := state1.(map[any]any)
		m2 := state2.(map[any]any)
		for k, v := range m1 {
			if v != m2[k] {
				return false
			}
		}
		for k, v := range m2 {
			if v != m1[k] {
				return false
			}
		}
		return true
	},
}

Functions

func NewScope

func NewScope(defs ...any) dscope.Scope

func RandBetween

func RandBetween[T number, T2 number](target *T, lower T2, upper T2)

func RandBool

func RandBool[T ~bool](target *T)

func RegisterAction

func RegisterAction(value any)

Types

type Action

type Action interface {
}

func RandomActionTree

func RandomActionTree(
	makers []ActionMaker,
	numActions int,
) Action

type ActionMaker

type ActionMaker = func() Action

type AddReport

type AddReport func(...Report)

type AddScriptDef

type AddScriptDef func(any)

type CleanTempDir

type CleanTempDir func(
	threshold time.Duration,
)

type Cleanup

type Cleanup func()

func (Cleanup) IsReducer

func (_ Cleanup) IsReducer()

type ClearTestDataFile

type ClearTestDataFile func(
	category string,
	extension string,
) (
	err error,
)

type CloseNode

type CloseNode func(id NodeID) error

type ConfigItems

type ConfigItems []any

func (ConfigItems) Reduce

func (_ ConfigItems) Reduce(_ dscope.Scope, vs []reflect.Value) reflect.Value

type CreatedAt

type CreatedAt string

type Debug9P

type Debug9P bool

type Def

type Def struct{}

func (Def) ClearTestDataFile

func (_ Def) ClearTestDataFile(
	getFilePath TestDataFilePath,
	id uuid.UUID,
) ClearTestDataFile

func (Def) CloseNode

func (_ Def) CloseNode() CloseNode

func (Def) CreatedAt

func (_ Def) CreatedAt() CreatedAt

func (Def) CreatedAtConfigItem

func (_ Def) CreatedAtConfigItem(
	t CreatedAt,
) ConfigItems

func (Def) Debug9P

func (_ Def) Debug9P() Debug9P

func (Def) DoAction

func (_ Def) DoAction(
	do Do,
	nextThreadID NextThreadID,
) (
	doAction doAction,
)

func (Def) DumbCleanup

func (_ Def) DumbCleanup() Cleanup

func (Def) Execute

func (_ Def) Execute(
	nodes Nodes,
	numNodes NumNodes,
	mainAction MainAction,
	ops Operators,
	doAction doAction,
	scope dscope.Scope,
	nextThreadID NextThreadID,
	closeNode CloseNode,
	processReports processReports,
	logger Logger,
	timeout ExecuteTimeout,
) Execute

func (Def) ExecuteFuncs

func (_ Def) ExecuteFuncs() (
	nodes Nodes,
	do Do,
)

func (Def) ExecuteTimeout

func (_ Def) ExecuteTimeout() ExecuteTimeout

func (Def) FilterPacket

func (_ Def) FilterPacket() FilterPacket

func (Def) GetPort

func (_ Def) GetPort(
	portRange PortRange,
	infos PortInfos,
) (
	get GetPort,
	getStr GetPortStr,
)

func (Def) GlobTestDataFiles

func (_ Def) GlobTestDataFiles(
	testDataDir TestDataDir,
) GlobTestDataFiles

func (Def) IsTesting

func (_ Def) IsTesting() IsTesting

func (Def) LoadScript

func (_ Def) LoadScript(
	builtins ScriptBuiltins,
	get GetScriptDefs,
) LoadScript

func (Def) Logger

func (_ Def) Logger(
	testDataFilePath TestDataFilePath,
	id UUID,
	isTesting IsTesting,
) Logger

func (Def) MainAction

func (_ Def) MainAction() (m MainAction)

func (Def) MainActionConfigItem

func (_ Def) MainActionConfigItem(
	action MainAction,
) ConfigItems

func (Def) NamedConfigItems

func (_ Def) NamedConfigItems(
	items ConfigItems,
) (
	nameds []NamedConfigItem,
	m map[string]NamedConfigItem,
)

func (Def) NetworkHost

func (_ Def) NetworkHost(
	id uuid.UUID,
	model NetworkModel,
	wt RootWaitTree,
	filter FilterPacket,
) (
	get GetNetworkHost,
	cleanup Cleanup,
)

func (Def) NetworkModel

func (_ Def) NetworkModel() NetworkModel

func (Def) NewPorcupineChecker

func (_ Def) NewPorcupineChecker(
	genVisual PorcupineAlwaysGenerateVisualization,
	write WriteTestDataFile,
	clear ClearTestDataFile,
	report AddReport,
) NewPorcupineChecker

func (Def) NextThreadID

func (_ Def) NextThreadID() NextThreadID

func (Def) NodeConfigSources

func (_ Def) NodeConfigSources() (_ NodeConfigSources)

func (Def) NodeConfigSourcesItem

func (_ Def) NodeConfigSourcesItem(
	srcs NodeConfigSources,
) ConfigItems

func (Def) NumNodes

func (_ Def) NumNodes() NumNodes

func (Def) NumNodesConfigItem

func (_ Def) NumNodesConfigItem(
	num NumNodes,
) ConfigItems

func (Def) Operators

func (_ Def) Operators() Operators

func (Def) PorcupineAlwaysGenerateVisualization

func (_ Def) PorcupineAlwaysGenerateVisualization() PorcupineAlwaysGenerateVisualization

func (Def) PortInfos

func (_ Def) PortInfos() PortInfos

func (Def) PortRange

func (_ Def) PortRange() PortRange

func (Def) ProcessReports

func (_ Def) ProcessReports(
	clearFile ClearTestDataFile,
	getReports GetAllReports,
	writeFile WriteTestDataFile,
	testDataDir TestDataDir,
	id uuid.UUID,
	testDataFilePath TestDataFilePath,
	logger Logger,
) processReports

func (Def) ReadConfig

func (_ Def) ReadConfig(
	nameds map[string]NamedConfigItem,
) ReadConfig

func (Def) Report

func (_ Def) Report() (
	add AddReport,
	getAll GetAllReports,
	get GetReports,
)

func (Def) RootWaitTree

func (_ Def) RootWaitTree() (
	wt RootWaitTree,
	cleanup Cleanup,
)

func (Def) ScriptBuiltins

func (_ Def) ScriptBuiltins(
	add AddScriptDef,
) ScriptBuiltins

func (Def) ScriptDefs

func (_ Def) ScriptDefs() (
	add AddScriptDef,
	get GetScriptDefs,
)

func (Def) Setup9P

func (_ Def) Setup9P(
	getHost GetNetworkHost,
	getPort GetPortStr,
	wt RootWaitTree,
	debug Debug9P,
) Setup9P

func (Def) SetupFuse

func (_ Def) SetupFuse(
	logger Logger,
) SetupFuse

func (Def) TempDir

func (_ Def) TempDir(
	logger Logger,
	model TempDirModel,
	setupFuse SetupFuse,
	setup9P Setup9P,
) (
	get GetTempDir,
	cleanup Cleanup,
	cleanDir CleanTempDir,
)

func (Def) TempDirModel

func (_ Def) TempDirModel() TempDirModel

func (Def) TestDataDir

func (_ Def) TestDataDir() (dir TestDataDir)

func (Def) TestDataFilePath

func (_ Def) TestDataFilePath(
	dir TestDataDir,
	id uuid.UUID,
) TestDataFilePath

func (Def) TestDataFilePathToUUID

func (_ Def) TestDataFilePathToUUID() TestDataFilePathToUUID

func (Def) UUID

func (_ Def) UUID() UUID

func (Def) UUIDConfigItem

func (_ Def) UUIDConfigItem(
	id uuid.UUID,
) ConfigItems

func (Def) WriteConfig

func (_ Def) WriteConfig(
	nameds []NamedConfigItem,
) WriteConfig

func (Def) WriteTestDataFile

func (_ Def) WriteTestDataFile(
	dir TestDataDir,
	getFilePath TestDataFilePath,
	id uuid.UUID,
) WriteTestDataFile

type Do

type Do func(threadID int64, action Action) error

type Execute

type Execute func() error

type ExecuteTimeout

type ExecuteTimeout time.Duration

type FilterPacket

type FilterPacket func(packet []byte) []byte

type GetAllReports

type GetAllReports func() []Report

type GetNetworkHost

type GetNetworkHost func() string

type GetPort

type GetPort func(nodeID NodeID, host string) uint16

type GetPortStr

type GetPortStr func(nodeID NodeID, host string) string

type GetReports

type GetReports func(kind string) []Report

type GetScriptDefs

type GetScriptDefs func() []any

type GetTempDir

type GetTempDir func() string

type GlobTestDataFiles

type GlobTestDataFiles func(
	category string,
	extension string,
) (
	paths []string,
	err error,
)

type IsTesting

type IsTesting bool

type LoadScript

type LoadScript func() (
	defs []any,
	err error,
)

type Logger

type Logger = *zap.Logger

type MainAction

type MainAction struct {
	Action Action
}

func (*MainAction) UnmarshalXML

func (t *MainAction) UnmarshalXML(d *xml.Decoder, start xml.StartElement) (err error)

type NamedConfigItem

type NamedConfigItem struct {
	Name  string
	Value any
}

type NetworkModel

type NetworkModel string

type NewPorcupineChecker

type NewPorcupineChecker func(
	model porcupine.Model,
	getOps func() []porcupine.Operation,
	events *[]porcupine.Event,
	timeout time.Duration,
) Operator

type NextThreadID

type NextThreadID func() int64

type Node

type Node interface{}

type NodeConfigSource

type NodeConfigSource struct {
	String string `xml:",cdata"`
}

type NodeConfigSources

type NodeConfigSources struct {
	Sources []NodeConfigSource `xml:"Source"`
}

type NodeID

type NodeID int

type Nodes

type Nodes = []Node

type NumNodes

type NumNodes int

type Operator

type Operator struct {
	Finally func()

	BeforeDo func()
	AfterDo  func()

	BeforeClose func()
	AfterClose  func()
}

type Operators

type Operators []Operator

func (Operators) IsReducer

func (c Operators) IsReducer()

type ParallelAction

type ParallelAction struct {
	Actions []Action
}

func Par

func Par(actions ...Action) ParallelAction

func (ParallelAction) MarshalXML

func (s ParallelAction) MarshalXML(e *xml.Encoder, start xml.StartElement) (err error)

func (*ParallelAction) UnmarshalXML

func (s *ParallelAction) UnmarshalXML(d *xml.Decoder, start xml.StartElement) (err error)

type PorcupineAlwaysGenerateVisualization

type PorcupineAlwaysGenerateVisualization bool

type PortInfo

type PortInfo struct {
	Port   uint16
	NodeID NodeID
}

type PortInfos

type PortInfos struct {
	*sync.Map
}

type PortRange

type PortRange [2]uint16

type ReadConfig

type ReadConfig func(r io.Reader) ([]any, error)

type Report

type Report struct {
	Kind string
	Desc string
}

type RootWaitTree

type RootWaitTree struct {
	*pr.WaitTree
}

type ScriptBuiltins

type ScriptBuiltins starlark.StringDict

func (ScriptBuiltins) IsReducer

func (_ ScriptBuiltins) IsReducer()

type SequentialAction

type SequentialAction struct {
	Actions []Action
}

func RandSeq

func RandSeq(makers []ActionMaker, num int) SequentialAction

func Seq

func Seq(actions ...Action) SequentialAction

func (SequentialAction) MarshalXML

func (s SequentialAction) MarshalXML(e *xml.Encoder, start xml.StartElement) (err error)

func (*SequentialAction) UnmarshalXML

func (s *SequentialAction) UnmarshalXML(d *xml.Decoder, start xml.StartElement) (err error)

type Setup9P

type Setup9P func(
	mountPoint string,
) (
	err error,
	end func() error,
)

type SetupFuse

type SetupFuse func(
	mountPoint string,
) (
	err error,
	end func() error,
)

type TempDirModel

type TempDirModel string

type TestDataDir

type TestDataDir string

type TestDataFilePath

type TestDataFilePath func(
	id uuid.UUID,
	category string,
	extension string,
) string

type TestDataFilePathToUUID

type TestDataFilePathToUUID func(
	path string,
) (
	id uuid.UUID,
	err error,
)

type UUID

type UUID = uuid.UUID

type WriteConfig

type WriteConfig func(w io.Writer) error

type WriteTestDataFile

type WriteTestDataFile func(
	category string,
	extension string,
) (
	file *os.File,
	err error,
	done func() error,
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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