Documentation
¶
Index ¶
- Constants
- Variables
- func CatchErr(p interface{}) error
- func CatchErrWithSize(p interface{}, stackSize int) error
- func GoSafe(msg string, fn func() error)
- func RoutineId() uint64
- func RunSafe(fn func() error) (err error)
- type CountdownStopper
- type StopTriggerable
- type Stoppable
- type Stopper
- type WaitStoppable
Constants ¶
const DefaultStackSize = 64 << 10 // 64KB
DefaultStackSize is the default size for stack traces
Variables ¶
var ErrCountdownTimerExpired = errors.New("countdown timer expired")
var GroupStopping = errors.New("ErrGroup is stopping") // Stoppable is stopping signal
Functions ¶
func CatchErr ¶
func CatchErr(p interface{}) error
CatchErr creates an error with stack trace from a recovered panic. It captures the current stack trace and formats it as part of the error message.
func CatchErrWithSize ¶
CatchErrWithSize creates an error with a stack trace of the specified size from a recovered panic. stackSize: the maximum size of the stack trace to capture
func GoSafe ¶
GoSafe executes a function in a separate goroutine with panic recovery. It logs any errors that occur during execution. msg: descriptive message for logging fn: function to execute safely
Types ¶
type CountdownStopper ¶
CountdownStopper the interface for countdown stoppers
func NewCountdownStopper ¶
func NewCountdownStopper() CountdownStopper
NewCountdownStopper creates a new countdown stopper
type StopTriggerable ¶
type StopTriggerable interface { // TriggerStop trigger stop TriggerStop() // StopTriggered listen stop is triggered StopTriggered() <-chan struct{} }
StopTriggerable trigger stop interface
type Stoppable ¶
type Stoppable interface { WaitStoppable StopTriggerable // DoStop execute stop DoStop(f func()) // Stopping listen stop is started Stopping() <-chan struct{} // IsStopping check stop is started IsStopping() bool }
Stoppable lifecycle stop manager interface
type Stopper ¶
type Stopper struct {
// contains filtered or unexported fields
}
Stopper implements Stoppable interface
func NewStopper ¶
func (*Stopper) IsStopping ¶
func (*Stopper) StopTriggered ¶
func (s *Stopper) StopTriggered() <-chan struct{}
func (*Stopper) TriggerStop ¶
func (s *Stopper) TriggerStop()
func (*Stopper) WaitStopped ¶
func (s *Stopper) WaitStopped()
type WaitStoppable ¶
type WaitStoppable interface {
WaitStopped()
}
WaitStoppable wait stop completed