From eca6b58f8e0fe466027f051aca1e83da81a18046 Mon Sep 17 00:00:00 2001 From: Paul J R Date: Sat, 14 Nov 2009 04:49:57 +1100 Subject: [PATCH] design doco, some more .. classes is the wrong word... so is packages really... lets call them "bits" created. --- design.txt | 33 +++++++++++++++++++++++++++++++++ src/benchclient.go | 32 ++++++++++++++++++++++++++++++++ src/dbconnector.go | 17 ++++++++++++++++- src/dbibridge.go | 10 +++++----- src/makeit | 6 +++--- src/webconnector.go | 2 +- 6 files changed, 90 insertions(+), 10 deletions(-) create mode 100644 design.txt create mode 100644 src/benchclient.go create mode 100644 src/benchcontroller.go create mode 100644 src/idgenerator.go create mode 100644 src/rpccontroller.go diff --git a/design.txt b/design.txt new file mode 100644 index 0000000..36762f9 --- /dev/null +++ b/design.txt @@ -0,0 +1,33 @@ +so our program should work pretty simple + +execution: +goDBHammer port + +where port is the port it'll listen to web requests for + + +there will be two very simple executions in that interface + +1 controls the benchmark +2 is for rpc + +this means you'll login to some controller and then tell it to connect to another controller on whatever port was used; + +for eg: + +machine 1: # godbhammer 12345 +machine 2: # godbhammer 12345 + +on webpage of machine 1: # add machine2:12345 + +then machine 1 controls machine 2's hammer + +The bits needed: + +rpc class (server/client) +web class (server) +id generator (one thread) +benchmark controller (one thread) +benchmark clients (one thread each) - the things actually running the benchmark + +dbi connector class. \ No newline at end of file diff --git a/src/benchclient.go b/src/benchclient.go new file mode 100644 index 0000000..6babb0c --- /dev/null +++ b/src/benchclient.go @@ -0,0 +1,32 @@ +package benchclient + +// this package is a single benchmark client, i.e. a worker + +import "dbconnector"; + +var myID int; + +func Setup(ID int) +{ + myID = ID; + + if myID == 1 { + // create the db + } +} + +func Begin() +{ + // start the test + + // first, populate data for pre-run + // this will mean creating x number of rows of data depending on input + + // now, run the test + // the test will be insert, drop, update, select queries across multiple tables +} + +func End() +{ + // the main controller said CEASE! +} \ No newline at end of file diff --git a/src/benchcontroller.go b/src/benchcontroller.go new file mode 100644 index 0000000..e69de29 diff --git a/src/dbconnector.go b/src/dbconnector.go index f8b9131..668242d 100644 --- a/src/dbconnector.go +++ b/src/dbconnector.go @@ -1 +1,16 @@ -// um yes... its a db connector \ No newline at end of file +// um yes... its a db connector +package dbconnector + +type DBConnector struct { + // err, yes +} + +func DBSetup(dbtype string, host string, username string, password string, database string, createtables bool) +{ + + // the job of this function is to bring up the connection and create tables based on dbtype + +} + + + diff --git a/src/dbibridge.go b/src/dbibridge.go index 0b9b97a..4c72f2f 100644 --- a/src/dbibridge.go +++ b/src/dbibridge.go @@ -8,7 +8,7 @@ import ( "unsafe"; ) -type DBConnection struct { +type DBIConnection struct { dbconn C.dbi_conn; dbinit bool; } @@ -23,9 +23,9 @@ func DBICreate()(connection *DBConnection) return dbCon; } -//func (thisDBConn *DBConnection)DBIConnect(dbtype string, host string, username string, password string, database string) +//func (thisDBConn *DBIConnection)DBIConnect(dbtype string, host string, username string, password string, database string) // for some reason, the above doesnt work how i'd expect.. -func DBIConnect(thisDBConn *DBConnection, dbtype string, host string, username string, password string, database string) +func DBIConnect(thisDBConn *DBIConnection, dbtype string, host string, username string, password string, database string) { C.dbi_initialize(nil); @@ -40,12 +40,12 @@ func DBIConnect(thisDBConn *DBConnection, dbtype string, host string, username s thisDBConn.dbinit = true; } -func ExecSQL(thisDBConn *DBConnection, SQL string) +func ExecSQL(thisDBConn *DBIConnection, SQL string) { C.dbi_conn_query((unsafe.Pointer)(thisDBConn.dbconn), C.CString(SQL)); } -func DBIDisconnect(thisDBConn *DBConnection) +func DBIDisconnect(thisDBConn *DBIConnection) { C.dbi_conn_close((unsafe.Pointer)(thisDBConn.dbconn)); } \ No newline at end of file diff --git a/src/idgenerator.go b/src/idgenerator.go new file mode 100644 index 0000000..e69de29 diff --git a/src/makeit b/src/makeit index fbcd8fc..d83b860 100644 --- a/src/makeit +++ b/src/makeit @@ -6,10 +6,10 @@ cgo dbibridge.go gopack grc dbibridge.a _dbibridge_.8 dbibridge.cgo3.8 #cp dbibridge.a /export/src/external/golang//pkg/linux_386/dbibridge.a gcc -m32 -fPIC -O2 -o dbibridge.cgo4.o -c dbibridge.cgo4.c -gcc -m32 -shared -lpthread -lm -ldbi -o dbibridge.so dbibridge.cgo4.o -cp dbibridge.so /export/src/external/golang//pkg/linux_386/./dbibridge_dbibridge.so +gcc -m32 -shared -L`pwd` -lpthread -lm -ldbi -o dbibridge_dbibridge.so dbibridge.cgo4.o +#cp dbibridge.so /export/src/external/golang//pkg/linux_386/./dbibridge_dbibridge.so 8g -I. webconnector.go -8l -L. webconnector.8 +8l -o godhammer -L. webconnector.8 diff --git a/src/rpccontroller.go b/src/rpccontroller.go new file mode 100644 index 0000000..e69de29 diff --git a/src/webconnector.go b/src/webconnector.go index 5fe61aa..eb81cc0 100644 --- a/src/webconnector.go +++ b/src/webconnector.go @@ -16,7 +16,7 @@ func HelloServer(c *http.Conn, req *http.Request) { func main() { - var Dbconn *dbibridge.DBConnection; + var Dbconn *dbibridge.DBIConnection; Dbconn = dbibridge.DBICreate(); -- 1.7.0.4