28 lines
838 B
Go
28 lines
838 B
Go
// Example broken demonstrates how the environment will forcibly kill the
|
|
// program if an actor cannot shut down.
|
|
package main
|
|
|
|
import "os"
|
|
import "log"
|
|
import "context"
|
|
import "git.tebibyte.media/sashakoshka/camfish"
|
|
|
|
func main() {
|
|
camfish.Run("broken",
|
|
"Example broken demonstrates how the environment will " +
|
|
"forcibly kill the program if an actor cannot shut down",
|
|
new(broken))
|
|
}
|
|
|
|
// broken is an incorrectly implemented actor that cannot shut down.
|
|
type broken struct { }
|
|
var _ camfish.Runnable = new(broken)
|
|
func (this *broken) Type() string { return "broken" }
|
|
|
|
func (this *broken) Run(ctx context.Context) error {
|
|
log.Println("(i) [broken] wait for approximately 8 minutes")
|
|
log.Printf("(i) [broken] if impatient, run: kill -9 %d", os.Getpid())
|
|
<- (chan struct { })(nil)
|
|
return ctx.Err() // unreachable, of course
|
|
}
|