Skip to content

Commit

Permalink
Merge pull request #12 from geniussportsgroup/develop
Browse files Browse the repository at this point in the history
Added new method that returns the full max sample: val, timestamp and…
  • Loading branch information
lrleon authored Nov 20, 2020
2 parents d3bdb31 + eed478e commit 1204559
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions sampler.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ func (sampler *SimpleSampler) RequestFinishes(requestCount *int, lock *sync.Mute

// Helper for reading number of samples.
func (sampler *SimpleSampler) GetNumRequest(currTime time.Time, lock *sync.Mutex) int {

lock.Lock()
defer lock.Unlock()
res := sampler.GetMax(currTime)
Expand All @@ -287,3 +288,16 @@ func (sampler *SimpleSampler) GetNumRequest(currTime time.Time, lock *sync.Mutex
}
return res.(int)
}

func (sampler *SimpleSampler) GetMaxSample(currTime time.Time,
lock *sync.Mutex) (int, time.Time, time.Time) {

lock.Lock()
defer lock.Unlock()
sample := sampler.MaximumVal()
if sample == nil {
return 0, currTime, currTime
}

return sample.val.(int), sample.time, sample.expirationTime
}

0 comments on commit 1204559

Please sign in to comment.