From 4644c6698a7b6ce6fdb913c2efd170cba3ebec16 Mon Sep 17 00:00:00 2001 From: Paul J R Date: Sun, 15 Nov 2009 23:51:54 +1100 Subject: [PATCH] the way i'm doing the web itnerface kinda sucks. --- src/benchcontroller.go | 11 ++++++----- src/webconnector.go | 32 ++++++++++++++++++++++++++------ 2 files changed, 32 insertions(+), 11 deletions(-) diff --git a/src/benchcontroller.go b/src/benchcontroller.go index bb49570..6bd48a3 100644 --- a/src/benchcontroller.go +++ b/src/benchcontroller.go @@ -4,7 +4,7 @@ package benchcontroller import ( //"./dbconnector"; - "os"; + "fmt"; "time"; ) @@ -25,14 +25,15 @@ func CreateController()(contConfig *BenchControllerConfig) return bcConfig; } -func MainLoop(conf *BenchControllerConfig, commInChan chan int, commOutChan chan int) +func MainLoop(conf *BenchControllerConfig, commInChan chan string, commOutChan chan string) { for { time.Sleep(1000000000); i := <-commInChan; - os.Stdout.WriteString("got a coms\n"); - switch i { + fmt.Printf("coms: %s\n", i); + + /*switch i { case 1: // this means shutdown os.Stdout.WriteString("shutdown\n"); @@ -43,6 +44,6 @@ func MainLoop(conf *BenchControllerConfig, commInChan chan int, commOutChan chan case 3: // start the clients os.Stdout.WriteString("start clients\n"); - } + }*/ } } \ No newline at end of file diff --git a/src/webconnector.go b/src/webconnector.go index 9885bbb..80a333f 100644 --- a/src/webconnector.go +++ b/src/webconnector.go @@ -11,8 +11,8 @@ import ( "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 +27,30 @@ 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) +{ + 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"); + + footer(c); + +} + func confirmPage(c *http.Conn, req *http.Request) { header(c); @@ -64,6 +82,8 @@ func confirmPage(c *http.Conn, req *http.Request) io.WriteString(c, ""); footer(c); + comout <- fmt.Sprintf("configure:%s:%s:%s:%s:%s:%s", dbhost, dbuser, dbpass, dbname, dbmult, nthreads); + } func mainPage(c *http.Conn, req *http.Request) @@ -98,14 +118,14 @@ 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); + err := http.ListenAndServe(":22222", nil); if err != nil { panic("ListenAndServe: ", err.String()) } -- 1.7.0.4