Documentation
¶
Index ¶
- type JobController
- type Option
- type ShutdownController
- func (sc *ShutdownController) Demand()
- func (sc *ShutdownController) Done() <-chan struct{}
- func (sc *ShutdownController) Force()
- func (sc *ShutdownController) GetJobController(logger *mylog.Logger) JobController
- func (sc *ShutdownController) IsShuttingDown() bool
- func (sc *ShutdownController) Request()
- func (sc *ShutdownController) ShutdownRequested() <-chan struct{}
- func (sc *ShutdownController) ShutdownStatus() ShutdownStatus
- type ShutdownStatus
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type JobController ¶
type JobController struct {
Job struct {
// Add job that would be awaited before server shutdown
Add func(delta int)
// Mark a job as done
Done func()
}
// Current context to use
context.Context
// Server shutdown context, Done on demand to shutdown
ShutdownCtx context.Context
// Server cleanup context, Done on force
CleanupCtx context.Context
//
IsShuttingDown func() bool
ShutdownStatus func() ShutdownStatus
// Current logger to use
Logger *mylog.Logger
// contains filtered or unexported fields
}
One global object to manage the state of the system
func (JobController) AddLoggerPrefix ¶
func (jc JobController) AddLoggerPrefix(prefix string) JobController
func (JobController) NewCtx ¶
func (jc JobController) NewCtx(ctx context.Context) JobController
func (JobController) ShutdownRequested ¶
func (jc JobController) ShutdownRequested() <-chan struct{}
type Option ¶
type Option func(*ShutdownController) error
func DemandDeadline ¶
Force demand (demand without cleanup) after duration
func InterruptHandler ¶
Force demand (demand without cleanup) after duration
func RequestDeadline ¶
Turn Request into Demand (force-shutdown connections) after duration
type ShutdownController ¶
type ShutdownController struct {
ShutdownCtx context.Context
CleanupCtx context.Context
// contains filtered or unexported fields
}
func (*ShutdownController) Demand ¶
func (sc *ShutdownController) Demand()
Servers should terminate connections and cleanup
func (*ShutdownController) Done ¶
func (sc *ShutdownController) Done() <-chan struct{}
func (*ShutdownController) Force ¶
func (sc *ShutdownController) Force()
Extreme measure. Shutdown w/o cleanup
func (*ShutdownController) GetJobController ¶
func (sc *ShutdownController) GetJobController(logger *mylog.Logger) JobController
func (*ShutdownController) IsShuttingDown ¶
func (sc *ShutdownController) IsShuttingDown() bool
func (*ShutdownController) Request ¶
func (sc *ShutdownController) Request()
Servers should deny new connections
func (*ShutdownController) ShutdownRequested ¶
func (sc *ShutdownController) ShutdownRequested() <-chan struct{}
func (*ShutdownController) ShutdownStatus ¶
func (sc *ShutdownController) ShutdownStatus() ShutdownStatus
type ShutdownStatus ¶
type ShutdownStatus uint8
const ( Working ShutdownStatus = iota Requested Demanded Forced Done )
Click to show internal directories.
Click to hide internal directories.