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)
|
go this.run(actor)
|
||||||
}
|
}
|
||||||
|
|
||||||
// run runs the given actor, restarting it if it fails. This function will exit
|
// run runs the given actor. This function will exit
|
||||||
// when the actor's context is canceled. The actor will be removed from the
|
// 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
|
// environment once this function exits, and the environment's wait group
|
||||||
// counter will be decremented. note that this function will never increment the
|
// counter will be decremented. note that this function will never increment the
|
||||||
// wait group counter, so start should usually be used instead.
|
// 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 {
|
if this.flags.crashOnError {
|
||||||
panic(fmt.Sprint(err))
|
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
|
// restart logic
|
||||||
@@ -373,7 +381,8 @@ func (this *environment) runRunnable(ctx context.Context, actor Runnable) (stopE
|
|||||||
restartInterval = restartInitialInterval
|
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 actor, ok := actor.(Resettable); ok {
|
||||||
if this.Verb() { log.Printf("... [%s] resetting", typ) }
|
if this.Verb() { log.Printf("... [%s] resetting", typ) }
|
||||||
func() {
|
func() {
|
||||||
|
|||||||
4
run.go
4
run.go
@@ -52,8 +52,8 @@ var env environment
|
|||||||
//
|
//
|
||||||
// 70. Running: Actors which implement [Runnable] or [RunShutdownable] are
|
// 70. Running: Actors which implement [Runnable] or [RunShutdownable] are
|
||||||
// run, each in their own goroutine. The environment is able to restart
|
// run, each in their own goroutine. The environment is able to restart
|
||||||
// actors which have failed, which entails resetting the actor if it
|
// actors which have failed if they implement [Resettable], which entails
|
||||||
// implements [Resettable], and running the actor again within the same
|
// resetting the actor and running it again within the same
|
||||||
// goroutine. If an actor does not run for a meaningful amount of time
|
// goroutine. If an actor does not run for a meaningful amount of time
|
||||||
// after resetting/initialization before failing, it is considered erratic
|
// after resetting/initialization before failing, it is considered erratic
|
||||||
// and further attempts to restart it will be spaced by a limited,
|
// and further attempts to restart it will be spaced by a limited,
|
||||||
|
|||||||
Reference in New Issue
Block a user