X-Git-Url: http://git.pjr.cc/?a=blobdiff_plain;f=src%2Fwebconnector.go;h=fa814f3badd0bbf43c16150c697f2fd0a5546b44;hb=c9ff4815a53c91a582619a41e7952571c02f6075;hp=9885bbb1e3a6b2b2c612771efbd66185eaa38301;hpb=c9e1d3b61ac854f6ca704d627957241a725d4bc2;p=goDBhammer.git
diff --git a/src/webconnector.go b/src/webconnector.go
index 9885bbb..fa814f3 100644
--- a/src/webconnector.go
+++ b/src/webconnector.go
@@ -8,11 +8,12 @@ import (
"io";
//"./dbibridge";
"./benchcontroller";
+ //"dbconnector";
"fmt";
)
-var comin chan int;
-var comout chan int;
+var comin chan string;
+var comout chan string;
// hello world, the web server
func ServerResponder(c *http.Conn, req *http.Request) {
@@ -27,12 +28,36 @@ func ServerResponder(c *http.Conn, req *http.Request) {
if req.RawURL == "/confirm" {
confirmPage(c, req);
}
+
+ if req.RawURL == "/begin" {
+ beginPage(c, req);
+ }
- // fucking go, i just wanna consume the incoming data, but it forces me to do something with it... cunt of a language
//k := <- comin;
//fmt.Printf("%d\n", k);
}
+func beginPage(c *http.Conn, req *http.Request)
+{
+
+ if req.Method != "GET" {
+ http.Redirect(c, "/begin", 301);
+ } else {
+ header(c);
+ io.WriteString(c, "
Starting hammer
");
+ //dbhost := req.FormValue("dbhost");
+ //dbuser := req.FormValue("dbuser");
+ //dbpass := req.FormValue("dbpass");
+ //dbname := req.FormValue("dbname");
+ //nthreads := req.FormValue("nthreads");
+ //dbmult := req.FormValue("dbmult");
+ comout <- "begin:setup";
+
+ footer(c);
+ }
+
+}
+
func confirmPage(c *http.Conn, req *http.Request)
{
header(c);
@@ -43,6 +68,7 @@ func confirmPage(c *http.Conn, req *http.Request)
dbname := req.FormValue("dbname");
nthreads := req.FormValue("nthreads");
dbmult := req.FormValue("dbmult");
+ var dbtype string;
io.WriteString(c, "You are trying to perform a benchmark with the following values:
");
io.WriteString(c, "");
@@ -63,7 +89,11 @@ func confirmPage(c *http.Conn, req *http.Request)
io.WriteString(c, "");
io.WriteString(c, "");
+ dbtype = "mysql";
+
footer(c);
+ comout <- fmt.Sprintf("configure:%s:%s:%s:%s:%s:%s:%s", dbtype, dbhost, dbuser, dbpass, dbname, dbmult, nthreads);
+
}
func mainPage(c *http.Conn, req *http.Request)
@@ -98,14 +128,16 @@ func footer(c *http.Conn)
func main()
{
- comin = make(chan int);
- comout = make(chan int);
+ comin = make(chan string);
+ comout = make(chan string);
+
bc := benchcontroller.CreateController();
go benchcontroller.MainLoop(bc, comout, comin);
- http.Handle("/", http.HandlerFunc(ServerResponder));
- err := http.ListenAndServe(":12345", nil);
+ http.Handle("/", http.FileServer("./web", "/web"));
+ http.Handle("/json", http.HandlerFunc(ServerResponder));
+ err := http.ListenAndServe(":22222", nil);
if err != nil {
panic("ListenAndServe: ", err.String())
}