Documentation ¶
Index ¶
- Constants
- Variables
- func FormatFloat(val float64, prec int) string
- func MustParseFloat(s string) float64
- func NewValidLimiter(r rate.Limit, b int) (*rate.Limiter, error)
- func NotZero(v float64) bool
- func ParseFloat(s string) (float64, error)
- func Pow10(n int64) int64
- func Render(tpl string, args interface{}) string
- func Retry(ctx context.Context, attempts int, duration time.Duration, ...) (err error)
- func ShouldDelay(l *rate.Limiter, minInterval time.Duration) time.Duration
- func Zero(v float64) bool
- type RetryPredicator
- type VolatileMemory
Constants ¶
View Source
const (
InfiniteRetry = 0
)
View Source
const MaxDigits = 18 // MAX_INT64 ~ 9 * 10^18
Variables ¶
View Source
var Pow10Table = [MaxDigits + 1]int64{
1, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11, 1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18,
}
Functions ¶
func FormatFloat ¶
func MustParseFloat ¶
func ParseFloat ¶
func Retry ¶
func Retry(ctx context.Context, attempts int, duration time.Duration, fnToRetry func() error, errHandler func(error), predicators ...RetryPredicator) (err error)
Retry retrys the passed function for "attempts" times, if passed function return error. Setting attempts to zero means keep retrying.
Types ¶
type RetryPredicator ¶
type VolatileMemory ¶
type VolatileMemory struct {
// contains filtered or unexported fields
}
func NewDetectorCache ¶
func NewDetectorCache() *VolatileMemory
func (*VolatileMemory) IsObjectFresh ¶
func (i *VolatileMemory) IsObjectFresh(obj interface{}, ttl time.Duration) bool
func (*VolatileMemory) IsTextFresh ¶
func (i *VolatileMemory) IsTextFresh(text string, ttl time.Duration) bool
Click to show internal directories.
Click to hide internal directories.