Documentation ¶
Index ¶
Constants ¶
View Source
const ContextUser string = "background_user"
View Source
const DefaultTimeout = 10 * time.Second
Variables ¶
Functions ¶
This section is empty.
Types ¶
type BackgroundStopper ¶
type BackgroundStopper interface {
IsStopped() bool
}
type BackgroundStopperStub ¶
type BackgroundStopperStub struct {
// contains filtered or unexported fields
}
func (*BackgroundStopperStub) IsStopped ¶
func (b *BackgroundStopperStub) IsStopped() bool
func (*BackgroundStopperStub) Stop ¶
func (b *BackgroundStopperStub) Stop()
type BackgroundWorker ¶
type BackgroundWorker struct { logger.WithLoggerBase Period int Name string CondChan *condchan.CondChan Finished chan bool Stopped atomic.Bool Running atomic.Bool JobRunner JobRunner }
func (*BackgroundWorker) IsStopped ¶
func (w *BackgroundWorker) IsStopped() bool
func (*BackgroundWorker) Run ¶
func (w *BackgroundWorker) Run(fin Finisher)
func (*BackgroundWorker) RunInBackground ¶
func (w *BackgroundWorker) RunInBackground()
func (*BackgroundWorker) Shutdown ¶
func (w *BackgroundWorker) Shutdown(ctx system_context.Context) error
func (*BackgroundWorker) Stop ¶
func (w *BackgroundWorker) Stop()
type FinisherBase ¶
type FinisherBase struct {
// contains filtered or unexported fields
}
func NewFinisher ¶
func NewFinisher(config ...*FinisherConfig) *FinisherBase
func (*FinisherBase) AddRunner ¶
func (f *FinisherBase) AddRunner(runner Runner, config ...*RunnerConfig)
func (*FinisherBase) RemoveRunner ¶
func (f *FinisherBase) RemoveRunner(name string)
func (*FinisherBase) Wait ¶
func (f *FinisherBase) Wait()
type FinisherConfig ¶
type FinisherConfig struct { FinisherMainConfig // Log can be set to change where finish logs to. Logger logger.Logger }
type FinisherMainConfig ¶
type FinisherMainConfig struct { // Timeout is the maximum amount of time to wait for // still running runners requests to finish, // when the shutdown signal was received for each runner. // // It defaults to DefaultTimeout which is 10 seconds. // // The timeout can be overridden on a per-server basis with passing the // WithTimeout() option to Add() while adding the runner. Timeout time.Duration // Signals can be used to change which signals finish catches to initiate // the shutdown. // It defaults to DefaultSignals which contains SIGINT and SIGTERM. Signals []os.Signal }
type JobRunner ¶
type JobRunner interface { RunJob() StopJob() SetStopper(stopper BackgroundStopper) Stopper() BackgroundStopper }
type JobRunnerBase ¶
type JobRunnerBase struct {
// contains filtered or unexported fields
}
func (*JobRunnerBase) SetStopper ¶
func (j *JobRunnerBase) SetStopper(stopper BackgroundStopper)
func (*JobRunnerBase) StopJob ¶
func (j *JobRunnerBase) StopJob()
func (*JobRunnerBase) Stopper ¶
func (j *JobRunnerBase) Stopper() BackgroundStopper
type WithBackgroundWorker ¶
type WithBackgroundWorker interface {
Worker() *BackgroundWorker
}
type WithBackgroundWorkerBase ¶
type WithBackgroundWorkerBase struct {
WorkerInterface *BackgroundWorker
}
func (*WithBackgroundWorkerBase) Worker ¶
func (w *WithBackgroundWorkerBase) Worker() *BackgroundWorker
Click to show internal directories.
Click to hide internal directories.