Document and specify defaults for ContainerRequestInfo.

This commit is contained in:
Victor Marmol 2015-03-25 13:15:10 -07:00
parent bfaf70b255
commit 814c65059a
2 changed files with 11 additions and 6 deletions

View File

@ -164,11 +164,7 @@ func streamResults(results chan *events.Event, w http.ResponseWriter, r *http.Re
}
func getContainerInfoRequest(body io.ReadCloser) (*info.ContainerInfoRequest, error) {
var query info.ContainerInfoRequest
// Default stats and samples is 64.
query.NumStats = 64
query := info.DefaultContainerInfoRequest()
decoder := json.NewDecoder(body)
err := decoder.Decode(&query)
if err != nil && err != io.EOF {

View File

@ -81,7 +81,9 @@ func (self ContainerReferenceSlice) Less(i, j int) bool { return self[i].Name <
// ContainerInfoQuery is used when users check a container info from the REST api.
// It specifies how much data users want to get about a container
type ContainerInfoRequest struct {
// Max number of stats to return.
// 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"`
// Start time for which to query information.
@ -93,6 +95,13 @@ type ContainerInfoRequest struct {
End time.Time `json:"end,omitempty"`
}
// Returns a ContainerInfoRequest with all default values specified.
func DefaultContainerInfoRequest() ContainerInfoRequest {
return ContainerInfoRequest{
NumStats: 60,
}
}
func (self *ContainerInfoRequest) Equals(other ContainerInfoRequest) bool {
return self.NumStats == other.NumStats &&
self.Start.Equal(other.Start) &&