Documentation ¶
Index ¶
- Variables
- type Option
- type Shutter
- func (s *Shutter) Err() error
- func (s *Shutter) IsTerminated() bool
- func (s *Shutter) IsTerminating() bool
- func (s *Shutter) LockedInit(fn func() error) (err error)
- func (s *Shutter) OnTerminated(f func(error))
- func (s *Shutter) OnTerminating(f func(error))
- func (s *Shutter) Shutdown(err error)
- func (s *Shutter) Terminated() <-chan struct{}
- func (s *Shutter) Terminating() <-chan struct{}
Constants ¶
This section is empty.
Variables ¶
var ErrShutterWasAlreadyDown = errors.New("saferun was called on an already-shutdown shutter")
Functions ¶
This section is empty.
Types ¶
type Option ¶ added in v1.4.1
type Option = func(shutter *Shutter)
func RegisterOnTerminated ¶ added in v1.4.1
registers a function to be called on terminated
func RegisterOnTerminating ¶ added in v1.4.1
registers a function to be called on terminating
type Shutter ¶
type Shutter struct {
// contains filtered or unexported fields
}
func (*Shutter) IsTerminated ¶ added in v1.4.1
func (*Shutter) IsTerminating ¶ added in v1.4.1
func (*Shutter) LockedInit ¶ added in v1.4.1
LockedInit allows you to run a function only if the shutter is not down yet, with the assurance that the it will not run its callback functions during the execution of your function.
This is useful to prevent race conditions, where the func given to "LockedInit" should increase a counter and the func given to OnShutdown should decrease it.
WARNING: never call Shutdown from within your LockedInit function, it will deadlock. Also, keep these init functions as short as possible.
NOTE: This was previously named SafeRun
func (*Shutter) OnTerminated ¶ added in v1.4.1
OnTerminated registers an additional handler to be triggered on `Shutdown()`. These calls will be blocking and will occur when the shutter has shutdown
func (*Shutter) OnTerminating ¶ added in v1.4.1
OnTerminating registers an additional handler to be triggered on `Shutdown()`. These calls will be blocking and will occur when the shutter is in the process of shutting down.
func (*Shutter) Terminated ¶ added in v1.4.1
func (s *Shutter) Terminated() <-chan struct{}
func (*Shutter) Terminating ¶ added in v1.4.1
func (s *Shutter) Terminating() <-chan struct{}