package states
import (
"errors"
"fmt"
am "github.com/pancsta/asyncmachine-go/pkg/machine"
)
type ConnectedState = string
type ConnectedStatesDef struct {
ErrConnecting ConnectedState
Connecting ConnectedState
Connected ConnectedState
Disconnecting ConnectedState
Disconnected ConnectedState
*am .StatesBase
}
type ConnectedGroupsDef struct {
Connected S
}
var ConnectedSchema = am .Schema {
ssC .ErrConnecting : {Require : S {Exception }},
ssC .Connecting : {
Require : S {ssB .Start },
Remove : sgC .Connected ,
},
ssC .Connected : {
Require : S {ssB .Start },
Remove : sgC .Connected ,
},
ssC .Disconnecting : {Remove : sgC .Connected },
ssC .Disconnected : {
Auto : true ,
Remove : sgC .Connected ,
},
}
var (
ssC = am .NewStates (ConnectedStatesDef {})
sgC = am .NewStateGroups (ConnectedGroupsDef {
Connected : S {
ssC .Connecting , ssC .Connected , ssC .Disconnecting ,
ssC .Disconnected ,
},
})
ConnectedStates = ssC
ConnectedGroups = sgC
)
var ErrConnecting = errors .New ("error connecting" )
func AddErrConnecting (
event *am .Event , mach *am .Machine , err error , args am .A ,
) error {
err = fmt .Errorf ("%w: %w" , ErrConnecting , err )
mach .EvAddErrState (event , ssC .ErrConnecting , err , args )
return err
}
type ConnPoolState = string
type ConnPoolStatesDef struct {
ErrConnecting ConnPoolState
Connecting ConnPoolState
Connected ConnPoolState
ConnectedFully ConnPoolState
Disconnecting ConnPoolState
Disconnected ConnPoolState
*am .StatesBase
}
type ConnPoolGroupsDef struct {
Connected S
}
var ConnPoolSchema = am .Schema {
ssPc .ErrConnecting : {Require : S {Exception }},
ssPc .Disconnected : {
Remove : S {ssPc .Connecting , ssPc .ConnectedFully , ssPc .Disconnecting },
},
ssPc .Connecting : {
Require : S {ssB .Start },
Remove : S {ssPc .Disconnecting },
},
ssPc .Connected : {
Require : S {ssB .Start },
Remove : S {ssPc .Disconnected },
},
ssPc .ConnectedFully : {
Require : S {ssPc .Connected },
Remove : S {ssPc .Disconnected },
},
ssPc .Disconnecting : {
Remove : S {ssPc .ConnectedFully , ssPc .Connected , ssPc .Connecting },
},
}
var (
ssPc = am .NewStates (ConnPoolStatesDef {})
sgCp = am .NewStateGroups (ConnPoolGroupsDef {
Connected : S {ssPc .Connected , ssPc .Disconnected },
})
ConnPoolStates = ssPc
ConnPoolGroups = sgCp
)
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 .