hystrix-go: github.com/afex/hystrix-go/hystrix/rolling Index | Files

package rolling

import "github.com/afex/hystrix-go/hystrix/rolling"


Package Files

rolling.go rolling_timing.go

type Number Uses

type Number struct {
    Buckets map[int64]*numberBucket
    Mutex   *sync.RWMutex

Number tracks a numberBucket over a bounded number of time buckets. Currently the buckets are one second long and only the last 10 seconds are kept.

func NewNumber Uses

func NewNumber() *Number

NewNumber initializes a RollingNumber struct.

func (*Number) Avg Uses

func (r *Number) Avg(now time.Time) float64

func (*Number) Increment Uses

func (r *Number) Increment(i float64)

Increment increments the number in current timeBucket.

func (*Number) Max Uses

func (r *Number) Max(now time.Time) float64

Max returns the maximum value seen in the last 10 seconds.

func (*Number) Sum Uses

func (r *Number) Sum(now time.Time) float64

Sum sums the values over the buckets in the last 10 seconds.

func (*Number) UpdateMax Uses

func (r *Number) UpdateMax(n float64)

UpdateMax updates the maximum value in the current bucket.

type Timing Uses

type Timing struct {
    Buckets map[int64]*timingBucket
    Mutex   *sync.RWMutex

    CachedSortedDurations []time.Duration
    LastCachedTime        int64

Timing maintains time Durations for each time bucket. The Durations are kept in an array to allow for a variety of statistics to be calculated from the source data.

func NewTiming Uses

func NewTiming() *Timing

NewTiming creates a RollingTiming struct.

func (*Timing) Add Uses

func (r *Timing) Add(duration time.Duration)

Add appends the time.Duration given to the current time bucket.

func (*Timing) Mean Uses

func (r *Timing) Mean() uint32

Mean computes the average timing in the last 60 seconds.

func (*Timing) Percentile Uses

func (r *Timing) Percentile(p float64) uint32

Percentile computes the percentile given with a linear interpolation.

func (*Timing) SortedDurations Uses

func (r *Timing) SortedDurations() []time.Duration

SortedDurations returns an array of time.Duration sorted from shortest to longest that have occurred in the last 60 seconds.

Package rolling imports 4 packages (graph) and is imported by 38 packages. Updated 2018-02-12. Refresh now. Tools for package owners.