Skip to content

Commit 530404b

Browse files
committed
#296 events() first sketch
1 parent fac7af6 commit 530404b

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

src/main/java/com/amihaiemil/docker/DockerSystem.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
package com.amihaiemil.docker;
2727

2828
import java.io.IOException;
29+
import java.io.Reader;
2930

3031
/**
3132
* Docker System API entry point.
@@ -45,4 +46,13 @@ public interface DockerSystem {
4546
DiskSpaceInfo diskUsage()
4647
throws IOException, UnexpectedResponseException;
4748

49+
/**
50+
* Follow the events on the server in real time.
51+
* @return The events {@link Reader}.
52+
* @throws IOException If an I/O error occurs.
53+
* @throws UnexpectedResponseException If the API responds with an
54+
* unexpected status.
55+
*/
56+
Reader events()
57+
throws IOException, UnexpectedResponseException;
4858
}

src/main/java/com/amihaiemil/docker/RtDockerSystem.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import org.apache.http.client.methods.HttpGet;
3131

3232
import java.io.IOException;
33+
import java.io.Reader;
3334
import java.net.URI;
3435

3536
/**
@@ -91,4 +92,20 @@ public DiskSpaceInfo diskUsage()
9192
}
9293
}
9394

95+
@Override
96+
public Reader events() throws IOException, UnexpectedResponseException {
97+
final HttpGet monitor = new HttpGet(
98+
this.baseUri.toString() + "/events"
99+
);
100+
return this.client.execute(
101+
monitor,
102+
new ReadStream(
103+
new MatchStatus(
104+
monitor.getURI(),
105+
HttpStatus.SC_OK
106+
)
107+
)
108+
);
109+
}
110+
94111
}

0 commit comments

Comments
 (0)