various updates.
[goDBhammer.git] / src / benchcontroller.go
index 579edcb..5370173 100644 (file)
@@ -4,12 +4,22 @@ package benchcontroller
 
 import (
        //"./dbconnector";
-       "os";
+       "fmt";
        "time";
+       "strings";
+       "strconv";
+       "os";
 )
 
 type BenchControllerConfig struct {
        id int;
+       nclients int;
+       datamult int;
+       dbtype string;
+       dbhost string;
+       dbuser string;
+       dbpass string;
+       dbname string;
 }
 
 func CreateController()(contConfig *BenchControllerConfig)
@@ -19,13 +29,45 @@ 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");
-               commOutChan <- i;
-               os.Stdout.WriteString("Send some back\n");
+               
+               fmt.Printf("coms: %s\n", i);
+               
+               calls := strings.Split(i, ":", 0);
+               
+               fmt.Printf("stuff 1: %s, stuff 2: %s\n", calls[0], calls[1]);
+               
+               switch calls[0] {
+                       case "configure":
+                               // this means shutdown
+                               os.Stdout.WriteString("time for a conf\n");
+                               conf.id = 0;
+                               
+                               
+                               var esink os.Error;
+                               
+                               conf.nclients, esink = strconv.Atoi(calls[7]);
+                               conf.datamult, esink = strconv.Atoi(calls[6]);
+                               
+                               if esink != os.ECHILD {
+                                       // i need to do something with esink or the bollocks compiler screws itself
+                               }
+                               conf.dbtype = calls[1];
+                               conf.dbhost = calls[2];
+                               conf.dbuser = calls[3];
+                               conf.dbpass = calls[4];
+                               conf.dbname = calls[5];
+                               
+                       case "asdf":
+                               // get ready to bench - start the clients
+                               os.Stdout.WriteString("ready clients\n");
+                       case "qwer":
+                               // start the clients
+                               os.Stdout.WriteString("start clients\n");
+               }
        }
 }
\ No newline at end of file