Documentation
¶
Index ¶
- func Closed() context.Context
- func CtxWithCancel() (context.Context, context.CancelFunc)
- type CancelCtx
- type Processor
- type Service
- func (svc *Service) Done() <-chan struct{}
- func (svc *Service) GoRun(fn func(context.Context)) (ok bool)
- func (svc *Service) GoRunWait(fn func(context.Context)) (ok bool)
- func (svc *Service) Run(fn func(context.Context)) (ok bool)
- func (svc *Service) RunWait(fn func(context.Context)) (ok bool)
- func (svc *Service) Running() bool
- func (svc *Service) Stop() bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CtxWithCancel ¶ added in v1.5.0
func CtxWithCancel() (context.Context, context.CancelFunc)
CtxWithCancel returns a new context.Context impl with cancel.
Types ¶
type CancelCtx ¶ added in v1.5.0
type CancelCtx (<-chan struct{})
CancelCtx is the simplest possible cancellable context.
type Processor ¶ added in v1.6.0
type Processor struct {
// contains filtered or unexported fields
}
Processor acts similarly to a sync.Once object, except that it is reusable. After the first call to Process(), any further calls before this first has returned will block until the first call has returned, and return the same error. This ensures that only a single instance of it is ever running at any one time.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service provides a means of tracking a single long-running Service, provided protected state changes and preventing multiple instances running. Also providing Service state information.
func (*Service) Done ¶
func (svc *Service) Done() <-chan struct{}
Done returns a channel that's closed when Service.Stop() is called. It is the same channel provided to the currently running service function.
func (*Service) GoRun ¶ added in v1.3.0
GoRun will run the supplied function until completion in a goroutine, using given context to propagate cancel. Immediately returns boolean indicating success, or that service is already running.
func (*Service) GoRunWait ¶ added in v1.7.0
GoRunWait is functionally the same as .RunWait(), but blocks until the first instance of RunWait() returns.
func (*Service) Run ¶
Run will run the supplied function until completion, using given context to propagate cancel. Immediately returns false if the Service is already running, and true after completed run.
func (*Service) RunWait ¶ added in v1.6.0
RunWait is functionally the same as .Run(), but blocks until the first instance of .Run() returns.