Browse Source

Upgrade to Hunt 1.2.x (#4442)

Heromyth 6 years ago
parent
commit
983caaaed3

+ 2 - 2
frameworks/D/hunt/build.sh

@@ -11,8 +11,8 @@
 	"libs-posix": [ "http_parser" ],
 	"lflags-posix": ["-Lhttp-parser/"],
 	"dependencies": {
-		"hunt": "~>1.1.0",
-		"hunt-database": "~>1.1.1",
+		"hunt": "~>1.2.0-beta.1",
+		"hunt-database": "~>1.2.0-beta.1",
 		"std_data_json": "~>0.18.2"
 	},
 	"configurations": [

+ 6 - 2
frameworks/D/hunt/source/DemoProcessor.d

@@ -30,7 +30,7 @@ class DemoProcessor : HttpProcessor {
     }
 
     override void onComplete(HttpRequest req) {
-        debug trace(req.uri);
+        // debug trace(req.uri);
         HttpURI uri = new HttpURI(req.uri);
 
         version (POSTGRESQL) {
@@ -138,7 +138,11 @@ class DemoProcessor : HttpProcessor {
     }
 
     private void respondWith404() {
-        respondWith("The available paths are: /plaintext, /json, /db, /queries?queries=number", 404);
+        version (POSTGRESQL) {
+            respondWith("The available paths are: /plaintext, /json, /db, /fortunes, /queries?queries=number, /updates?queries=number", 404);
+        } else {
+            respondWith("The available paths are: /plaintext, /json", 404);
+        }
     }
 
     version (POSTGRESQL) {

+ 4 - 4
frameworks/D/hunt/source/app.d

@@ -29,14 +29,14 @@ void main(string[] args) {
 version(POSTGRESQL) {
 	debug {
 		dbConnection = new Database("postgresql://benchmarkdbuser:[email protected]:5432/hello_world?charset=utf-8");
-		dbConnection.getOption().setMinimumConnection(64);
+		dbConnection.getOption().setMinimumConnection(128);
 	} else {
 		dbConnection = new Database("postgresql://benchmarkdbuser:benchmarkdbpass@tfb-database:5432/hello_world?charset=utf-8");
-		dbConnection.getOption().setMinimumConnection(64);
+		dbConnection.getOption().setMinimumConnection(128);
 	}
-		dbConnection.getOption().setMaximumConnection(64);
+		dbConnection.getOption().setMaximumConnection(128);
 }
-	HttpServer httpServer = new HttpServer("0.0.0.0", port, totalCPUs-1);
+	HttpServer httpServer = new HttpServer("0.0.0.0", port, totalCPUs);
 	httpServer.onProcessorCreate(delegate HttpProcessor (TcpStream client) {
 		return new DemoProcessor(client);
 	});

+ 4 - 2
frameworks/D/hunt/source/http/Processor.d

@@ -59,9 +59,11 @@ public:
 			parser.execute(data);
 		})
 		.onClosed(() {
-			notifyClientClosed();
+			// notifyClientClosed();
+		})
+		.onError((string msg) { 
+			debug warning("Error: ", msg); 
 		})
-		.onError((string msg) { warning("Error: ", msg); })
 		.start();
 	}
 

+ 2 - 2
frameworks/D/hunt/source/http/Server.d

@@ -30,6 +30,7 @@ abstract class AbstractTcpServer {
 	this(Address address, int thread = (totalCPUs - 1)) {
 		this._address = address;
 		_tcpStreamoption = TcpStreamOption.createOption();
+		_tcpStreamoption.bufferSize = 1024*2;
 		_group = new EventLoopGroup(cast(uint) thread);
 	}
 
@@ -40,13 +41,12 @@ abstract class AbstractTcpServer {
 	void start() {
 		if (_isStarted)
 			return;
-		debug trace("start to listen:");
 		_isStarted = true;
 
 		Socket server = new TcpSocket();
 		server.setOption(SocketOptionLevel.SOCKET, SocketOption.REUSEADDR, true);
 		server.bind(new InternetAddress("0.0.0.0", 8080));
-		server.listen(1000);
+		server.listen(8192);
 
 		debug trace("Launching server");