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 NoopReporter ¶ added in v0.0.3
type NoopReporter struct{}
NoopReporter Used to continue running go routine and do nothing
func (*NoopReporter) Report ¶ added in v0.0.3
func (*NoopReporter) Report(ctx context.Context, rec interface{})
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
func WithRecoverer ¶ added in v0.0.3
func WithRecoverer(reporter RecoveryReporter, stackPrinter StackPrinter) Option
func WithStatus ¶ added in v0.0.2
func WithStatus(id string, store *StatusStore) Option
type RecoveryReporter ¶ added in v0.0.3
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 StackPrinter ¶ added in v0.0.3
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
Source Files
¶
Click to show internal directories.
Click to hide internal directories.