Documentation ¶
Index ¶
Constants ¶
View Source
const ResetNever time.Duration = 0
Variables ¶
View Source
var ( ErrAlreadyRunning = fmt.Errorf("already running") ErrNotRunning = fmt.Errorf("not running") )
Functions ¶
This section is empty.
Types ¶
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
func WithStatus ¶ added in v0.0.2
func WithStatus(id string, store *StatusStore) Option
type Runnable ¶
type Runnable interface { Run(ctx context.Context) error Stop(ctx context.Context) error IsRunning() bool }
func New ¶
New creates a new Runnable with the given runFunc.
Example:
type Monitor struct { runnable.Runnable } func (m *Monitor) run(ctx context.Context) error { // do something return nil } func NewMonitor() Monitor { m := Monitor{} m.Runnable = runnable.NewRunnable(m.run) return m }
func NewGroup ¶
NewGroup creates a new Runnable that runs multiple runnables concurrently.
Example:
group := NewGroup( New(func(ctx context.Context) error { // do something return nil }), New(func(ctx context.Context) error { // do something return nil }), ) err := group.Run(context.Background()) if err != nil { // handle error }
type StatusStore ¶ added in v0.0.2
type StatusStore struct {
// contains filtered or unexported fields
}
func NewStatusStore ¶ added in v0.0.2
func NewStatusStore() *StatusStore
func (*StatusStore) Get ¶ added in v0.0.2
func (s *StatusStore) Get() StatusMap
Click to show internal directories.
Click to hide internal directories.