Documentation ¶
Overview ¶
Package expvarx provides some extensions to the expvar package.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type SafeFunc ¶
type SafeFunc struct {
// contains filtered or unexported fields
}
SafeFunc is a wrapper around expvar.Func that guards against unbounded call time and ensures that only a single call is in progress at any given time.
func NewSafeFunc ¶
NewSafeFunc returns a new SafeFunc that wraps f. If f takes longer than limit to execute then Value calls return nil. If onSlow is non-nil, it is called when f takes longer than limit to execute. onSlow is called with the duration of the slow call and the final computed value.
func (*SafeFunc) String ¶
String implements stringer in the same pattern as expvar.Func, calling Value and serializing the result as JSON, ignoring errors.
func (*SafeFunc) Value ¶
Value acts similarly to expvar.Func.Value, but if the underlying function takes longer than the configured limit, all callers will receive nil until the underlying operation completes. On completion of the underlying operation, the onSlow callback is called if set.