package main
import (
"context"
"fmt"
"time"
amhelp "github.com/pancsta/asyncmachine-go/pkg/helpers"
am "github.com/pancsta/asyncmachine-go/pkg/machine"
ampipe "github.com/pancsta/asyncmachine-go/pkg/states/pipes"
)
func init() {
}
func main() {
ctx := context .Background ()
mach1 := am .New (ctx , am .Schema {
"Ready" : {},
"Foo" : {},
"Bar" : {},
"Custom" : {},
"Healthcheck" : {Multi : true },
}, &am .Opts {LogLevel : am .LogOps , Id : "source" })
mach2 := am .New (ctx , am .Schema {
"Ready" : {},
"Foo" : {},
"Bar" : {},
"Custom" : {},
"Healthcheck" : {Multi : true },
}, &am .Opts {LogLevel : am .LogOps , Id : "destination" })
amhelp .MachDebugEnv (mach1 )
amhelp .MachDebugEnv (mach2 )
_ , err := ampipe .BindReady (mach1 , mach2 , "" , "" )
if err != nil {
panic (err )
}
_, err = ampipe .BindErr (mach1 , mach2 , "" )
if err != nil {
panic (err )
}
_, err = ampipe .Bind (mach1 , mach2 , "Custom" , "" , "" )
if err != nil {
panic (err )
}
_, err = ampipe .BindMany (mach1 , mach2 , am .S {"Foo" , "Bar" }, nil )
if err != nil {
panic (err )
}
mach1 .Add1 ("Ready" , nil )
mach1 .Add (am .S {"Foo" , "Bar" }, nil )
err = amhelp .WaitForAll (ctx , time .Second , mach2 .When (am .S {"Foo" , "Bar" , "Ready" }, nil ))
if err != nil {
panic (err )
}
fmt .Println ("done" )
}
The pages are generated with Golds v0.8.4 . (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu .
PR and bug reports are welcome and can be submitted to the issue list .
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds .