From ab660ca622c93d2ba934f14f855f8a94687e5655 Mon Sep 17 00:00:00 2001 From: Thomas Rudin Date: Mon, 7 Jan 2019 22:27:24 +0100 Subject: [PATCH] db interface --- db/accessor.go | 18 ++++++++++++++++++ db/sqlite.go | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 db/accessor.go create mode 100644 db/sqlite.go diff --git a/db/accessor.go b/db/accessor.go new file mode 100644 index 0000000..f3b3e9b --- /dev/null +++ b/db/accessor.go @@ -0,0 +1,18 @@ +package db + +type Block struct { + posx, posy, posz int + data []byte + mtime int64 +} + +type DBAccessor interface { + IsMigrated() (bool, error) + Migrate() error + FindLatestBlocks(time int64, limit int) []Block + + //Block range lookup + FindBlocks(posx int, posz int, posystart int, posyend int) []Block + GetXRange(posystart int, posyend int) (int, int) + GetZRange(posystart int, posyend int) (int, int) +} diff --git a/db/sqlite.go b/db/sqlite.go new file mode 100644 index 0000000..dfd46f3 --- /dev/null +++ b/db/sqlite.go @@ -0,0 +1,32 @@ +package db + +type Sqlite3Accessor struct { +} + +func (db *Sqlite3Accessor) IsMigrated() (bool, error) { + return false, nil +} + +func (db *Sqlite3Accessor) Migrate() error { + return nil +} + +func (db *Sqlite3Accessor) FindLatestBlocks(time int64, limit int) []Block { + return make([]Block, 0) +} + +func (db *Sqlite3Accessor) FindBlocks(posx int, posz int, posystart int, posyend int) []Block { + return make([]Block, 0) +} + +func (db *Sqlite3Accessor) GetXRange(posystart int, posyend int) (int, int) { + return 0, 0 +} + +func (db *Sqlite3Accessor) GetZRange(posystart int, posyend int) (int, int) { + return 0, 0 +} + +func NewSqliteAccessor(filename string) { + +}