package main
import (
"context"
"time"
"github.com/joho/godotenv"
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() {
_ = godotenv .Load ()
}
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" : {},
"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 )
}
pipeCustom := &struct {
CustomState am .HandlerFinal
CustomEnd am .HandlerFinal
}{
CustomState : ampipe .Add (mach1 , mach2 , "Custom" , "" ),
CustomEnd : ampipe .Remove (mach1 , mach2 , "Custom" , "" ),
}
if err := mach1 .BindHandlers (pipeCustom ); err != nil {
panic (err )
}
time .Sleep (time .Second )
}
The pages are generated with Golds v0.8.2 . (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 .