Don't attempt to restart non-resettable actors
This commit is contained in:
@@ -236,8 +236,9 @@ func (this *environment) start(actor Actor) {
|
||||
go this.run(actor)
|
||||
}
|
||||
|
||||
// run runs the given actor, restarting it if it fails. This function will exit
|
||||
// when the actor's context is canceled. The actor will be removed from the
|
||||
// run runs the given actor. This function will exit
|
||||
// when the actor's context is canceled, or the actor has stopped or exited.
|
||||
// The actor will be removed from the
|
||||
// environment once this function exits, and the environment's wait group
|
||||
// counter will be decremented. note that this function will never increment the
|
||||
// wait group counter, so start should usually be used instead.
|
||||
@@ -349,6 +350,13 @@ func (this *environment) runRunnable(ctx context.Context, actor Runnable) (stopE
|
||||
if this.flags.crashOnError {
|
||||
panic(fmt.Sprint(err))
|
||||
}
|
||||
|
||||
// if an actor isn't resettable, don't reset
|
||||
// or restart it
|
||||
if _, ok := actor.(Resettable); !ok {
|
||||
stopErr = err
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// restart logic
|
||||
@@ -373,7 +381,8 @@ func (this *environment) runRunnable(ctx context.Context, actor Runnable) (stopE
|
||||
restartInterval = restartInitialInterval
|
||||
}
|
||||
|
||||
// reset if needed
|
||||
// reset if needed. this condition will always be true because
|
||||
// this code path is restricted to Resettable anyway
|
||||
if actor, ok := actor.(Resettable); ok {
|
||||
if this.Verb() { log.Printf("... [%s] resetting", typ) }
|
||||
func() {
|
||||
|
||||
4
run.go
4
run.go
@@ -52,8 +52,8 @@ var env environment
|
||||
//
|
||||
// 70. Running: Actors which implement [Runnable] or [RunShutdownable] are
|
||||
// run, each in their own goroutine. The environment is able to restart
|
||||
// actors which have failed, which entails resetting the actor if it
|
||||
// implements [Resettable], and running the actor again within the same
|
||||
// actors which have failed if they implement [Resettable], which entails
|
||||
// resetting the actor and running it again within the same
|
||||
// goroutine. If an actor does not run for a meaningful amount of time
|
||||
// after resetting/initialization before failing, it is considered erratic
|
||||
// and further attempts to restart it will be spaced by a limited,
|
||||
|
||||
Reference in New Issue
Block a user