Browse Source

Fixed falcore

Thanks to @ebramanti-techempower for doing the lifting
msmith-techempower 10 years ago
parent
commit
ace13969b7

+ 6 - 0
frameworks/Go/falcore/bash_profile.sh

@@ -0,0 +1,6 @@
+#!/bin/bash
+
+# Set the root of our go installation
+export GOROOT=${IROOT}/go
+
+export GOPATH=${TROOT}

+ 0 - 30
frameworks/Go/falcore/setup.py

@@ -1,30 +0,0 @@
-import subprocess
-import sys
-import os
-import setup_util
-
-def start(args, logfile, errfile):
-  setup_util.replace_text("falcore/src/framework_benchmarks/falcore.go", "tcp\(.*:3306\)", "tcp(" + args.database_host + ":3306)")
-  if os.name == 'nt':
-    #subprocess.call("rmdir /s /q pkg\\windows_amd64", shell=True, cwd="go")
-    #subprocess.call("rmdir /s /q src\\github.com", shell=True, cwd="go")
-    #subprocess.call("del /s /q /f bin\\hello.exe", shell=True, cwd="go")
-    subprocess.call("set GOPATH=C:\\FrameworkBenchmarks\\falcore&& go get ./...", shell=True, cwd="falcore", stderr=errfile, stdout=logfile)
-    subprocess.Popen("setup.bat", shell=True, cwd="falcore", stderr=errfile, stdout=logfile) 
-    return 0
-  os.environ["GOPATH"] = os.path.expanduser('~/FrameworkBenchmarks/falcore')
-  subprocess.call("go get ./...", shell=True, cwd="falcore", stderr=errfile, stdout=logfile) 
-  subprocess.Popen("go run src/framework_benchmarks/falcore.go".rsplit(" "), cwd="falcore", stderr=errfile, stdout=logfile)
-  return 0
-def stop(logfile, errfile):
-  if os.name == 'nt':
-    subprocess.call("taskkill /f /im go.exe > NUL", shell=True, stderr=errfile, stdout=logfile)
-    subprocess.call("taskkill /f /im falcore.exe > NUL", shell=True, stderr=errfile, stdout=logfile)
-    return 0
-  p = subprocess.Popen(['ps', 'aux'], stdout=subprocess.PIPE)
-  out, err = p.communicate()
-  for line in out.splitlines():
-    if 'falcore' in line and 'run-tests' not in line:
-      pid = int(line.split(None, 2)[1])
-      os.kill(pid, 15)
-  return 0

+ 10 - 0
frameworks/Go/falcore/setup.sh

@@ -0,0 +1,10 @@
+#!/bin/bash
+
+
+#!/bin/bash
+
+# Where to find the go executable
+export PATH="$GOROOT/bin:$PATH"
+
+go get ./...
+go run src/framework_benchmarks/falcore.go &

+ 6 - 0
frameworks/Go/falcore/source_code

@@ -0,0 +1,6 @@
+./falcore/src/
+./falcore/src/framework_benchmarks
+./falcore/src/framework_benchmarks/falcore.go
+./falcore/templates/
+./falcore/templates/fortune.html
+./falcore/templates/layout.html

+ 6 - 5
frameworks/Go/falcore/src/framework_benchmarks/falcore.go

@@ -3,6 +3,7 @@ package main
 import (
 	"database/sql"
 	"github.com/fitstar/falcore"
+	"github.com/fitstar/falcore/responder"
 	"html/template"
 	"io"
 	"log"
@@ -157,7 +158,7 @@ var textHtml = http.Header{"Content-Type": []string{"text/html"}}
 // Test 1: JSON serialization
 var jsonFilter = falcore.NewRequestFilter(func(req *falcore.Request) *http.Response {
 	if req.HttpRequest.URL.Path == "/json" {
-		resp, _ := falcore.JSONResponse(req.HttpRequest, 200, applicationJson, &Message{helloWorldString})
+		resp, _ := responder.JSONResponse(req.HttpRequest, 200, applicationJson, &Message{helloWorldString})
 		return resp
 	}
 	return nil
@@ -172,7 +173,7 @@ var dbFilter = falcore.NewRequestFilter(func(req *falcore.Request) *http.Respons
 			log.Fatalf("Error scanning world row: %s", err.Error())
 		}
 
-		resp, _ := falcore.JSONResponse(req.HttpRequest, 200, applicationJson, &world)
+		resp, _ := responder.JSONResponse(req.HttpRequest, 200, applicationJson, &world)
 		return resp
 	}
 	return nil
@@ -197,7 +198,7 @@ var queriesFilter = falcore.NewRequestFilter(func(req *falcore.Request) *http.Re
 				log.Fatalf("Error scanning world row: %s", err.Error())
 			}
 		}
-		resp, _ := falcore.JSONResponse(req.HttpRequest, 200, applicationJson, &world)
+		resp, _ := responder.JSONResponse(req.HttpRequest, 200, applicationJson, &world)
 		return resp
 	}
 	return nil
@@ -247,7 +248,7 @@ var updateFilter = falcore.NewRequestFilter(func(req *falcore.Request) *http.Res
 			worldStatement.QueryRow(rand.Intn(worldRowCount)+1).Scan(&world.Id, &world.RandomNumber)
 			world.RandomNumber = uint16(rand.Intn(worldRowCount) + 1)
 			updateStatement.Exec(world.RandomNumber, world.Id)
-			resp, _ := falcore.JSONResponse(req.HttpRequest, 200, applicationJson, &world)
+			resp, _ := responder.JSONResponse(req.HttpRequest, 200, applicationJson, &world)
 			return resp
 		} else {
 			world := make([]World, n)
@@ -260,7 +261,7 @@ var updateFilter = falcore.NewRequestFilter(func(req *falcore.Request) *http.Res
 					log.Fatalf("Error updating world row: %s", err.Error())
 				}
 			}
-			resp, _ := falcore.JSONResponse(req.HttpRequest, 200, applicationJson, world)
+			resp, _ := responder.JSONResponse(req.HttpRequest, 200, applicationJson, world)
 			return resp
 		}