HTTP Server Sharing Documentation

Add the paragraph about server sharing and explain the round robin strategy Vert.x uses.

Signed-off-by: Clement Escoffier <clement.escoffier@gmail.com>
This commit is contained in:
Clement Escoffier
2015-06-04 15:14:36 +02:00
parent 65dfc3b3b6
commit c1cd4b1cee
3 changed files with 106 additions and 10 deletions

View File

@@ -90,7 +90,6 @@ public class HTTPExamples {
}
public void example8(HttpServerRequest request) {
MultiMap headers = request.headers();
@@ -104,9 +103,9 @@ public class HTTPExamples {
public void example9(HttpServerRequest request) {
request.handler(buffer -> {
System.out.println("I have received a chunk of the body of length " + buffer.length());
});
request.handler(buffer -> {
System.out.println("I have received a chunk of the body of length " + buffer.length());
});
}
public void example10(HttpServerRequest request) {
@@ -147,7 +146,7 @@ public class HTTPExamples {
server.requestHandler(request -> {
request.setExpectMultipart(true);
request.uploadHandler(upload -> {
System.out.println("Got a file upload " + upload.name());
System.out.println("Got a file upload " + upload.name());
});
});
}
@@ -577,4 +576,21 @@ public class HTTPExamples {
});
}
public void serversharing(Vertx vertx) {
vertx.createHttpServer().requestHandler(request -> {
request.response().end("Hello from server " + this);
}).listen(8080);
}
public void serversharingclient(Vertx vertx) {
vertx.setPeriodic(100, (l) -> {
vertx.createHttpClient().getNow(8080, "localhost", "/", resp -> {
resp.bodyHandler(body -> {
System.out.println(body.toString("ISO-8859-1"));
});
});
});
}
}