import (
//"./dbconnector";
- "os";
+ "fmt";
"time";
)
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");
case 3:
// start the clients
os.Stdout.WriteString("start clients\n");
- }
+ }*/
}
}
\ No newline at end of file
"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) {
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, "<h1>Starting hammer</h1>");
+ //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);
io.WriteString(c, "</form>");
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)
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())
}