Add the RunShutdowner actor interface
This commit is contained in:
parent
e1ccb4d6e8
commit
bbe833bb53
20
actor.go
20
actor.go
@ -88,3 +88,23 @@ type Resettable interface {
|
|||||||
// invalid and any process which depends on it should be shut down.
|
// invalid and any process which depends on it should be shut down.
|
||||||
Reset(ctx context.Context) error
|
Reset(ctx context.Context) error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// RunShutdownable is any object that needs a context in order to shut down.
|
||||||
|
// Actors which implement this interface cannot implement the Runnable
|
||||||
|
// interface. This can be used to run an http.Server as an actor.
|
||||||
|
type RunShutdownable interface {
|
||||||
|
// Run is similar to [Runnable.Run], but takes no context and blocks
|
||||||
|
// until Shutdown has run and exited. It may also return when something
|
||||||
|
// goes wrong and it cannot continue, in which case it must return a
|
||||||
|
// non-nil error explaining why. Shutdown does not need to be called in
|
||||||
|
// the latter case.
|
||||||
|
Run() error
|
||||||
|
// Shutdown shuts down the actor. It must be called while Run is
|
||||||
|
// running, and it must unblock Run even if it fails, the context
|
||||||
|
// expires, it returns an error, etc. Shutdown must return when or
|
||||||
|
// before the context expires, and must return ctx.Err if there is no
|
||||||
|
// other error to be returned. If Shutdown returns any error, the object
|
||||||
|
// must be treated as invalid and any other process which depends on it
|
||||||
|
// should be shut down.
|
||||||
|
Shutdown(ctx context.Context) error
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user