Browse Source

jiffified.

Heinz N. Gies 12 years ago
parent
commit
9ec8552bac
4 changed files with 5 additions and 6 deletions
  1. 1 1
      cowboy/src/db_handler.erl
  2. 0 1
      cowboy/src/hello_world_app.erl
  3. 1 1
      cowboy/src/json_handler.erl
  4. 3 3
      nodejs/hello.js

+ 1 - 1
cowboy/src/db_handler.erl

@@ -22,7 +22,7 @@ handle(Req, State) ->
 			        {result_packet, _, _, [Res], _} <- [emysql:execute(test_pool, db_stmt, [random:uniform(10000)]) || _ <- lists:seq(1, I) ]],
 			        {result_packet, _, _, [Res], _} <- [emysql:execute(test_pool, db_stmt, [random:uniform(10000)]) || _ <- lists:seq(1, I) ]],
 			{Res, Req1}
 			{Res, Req1}
 		end,
 		end,
-	{ok, Req3} = cowboy_req:reply(200, [{<<"Content-Type">>, <<"application/json">>}], jsx:encode(JSON), Req2),
+	{ok, Req3} = cowboy_req:reply(200, [{<<"Content-Type">>, <<"application/json">>}], jiffy:encode(JSON), Req2),
 	{ok, Req3, State}.
 	{ok, Req3, State}.
 
 
 terminate(_Reason, _Req, _State) ->
 terminate(_Reason, _Req, _State) ->

+ 0 - 1
cowboy/src/hello_world_app.erl

@@ -13,7 +13,6 @@
 start(_Type, _Args) ->
 start(_Type, _Args) ->
         crypto:start(),
         crypto:start(),
         application:start(emysql),
         application:start(emysql),
-        application:start(jiffy),
         emysql:add_pool(test_pool, 32,
         emysql:add_pool(test_pool, 32,
           "benchmarkdbuser", "benchmarkdbpass", "localhost", 3306,
           "benchmarkdbuser", "benchmarkdbpass", "localhost", 3306,
           "hello_world", utf8),
           "hello_world", utf8),

+ 1 - 1
cowboy/src/json_handler.erl

@@ -11,7 +11,7 @@ init(_Transport, Req, []) ->
 	{ok, Req, undefined}.
 	{ok, Req, undefined}.
 
 
 handle(Req, State) ->
 handle(Req, State) ->
-	{ok, Req2} = cowboy_req:reply(200, [{<<"Content-Type">>, <<"application/json">>}], jsx:encode([{<<"message">>, <<"Hello, World!">>}]), Req),
+	{ok, Req2} = cowboy_req:reply(200, [{<<"Content-Type">>, <<"application/json">>}], jiffy:encode({[{<<"message">>, <<"Hello, World!">>}]}), Req),
 	{ok, Req2, State}.
 	{ok, Req2, State}.
 
 
 terminate(_Reason, _Req, _State) ->
 terminate(_Reason, _Req, _State) ->

+ 3 - 3
nodejs/hello.js

@@ -18,10 +18,10 @@ var http = require('http')
   , url = require('url')
   , url = require('url')
   , async = require('async')
   , async = require('async')
   , mongoose = require('mongoose')
   , mongoose = require('mongoose')
-  , conn = mongoose.connect('mongodb://localhost/hello_world')
+  , conn = mongoose.connect('mongodb://172.16.234.132/hello_world')
   , mysql = require('mysql')
   , mysql = require('mysql')
   , pool  = mysql.createPool({
   , pool  = mysql.createPool({
-      host: 'localhost',
+      host: '172.16.234.132',
       user     : 'benchmarkdbuser',
       user     : 'benchmarkdbuser',
       password : 'benchmarkdbpass',
       password : 'benchmarkdbpass',
       database : 'hello_world',
       database : 'hello_world',
@@ -29,7 +29,7 @@ var http = require('http')
     })
     })
   , Sequelize = require("sequelize")
   , Sequelize = require("sequelize")
   , sequelize = new Sequelize('hello_world', 'benchmarkdbuser', 'benchmarkdbpass', {
   , sequelize = new Sequelize('hello_world', 'benchmarkdbuser', 'benchmarkdbpass', {
-    host: 'localhost',
+    host: '172.16.234.132',
     logging: false,
     logging: false,
     define: { timestamps: false },
     define: { timestamps: false },
     maxConcurrentQueries: 100,
     maxConcurrentQueries: 100,