Demos & Examples
-> go back to monorepo /
Live Debugging Session
Interactively use the TUI debugger with data pre-generated by libp2p-pubsub-simulator in:
States structure
var (
states = am.Struct{
// input states
InputPush: {},
InputCoin: {},
// "state" states
Locked: {
Auto: true,
Remove: groupUnlocked,
},
Unlocked: {Remove: groupUnlocked},
}
)
States structure
var (
states = am.Struct{
// input states
Input: {Multi: true},
// action states
Start: {Add: am.S{StepX}},
// "state" states
StepX: {Remove: groupSteps},
Step0: {Remove: groupSteps},
Step1: {Remove: groupSteps},
Step2: {Remove: groupSteps},
Step3: {Remove: groupSteps},
}
)
States structure
// States map defines relations and properties of states (for files).
var States = am.Struct{
Init: {Add: S{Watching}},
Watching: {
Add: S{Init},
After: S{Init},
},
ChangeEvent: {
Multi: true,
Require: S{Watching},
},
Refreshing: {
Multi: true,
Remove: S{AllRefreshed},
},
Refreshed: {Multi: true},
AllRefreshed: {},
}
// StatesDir map defines relations and properties of states (for directories).
var StatesDir = am.Struct{
Refreshing: {Remove: groupRefreshed},
Refreshed: {Remove: groupRefreshed},
DirDebounced: {Remove: groupRefreshed},
DirCached: {},
}
// Groups of mutually exclusive states.
var groupRefreshed = S{Refreshing, Refreshed, DirDebounced}
States structure
// States map defines relations and properties of states.
var States = am.Struct{
CreatingExpense: {Remove: GroupExpense},
ExpenseCreated: {Remove: GroupExpense},
WaitingForApproval: {
Auto: true,
Remove: GroupApproval,
},
ApprovalGranted: {Remove: GroupApproval},
PaymentInProgress: {
Auto: true,
Remove: GroupPayment,
},
PaymentCompleted: {Remove: GroupPayment},
}
States structure
// States map defines relations and properties of states.
var States = am.Struct{
DownloadingFile: {Remove: GroupFileDownloaded},
FileDownloaded: {Remove: GroupFileDownloaded},
ProcessingFile: {
Auto: true,
Require: S{FileDownloaded},
Remove: GroupFileProcessed,
},
FileProcessed: {Remove: GroupFileProcessed},
UploadingFile: {
Auto: true,
Require: S{FileProcessed},
Remove: GroupFileUploaded,
},
FileUploaded: {Remove: GroupFileUploaded},
}
// Groups of mutually exclusive states.
var (
GroupFileDownloaded = S{DownloadingFile, FileDownloaded}
GroupFileProcessed = S{ProcessingFile, FileProcessed}
GroupFileUploaded = S{UploadingFile, FileUploaded}
)
Case Studies
Several case studies are available to show how to implement various types of state machines, measure performance and produce
a lot of inspectable data.
monorepo
Go back to the monorepo root to continue reading.