diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/hub/Makefile | 2 | ||||
-rw-r--r-- | src/hub/src/spreadspace.org/sfive-hub/s5hub.go | 3 | ||||
-rw-r--r-- | src/hub/src/spreadspace.org/sfive/s5srv.go | 4 | ||||
-rw-r--r-- | src/hub/src/spreadspace.org/sfive/s5store.go | 24 | ||||
-rw-r--r-- | src/hub/src/spreadspace.org/sfive/s5store_test.go | 10 |
5 files changed, 15 insertions, 28 deletions
diff --git a/src/hub/Makefile b/src/hub/Makefile index 0c34f14..d03dc7d 100644 --- a/src/hub/Makefile +++ b/src/hub/Makefile @@ -43,8 +43,6 @@ LIBS := "gopkg.in/gorp.v2" \ "github.com/zenazn/goji" \ "github.com/pborman/uuid" \ "github.com/equinox0815/graphite-golang" -# "github.com/go-sql-driver/mysql" -# "github.com/ziutek/mymysql/godrv" all: build test diff --git a/src/hub/src/spreadspace.org/sfive-hub/s5hub.go b/src/hub/src/spreadspace.org/sfive-hub/s5hub.go index 8897e42..ccdd4e0 100644 --- a/src/hub/src/spreadspace.org/sfive-hub/s5hub.go +++ b/src/hub/src/spreadspace.org/sfive-hub/s5hub.go @@ -13,7 +13,6 @@ var s5hl = log.New(os.Stderr, "[s5hub]\t", log.LstdFlags) func main() { db := flag.String("db", "/var/lib/sfive/db.sqlite", "path to the sqlite3 database file") - dbMysql := flag.Bool("db-mysql", false, "use MySQL connector") pipe := flag.String("pipe", "/var/run/sfive/pipe", "path to the unix pipe for the pipeserver") ppipe := flag.String("pipegram", "/var/run/sfive/pipegram", "path to the unix datagram pipe for the pipeserver") startPipe := flag.Bool("start-pipe-server", true, "start a connection oriented pipe server; see option pipe") @@ -38,7 +37,7 @@ func main() { return } - server, err := sfive.NewServer(*dbMysql, *db) + server, err := sfive.NewServer(*db) if err != nil { s5hl.Fatalf("failed to initialize: %v", err) } diff --git a/src/hub/src/spreadspace.org/sfive/s5srv.go b/src/hub/src/spreadspace.org/sfive/s5srv.go index 9cf4c64..8f9093d 100644 --- a/src/hub/src/spreadspace.org/sfive/s5srv.go +++ b/src/hub/src/spreadspace.org/sfive/s5srv.go @@ -168,10 +168,10 @@ func (self StatsSinkServer) Close() { self.store.Close() } -func NewServer(mysql bool, dbPath string) (server *StatsSinkServer, err error) { +func NewServer(dbPath string) (server *StatsSinkServer, err error) { // TODO read configuration and create instance with correct settings server = new(StatsSinkServer) - server.store, err = NewStore(mysql, dbPath) + server.store, err = NewStore(dbPath) if err != nil { return } diff --git a/src/hub/src/spreadspace.org/sfive/s5store.go b/src/hub/src/spreadspace.org/sfive/s5store.go index 6fb5f8a..8611661 100644 --- a/src/hub/src/spreadspace.org/sfive/s5store.go +++ b/src/hub/src/spreadspace.org/sfive/s5store.go @@ -66,26 +66,16 @@ func updateFromStatisticsData(value StatisticsData) (dataUpdateDb, []clientDataD return du, cd, src, tags } -func initDb(mysql bool, path string) (res *gorp.DbMap, hubId string, err error) { +func initDb(path string) (res *gorp.DbMap, hubId string, err error) { // connect to db using standard Go database/sql API var db *sql.DB - var dialect gorp.Dialect - if mysql { - db, err = sql.Open("mysql", path) - if err != nil { - return - } - dialect = gorp.MySQLDialect{Engine: "InnoDB", Encoding: "UTF8"} - } else { - db, err = sql.Open("sqlite3", path) - if err != nil { - return - } - dialect = gorp.SqliteDialect{} + db, err = sql.Open("sqlite3", path) + if err != nil { + return } - dbmap := &gorp.DbMap{Db: db, Dialect: dialect} + dbmap := &gorp.DbMap{Db: db, Dialect: gorp.SqliteDialect{}} // dbmap.TraceOn("[gorp]", log.New(os.Stdout, "myapp:", log.Lmicroseconds)) dbmap.AddTableWithName(tagDb{}, tagsTn).SetKeys(true, "Id").ColMap("Name").SetUnique(true) @@ -630,8 +620,8 @@ func (s sqliteStore) GetStoreId() (uuid string, err error) { return } -func NewStore(mysql bool, path string) (sqliteStore, error) { - db, hubid, err := initDb(mysql, path) +func NewStore(path string) (sqliteStore, error) { + db, hubid, err := initDb(path) if err != nil { return sqliteStore{}, err } diff --git a/src/hub/src/spreadspace.org/sfive/s5store_test.go b/src/hub/src/spreadspace.org/sfive/s5store_test.go index 409bd08..6c9e302 100644 --- a/src/hub/src/spreadspace.org/sfive/s5store_test.go +++ b/src/hub/src/spreadspace.org/sfive/s5store_test.go @@ -6,7 +6,7 @@ import ( ) func TestAppend(t *testing.T) { - store, err := NewStore(false, "file:memdb1?mode=memory&cache=shared") + store, err := NewStore("file:memdb1?mode=memory&cache=shared") if err != nil { t.Errorf("Failed to initialize: %v", err) return @@ -53,7 +53,7 @@ func TestAppend(t *testing.T) { } func TestCount(t *testing.T) { - store, err := NewStore(false, "file:memdb1?mode=memory&cache=shared") + store, err := NewStore("file:memdb1?mode=memory&cache=shared") if err != nil { t.Errorf("Failed to initialize: %v", err) } @@ -67,7 +67,7 @@ func TestCount(t *testing.T) { } func TestGetUpdatesAfter(t *testing.T) { - store, err := NewStore(false, "file:memdb1?mode=memory&cache=shared") + store, err := NewStore("file:memdb1?mode=memory&cache=shared") if err != nil { t.Errorf("Failed to initialize: %v", err) return @@ -142,7 +142,7 @@ func generateStatisticsData(n int) (data []StatisticsData) { } func BenchmarkAppendMany(b *testing.B) { - store, err := NewStore(false, "file:memdb1?mode=memory&cache=shared") + store, err := NewStore("file:memdb1?mode=memory&cache=shared") if err != nil { b.Errorf("Failed to initialize: %v", err) } @@ -157,7 +157,7 @@ func BenchmarkAppendMany(b *testing.B) { } func BenchmarkGetUpdatesAfter(b *testing.B) { - store, err := NewStore(false, "file:memdb1?mode=memory&cache=shared") + store, err := NewStore("file:memdb1?mode=memory&cache=shared") if err != nil { b.Errorf("Failed to initialize: %v", err) } |