Added possibility to not ignore NumStats field in ContainerInfoRequest
This commit is contained in:
parent
1d2d38d164
commit
9e739ec757
@ -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"`
|
||||
|
||||
|
@ -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.
|
||||
|
@ -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})
|
||||
|
Loading…
Reference in New Issue
Block a user