Documentation ¶
Index ¶
- func FmtStateToString(fs fmt.State) string
- func FormatNonFormatter(fs fmt.State, verb rune, nonFormatter interface{})
- func GetStack(skip int) errors.StackTrace
- func SignalsToContext(ctx context.Context, signals ...os.Signal) (child context.Context, reason <-chan os.Signal)
- type AdvancedError
- func (ae AdvancedError) Cause() error
- func (ae AdvancedError) Error() string
- func (ae AdvancedError) Format(fs fmt.State, verb rune)
- func (ae AdvancedError) MarshalJSON() ([]byte, error)
- func (ae AdvancedError) MarshalText() (text []byte, err error)
- func (ae AdvancedError) StackTrace() errors.StackTrace
- func (ae AdvancedError) String() string
- func (ae AdvancedError) Unwrap() error
- type Causer
- type ElasticQueue
- type ErrorGroup
- type ErrorWithStack
- type Formatable
- type LimitedQueue
- type RunQueue
- type StackTracer
- type Unwrapper
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FmtStateToString ¶
FmtStateToString converts $fs to its fmt.Printf() representation (see unit tests).
func FormatNonFormatter ¶
FormatNonFormatter forwards $fs and $verb to $nonFormatter.Format() if $nonFormatter is a fmt.Formatter. Otherwise it formats $nonFormatter via fmt.Fprintf() as specified by $fs and $verb.
func GetStack ¶
func GetStack(skip int) errors.StackTrace
GetStack returns a complete errors.StackTrace of the calling goroutine without GetStack itself and $skip additional frames at the top.
func SignalsToContext ¶
func SignalsToContext(ctx context.Context, signals ...os.Signal) (child context.Context, reason <-chan os.Signal)
SignalsToContext derives $child from $ctx and cancels it on one of $signals. The exact signal (or nil on $ctx cancellation) is forwarded to $reason. $signals will be handled by SignalsToContext until $ctx cancellation to prevent firing of default handlers. Cancel $ctx not to leak goroutines!
Types ¶
type AdvancedError ¶
type AdvancedError struct { Err error Stack errors.StackTrace }
AdvancedError is a feature-rich error wrapper.
func (AdvancedError) Cause ¶
func (ae AdvancedError) Cause() error
func (AdvancedError) Error ¶
func (ae AdvancedError) Error() string
func (AdvancedError) Format ¶
func (ae AdvancedError) Format(fs fmt.State, verb rune)
Format appends the stack on %+v and %v.
func (AdvancedError) MarshalJSON ¶
func (ae AdvancedError) MarshalJSON() ([]byte, error)
func (AdvancedError) MarshalText ¶
func (ae AdvancedError) MarshalText() (text []byte, err error)
func (AdvancedError) StackTrace ¶
func (ae AdvancedError) StackTrace() errors.StackTrace
func (AdvancedError) String ¶
func (ae AdvancedError) String() string
func (AdvancedError) Unwrap ¶
func (ae AdvancedError) Unwrap() error
type ElasticQueue ¶
type ElasticQueue struct {
// contains filtered or unexported fields
}
ElasticQueue runs enqueued tasks immediately until context cancellation.
func NewElasticQueue ¶
func NewElasticQueue(ctx context.Context) *ElasticQueue
NewElasticQueue creates a new ElasticQueue. $ctx is forwarded to Enqueue()d tasks.
func (*ElasticQueue) Wait ¶
func (eq *ElasticQueue) Wait()
type ErrorGroup ¶
type ErrorGroup struct {
// contains filtered or unexported fields
}
ErrorGroup is a more feature-rich version of golang.org/x/sync/errgroup.Group:
* enforces usage of ErrorWithStack, not just error * assembles stack across goroutines * context is forwarded to tasks * optional concurrency limit * stops on context cancellation
func NewErrorGroup ¶
func NewErrorGroup(ctx context.Context, concurrency int64) *ErrorGroup
NewErrorGroup creates a new ErrorGroup. $ctx is forwarded to tasks. $concurrency < 1 means infinite.
func (*ErrorGroup) Go ¶
func (eg *ErrorGroup) Go(weight int64, f func(context.Context) ErrorWithStack)
func (*ErrorGroup) Wait ¶
func (eg *ErrorGroup) Wait() ErrorWithStack
type ErrorWithStack ¶
type ErrorWithStack interface { error StackTracer }
func AttachStackToError ¶
func AttachStackToError(err error, skip int) ErrorWithStack
AttachStackToError attaches a complete errors.StackTrace of the calling goroutine to $err if needed, without AttachStackToError itself and $skip additional frames at the top.
type Formatable ¶
type Formatable struct { // Output is the actual writer. Output io.Writer // Error is the first write error. Error ErrorWithStack Wid int Prec int HasWid bool HasPrec bool Flags map[int]struct{} }
Formatable may be used instead of fmt.Fprintf() for exactly one fmt.Formatter.
func (*Formatable) Flag ¶
func (f *Formatable) Flag(c int) bool
func (*Formatable) Precision ¶
func (f *Formatable) Precision() (int, bool)
func (*Formatable) Width ¶
func (f *Formatable) Width() (int, bool)
type LimitedQueue ¶
type LimitedQueue struct {
// contains filtered or unexported fields
}
LimitedQueue runs enqueued tasks with limited concurrency in FIFO order until context cancellation.
func NewLimitedQueue ¶
func NewLimitedQueue(ctx context.Context, concurrency int64) *LimitedQueue
NewLimitedQueue creates a new LimitedQueue which runs $concurrency tasks at a time. $ctx is forwarded to Enqueue()d tasks.
func (*LimitedQueue) Enqueue ¶
func (lq *LimitedQueue) Enqueue(weight int64, f func(context.Context))
func (*LimitedQueue) Wait ¶
func (lq *LimitedQueue) Wait()
type StackTracer ¶
type StackTracer interface {
StackTrace() errors.StackTrace
}