Browse Source

nawak removal

nate 8 years ago
parent
commit
dfad714947

+ 0 - 1
.travis.yml

@@ -116,7 +116,6 @@ env:
     - "TESTDIR=Lua/octopus"
     - "TESTDIR=Lua/openresty"
     - "TESTDIR=Nim/jester"
-    - "TESTDIR=Nim/nawak"
     - "TESTDIR=Perl/dancer"
     - "TESTDIR=Perl/kelp"
     - "TESTDIR=Perl/mojolicious"

+ 0 - 6
frameworks/Nim/nawak/.gitignore

@@ -1,6 +0,0 @@
-/nawak_postgres
-/nawak_redis
-/conf/logs
-/conf/run
-/conf/tmp
-/conf/config.sqlite

+ 0 - 81
frameworks/Nim/nawak/app.nim

@@ -1,81 +0,0 @@
-import os, strtabs, strutils, math, algorithm
-import nawak_mongrel, jdump
-import model, fortunes_tmpl
-when not defined(postgre_model) xor defined(redis_model):
-    {.error: "please pass either -d:postgre_model or -d:redis_model to the compiler".}
-when defined(postgre_model):
-    import model_postgre
-when defined(redis_model):
-    import model_redis
-
-get "/json":
-    var j: THello
-    j.message = "Hello, World!"
-    # jdump serialize the tuples of the model as json
-    return response(jdump(j), "application/json")
-
-get "/plaintext":
-    return response("Hello, World!", "text/plain")
-
-get "/db":
-    let w = getWorld(random(10_000)+1)
-    return response(jdump(w), "application/json")
-
-get "/fortunes":
-    var fortunes = getAllFortunes()
-    let new_fortune: TFortune =
-        (id: 0,
-         message: "Additional fortune added at request time.")
-    fortunes.add new_fortune
-    sort(fortunes, proc(x, y: TFortune): int =
-        return cmp(x.message, y.message))
-
-    return response(fortunes_tmpl(fortunes), "text/html; charset=utf-8")
-
-
-proc limit_queries(query_params: PStringTable): int =
-    result = 1
-    if query_params.hasKey("queries"):
-        try:
-            result = parseInt(query_params["queries"])
-        except EInvalidValue: discard
-        # clamp the number of queries
-        if result < 1: result = 1
-        elif result > 500: result = 500
-
-get "/queries":
-    let queries = limit_queries(request.query)
-
-    var world: seq[TWorld]
-    world.newSeq(queries)
-    for i in 0.. <queries:
-        world[i] = getWorld random(10_000) + 1
-    return response(jdump(world), "application/json")
-
-get "/updates":
-    let queries = limit_queries(request.query)
-
-    var world: seq[TWorld]
-    world.newSeq(queries)
-    for i in 0.. <queries:
-        world[i] = getWorld(random(10_000) + 1)
-        world[i].randomNumber = random(10_000) + 1
-        updateWorld world[i]
-
-    return response(jdump(world), "application/json")
-
-custom_page 404:
-    # customize the content of the 404 page
-    return response(404, """Nah, I've got nothing.<br>
-                            Here's a <b>404 Page Not Found</b> error for you.""")
-
-var nb_workers = 32
-if paramCount() > 0:
-    try:
-        nb_workers = paramStr(1).parseInt
-    except ValueError:
-        echo "Usage: app [number of workers]"
-        echo "       Will start with 32 workers by default"
-echo "Starting with " & $nb_workers & " workers"
-
-run(init=init_db, nb_threads=nb_workers)

+ 0 - 28
frameworks/Nim/nawak/benchmark_config.json

@@ -1,28 +0,0 @@
-{
-  "framework": "nawak",
-  "tests": [{
-    "default": {
-      "setup_file": "setup",
-      "json_url": "/json",
-      "db_url": "/db",
-      "query_url": "/queries?queries=",
-      "fortune_url": "/fortunes",
-      "update_url": "/updates?queries=",
-      "plaintext_url": "/plaintext",
-      "port": 6767,
-      "approach": "Realistic",
-      "classification": "Micro",
-      "database": "Postgres",
-      "framework": "nawak",
-      "language": "Nim",
-      "orm": "Raw",
-      "platform": "Nim",
-      "webserver": "mongrel2",
-      "os": "Linux",
-      "database_os": "Linux",
-      "display_name": "nawak-postgresql",
-      "notes": "",
-      "versus": ""
-    }
-  }]
-}

+ 0 - 9
frameworks/Nim/nawak/conf/Makefile

@@ -1,9 +0,0 @@
-
-all: run
-
-run:
-	mkdir -p run logs tmp
-	m2sh load
-	sudo m2sh start -every
-
-.PHONY: run

+ 0 - 28
frameworks/Nim/nawak/conf/mongrel2.conf

@@ -1,28 +0,0 @@
-# this is the minimal config required for mongrel2
-micro_framework = Handler(
-                          send_spec='tcp://127.0.0.1:9999',
-                          send_ident='0138a43-micro-nimrod',
-                          recv_spec='tcp://127.0.0.1:9998',
-                          #protocol='tnetstring', # default to json
-                          recv_ident='')
-
-main = Server(
-    uuid="bd81667c-505a-41da-952c-1e672338db8a",
-    access_log="/logs/access.log",
-    error_log="/logs/error.log",
-    chroot="./",
-    default_host="localhost",
-    name="test",
-    pid_file="/run/mongrel2.pid",
-    port=6767,
-    hosts = [
-        Host(name="localhost", routes={
-            '/': micro_framework
-        })
-    ]
-)
-
-settings = {"zeromq.threads": 1,
-            "disable.access_logging": 1}
-
-servers = [main]

