examples/broken: Demonstrate new fix working
This commit is contained in:
parent
bae737e6b8
commit
641624ef3b
27
examples/broken/main.go
Normal file
27
examples/broken/main.go
Normal file
@ -0,0 +1,27 @@
|
||||
// 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
|
||||
}
|
Loading…
Reference in New Issue
Block a user