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
|
// It specifies how much data users want to get about a container
|
||||||
type ContainerInfoRequest struct {
|
type ContainerInfoRequest struct {
|
||||||
// Max number of stats to return. Specify -1 for all stats currently available.
|
// 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
|
// Default: 60
|
||||||
NumStats int `json:"num_stats,omitempty"`
|
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).
|
// 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
|
// Results are from first to last. maxResults of -1 means no limit.
|
||||||
// and last are specified, maxResults is ignored.
|
|
||||||
func (self *TimedStore) InTimeRange(start, end time.Time, maxResults int) []interface{} {
|
func (self *TimedStore) InTimeRange(start, end time.Time, maxResults int) []interface{} {
|
||||||
// No stats, return empty.
|
// No stats, return empty.
|
||||||
if len(self.buffer) == 0 {
|
if len(self.buffer) == 0 {
|
||||||
return []interface{}{}
|
return []interface{}{}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return all results in a time range if specified.
|
|
||||||
if !start.IsZero() && !end.IsZero() {
|
|
||||||
maxResults = -1
|
|
||||||
}
|
|
||||||
|
|
||||||
var startIndex int
|
var startIndex int
|
||||||
if start.IsZero() {
|
if start.IsZero() {
|
||||||
// None specified, start at the beginning.
|
// 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})
|
expectElements(t, sb.InTimeRange(createTime(3), createTime(5), 10), []int{3, 4})
|
||||||
assert.Empty(sb.InTimeRange(createTime(5), createTime(5), 10))
|
assert.Empty(sb.InTimeRange(createTime(5), createTime(5), 10))
|
||||||
|
|
||||||
// Start and end time ignores maxResults.
|
// Start and end time does't ignore maxResults.
|
||||||
expectElements(t, sb.InTimeRange(createTime(1), createTime(5), 1), []int{1, 2, 3, 4})
|
expectElements(t, sb.InTimeRange(createTime(1), createTime(5), 1), []int{4})
|
||||||
|
|
||||||
// No start time.
|
// No start time.
|
||||||
expectElements(t, sb.InTimeRange(empty, createTime(5), 10), []int{1, 2, 3, 4})
|
expectElements(t, sb.InTimeRange(empty, createTime(5), 10), []int{1, 2, 3, 4})
|
||||||
|
Loading…
Reference in New Issue
Block a user