diff options
author | Michael Crosby <crosbymichael@gmail.com> | 2016-09-06 11:46:37 -0700 |
---|---|---|
committer | Michael Crosby <crosbymichael@gmail.com> | 2016-09-07 11:05:58 -0700 |
commit | 7c36a1af031b510cd990cf488ee5998a3efb450f (patch) | |
tree | 477f7c37b71fbc6dc641d7b294b68e17d6c869ec /client/container_stats.go | |
parent | 91e197d614547f0202e6ae9b8a24d88ee131d950 (diff) | |
download | docker-7c36a1af031b510cd990cf488ee5998a3efb450f.tar.gz |
Move engine-api client package
This moves the engine-api client package to `/docker/docker/client`.
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
Diffstat (limited to 'client/container_stats.go')
-rw-r--r-- | client/container_stats.go | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/client/container_stats.go b/client/container_stats.go new file mode 100644 index 0000000000..2cc67c3af1 --- /dev/null +++ b/client/container_stats.go @@ -0,0 +1,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 +} |