Documentation
¶
Overview ¶
canstop provides a way to manage the lifecycle of long-running processes that need to be able to shut down gracefully.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AcceptTCPWithTimeout ¶
Types ¶
type ConnWrapper ¶
type ErrorCounter ¶
func NewErrorCounter ¶
func NewErrorCounter(size int) *ErrorCounter
func (*ErrorCounter) AddTimestamp ¶
func (self *ErrorCounter) AddTimestamp(t time.Time)
func (*ErrorCounter) CalculateDelay ¶
func (self *ErrorCounter) CalculateDelay() (delay time.Duration)
type Lifecycle ¶
type Lifecycle struct {
// contains filtered or unexported fields
}
func NewLifecycle ¶
func NewLifecycle() *Lifecycle
func (*Lifecycle) IsInterrupted ¶
convenience method for checking for interrupt for non-select{} usecases
func (*Lifecycle) Service ¶
func (self *Lifecycle) Service(f Manageable, name string)
Service allows a background process that is expected to run for the duration of a program to run with the ability to check for cancellation. A good example of a service is the "accept loop" of a network service, which perpetually accepts incoming connections.
func (*Lifecycle) Session ¶
func (self *Lifecycle) Session(f Manageable)
Session allows a single session to run with the ability to check for cancellation. Sessions are expected to be plentiful and to come and go many times during the course of a program's life time. They are not accounted for the same way that services are, but are nonetheless given a chance to clean up at shutdown time. A good example of a session is a single TCP connection.
func (*Lifecycle) StopAndWait ¶
func (self *Lifecycle) StopAndWait()
type Manageable ¶
type PanicError ¶
type PanicError struct {
// contains filtered or unexported fields
}
func (PanicError) Error ¶
func (self PanicError) Error() string