From 9e739ec757617f91c6d4ae365dadf12c56dda481 Mon Sep 17 00:00:00 2001 From: Piotr Szczesniak Date: Tue, 8 Dec 2015 21:29:56 +0100 Subject: [PATCH] Added possibility to not ignore NumStats field in ContainerInfoRequest --- info/v1/container.go | 1 - utils/timed_store.go | 8 +------- utils/timed_store_test.go | 4 ++-- 3 files changed, 3 insertions(+), 10 deletions(-) diff --git a/info/v1/container.go b/info/v1/container.go index 1a3449b9..53b8b5d2 100644 --- a/info/v1/container.go +++ b/info/v1/container.go @@ -91,7 +91,6 @@ func (self ContainerReferenceSlice) Less(i, j int) bool { return self[i].Name < // It specifies how much data users want to get about a container type ContainerInfoRequest struct { // Max number of stats to return. Specify -1 for all stats currently available. - // If start and end time are specified this limit is ignored. // Default: 60 NumStats int `json:"num_stats,omitempty"` diff --git a/utils/timed_store.go b/utils/timed_store.go index 70c310d3..372ff095 100644 --- a/utils/timed_store.go +++ b/utils/timed_store.go @@ -84,19 +84,13 @@ func (self *TimedStore) Add(timestamp time.Time, item interface{}) { } // Returns up to maxResult elements in the specified time period (inclusive). -// Results are from first to last. maxResults of -1 means no limit. When first -// and last are specified, maxResults is ignored. +// Results are from first to last. maxResults of -1 means no limit. func (self *TimedStore) InTimeRange(start, end time.Time, maxResults int) []interface{} { // No stats, return empty. if len(self.buffer) == 0 { return []interface{}{} } - // Return all results in a time range if specified. - if !start.IsZero() && !end.IsZero() { - maxResults = -1 - } - var startIndex int if start.IsZero() { // None specified, start at the beginning. diff --git a/utils/timed_store_test.go b/utils/timed_store_test.go index 76b77782..6daa653b 100644 --- a/utils/timed_store_test.go +++ b/utils/timed_store_test.go @@ -144,8 +144,8 @@ func TestInTimeRange(t *testing.T) { expectElements(t, sb.InTimeRange(createTime(3), createTime(5), 10), []int{3, 4}) assert.Empty(sb.InTimeRange(createTime(5), createTime(5), 10)) - // Start and end time ignores maxResults. - expectElements(t, sb.InTimeRange(createTime(1), createTime(5), 1), []int{1, 2, 3, 4}) + // Start and end time does't ignore maxResults. + expectElements(t, sb.InTimeRange(createTime(1), createTime(5), 1), []int{4}) // No start time. expectElements(t, sb.InTimeRange(empty, createTime(5), 10), []int{1, 2, 3, 4})