+ 0 - 17
frameworks/Nim/nawak/fortunes_tmpl.nim

@@ -1,17 +0,0 @@
-#! stdtmpl | standard
-#from xmltree import escape
-#import model
-#proc fortunes_tmpl*(fortunes: openArray[TFortune]): string =
-#  result = ""
-<!DOCTYPE html>
-<html>
-  <head><title>Fortunes</title></head>
-<body>
-  <table>
-    <tr><th>id</th><th>message</th></tr>
-  #for fortune in items(fortunes):
-    <tr><td>${fortune.id}</td><td>${escape(fortune.message)}</td></tr>
-  #end for
-  </table>
-</body>
-</html>

+ 0 - 3
frameworks/Nim/nawak/model.nim

@@ -1,3 +0,0 @@
-type THello* = tuple[message: string]
-type TWorld* = tuple[id: int, randomNumber: int]
-type TFortune* = tuple[id: int, message: string]

+ 0 - 36
frameworks/Nim/nawak/model_postgre.nim

@@ -1,36 +0,0 @@
-import strutils, db_postgres
-import model
-
-const qworld = sql"SELECT id, randomNumber FROM World WHERE id = $1"
-const qfortunes = sql"SELECT id, message FROM Fortune"
-const qupdates = sql"UPDATE World SET randomNumber = $1 WHERE id = $2"
-
-var db {.threadvar.}: TDbConn
-var qworld_prepared {.threadvar.}: TSqlPrepared
-var qfortunes_prepared {.threadvar.}: TSqlPrepared
-var qupdates_prepared {.threadvar.}: TSqlPrepared
-
-proc init_db*() {.procvar.} =
-    db = open("", "benchmarkdbuser", "benchmarkdbpass",
-              "host=127.0.0.1 port=5432 dbname=hello_world")
-    # prepare queries
-    qworld_prepared = db.prepare("world", qworld, 1)
-    qfortunes_prepared = db.prepare("fortunes", qfortunes, 0)
-    qupdates_prepared = db.prepare("updates", qupdates, 2)
-
-
-proc getWorld*(n: int): TWorld =
-    #let row = db.getRow(qworld, n)
-    ## Yes, prepared queries are faster than unprepared ones
-    let row = db.getRow(qworld_prepared, n)
-    result.id = parseInt(row[0])
-    result.randomNumber = parseInt(row[1])
-
-proc updateWorld*(w: TWorld) =
-    db.exec(qupdates_prepared, $w.randomNumber, $w.id)
-
-proc getAllFortunes*(): seq[TFortune] =
-    let rows = db.getAllRows(qfortunes_prepared)
-    result.newSeq(rows.len)
-    for j, row in rows.pairs:
-        result[j] = (row[0].parseInt, row[1])

+ 0 - 23
frameworks/Nim/nawak/model_redis.nim

@@ -1,23 +0,0 @@
-import strutils, redis
-import model
-
-var db {.threadvar.}: TRedis
-
-proc init_db*() {.procvar.} =
-    db = open(host="foobar")
-
-proc getWorld*(id: int): TWorld =
-    let s = redis.get(db, "world:" & $id)
-    if s == redisNil:
-        raise newException(ERedis, "World Not Found")
-    return (id, s.parseInt)
-
-proc updateWorld*(w: TWorld) =
-    db.setk("world:" & $w.id, $w.randomNumber)
-
-proc getAllFortunes*(): seq[TFortune] =
-    result = @[]
-    var i = 1
-    for s in db.lrange("fortunes", 0, -1):
-        result.add((id: i, message: s))
-        inc(i)

+ 0 - 24
frameworks/Nim/nawak/setup.sh

@@ -1,24 +0,0 @@
-#!/bin/bash
-
-sed -i 's|host=127.0.0.1 port=5432|host='"${DBHOST}"' port=5432|g' model_postgre.nim
-
-fw_depends postgresql nim nimble zeromq mongrel2 nawak
-
-echo "** Compiling app"
-nim c --threads:on -d:release -d:postgre_model -l:-Wl,-rpath,$IROOT/zeromq-4.0.3/lib -o:nawak_postgre app.nim
-
-echo "** Starting mongrel2"
-cd conf
-mkdir -p run logs tmp
-m2sh load -config mongrel2.conf
-m2sh start -name test &
-
-cd ..
-nb_workers=256
-if [ "$TRAVIS" == "1" ]; then
-  nb_workers=32
-fi
-
-echo "** Starting app"
-
-./nawak_postgre $nb_workers &

+ 0 - 19
toolset/setup/linux/frameworks/nawak.sh

@@ -1,19 +0,0 @@
-#!/bin/bash
-
-fw_depends nim nimble zeromq mongrel2
-
-RETCODE=$(fw_exists ${IROOT}/nawak.installed)
-[ ! "$RETCODE" == 0 ] || { \
-  source $IROOT/nawak.installed
-  return 0; }
-
-git clone https://github.com/idlewan/nawak.git
-cd nawak
-git fetch
-git checkout b34b0b5077541ae9671957452a70e2578894d3a8
-nimble update
-nimble install
-
-echo "export NAWAK_HOME=${IROOT}/nawak" > $IROOT/nawak.installed
-
-source $IROOT/nawak.installed