Source File
chain.go
Belonging Package
go.pact.im/x/process
package processimport ()// Chain returns a [Runner] instance that starts and runs processes by nesting// them in callbacks. If no processes are given, it returns [Nop] instance.func ( ...Runner) Runner {switch len() {case 0:return Nop()case 1:return [0]}return &chainRunner{}}type chainRunner struct {deps []Runner}func ( *chainRunner) ( context.Context, Callback) error {:= chainState{deps: .deps}return .Run(, )}type chainState struct {index intdeps []Runner // len(deps) >= 2main Callback}func ( *chainState) ( context.Context, Callback) error {switch .index {case 0:.main == .nextcase len(.deps) - 1:= .maindefault:= .next}:= .index.index++return .deps[].Run(, )}func ( *chainState) ( context.Context) error {return .Run(, nil)}
The pages are generated with Golds v0.7.6. (GOOS=linux GOARCH=amd64)