File: container_stats.go

package info (click to toggle)
golang-github-docker-engine-api 0.4.0-4
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 1,064 kB
  • sloc: makefile: 19
file content (24 lines) | stat: -rw-r--r-- 550 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package client

import (
	"io"
	"net/url"

	"golang.org/x/net/context"
)

// ContainerStats returns near realtime stats for a given container.
// It's up to the caller to close the io.ReadCloser returned.
func (cli *Client) ContainerStats(ctx context.Context, containerID string, stream bool) (io.ReadCloser, error) {
	query := url.Values{}
	query.Set("stream", "0")
	if stream {
		query.Set("stream", "1")
	}

	resp, err := cli.get(ctx, "/containers/"+containerID+"/stats", query, nil)
	if err != nil {
		return nil, err
	}
	return resp.body, err
}