From f34757afbd7a3c73b7496963fcfe2a0094e17d09 Mon Sep 17 00:00:00 2001 From: bouncepaw Date: Sun, 24 Jan 2021 13:36:03 +0500 Subject: [PATCH] Drop memdb dependency because it is not used yet --- go.mod | 1 - go.sum | 9 ------- hyphae/hypha.go | 16 ++---------- storage/storage.go | 65 ---------------------------------------------- 4 files changed, 2 insertions(+), 89 deletions(-) delete mode 100644 storage/storage.go diff --git a/go.mod b/go.mod index 2d5ea15..137cbae 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,6 @@ go 1.14 require ( github.com/adrg/xdg v0.2.2 github.com/gorilla/feeds v1.1.1 - github.com/hashicorp/go-memdb v1.3.0 github.com/kr/pretty v0.2.1 // indirect github.com/valyala/quicktemplate v1.6.3 ) diff --git a/go.sum b/go.sum index b20873b..f950cb8 100644 --- a/go.sum +++ b/go.sum @@ -5,15 +5,6 @@ github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8 github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/gorilla/feeds v1.1.1 h1:HwKXxqzcRNg9to+BbvJog4+f3s/xzvtZXICcQGutYfY= github.com/gorilla/feeds v1.1.1/go.mod h1:Nk0jZrvPFZX1OBe5NPiddPw7CfwF6Q9eqzaBbaightA= -github.com/hashicorp/go-immutable-radix v1.3.0 h1:8exGP7ego3OmkfksihtSouGMZ+hQrhxx+FVELeXpVPE= -github.com/hashicorp/go-immutable-radix v1.3.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= -github.com/hashicorp/go-memdb v1.3.0 h1:xdXq34gBOMEloa9rlGStLxmfX/dyIK8htOv36dQUwHU= -github.com/hashicorp/go-memdb v1.3.0/go.mod h1:Mluclgwib3R93Hk5fxEfiRhB+6Dar64wWh71LpNSe3g= -github.com/hashicorp/go-uuid v1.0.0 h1:RS8zrF7PhGwyNPOtxSClXXj9HA8feRnJzgnI1RJCSnM= -github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= -github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= -github.com/hashicorp/golang-lru v0.5.4 h1:YDjusn29QI/Das2iO9M0BHnIbxPeyuCHsjMW+lJfyTc= -github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= github.com/klauspost/compress v1.10.7/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= github.com/klauspost/compress v1.11.0/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI= diff --git a/hyphae/hypha.go b/hyphae/hypha.go index 366fd5a..d70cd1e 100644 --- a/hyphae/hypha.go +++ b/hyphae/hypha.go @@ -1,8 +1,7 @@ package hyphae -import ( - "github.com/bouncepaw/mycorrhiza/storage" -) +// TODO: do +import () type Hypha struct { Name string @@ -15,17 +14,6 @@ type Hypha struct { // AddHypha adds a hypha named `name` with such `textPath` and `binaryPath`. Both paths can be empty. Does //not// check for hypha's existence beforehand. Count is handled. func AddHypha(name, textPath, binaryPath string) { - txn := storage.DB.Txn(true) - txn.Insert("hyphae", - &Hypha{ - Name: name, - TextPath: textPath, - BinaryPath: binaryPath, - OutLinks: make([]string, 0), - BackLinks: make([]string, 0), - }) - txn.Commit() - IncrementCount() } // DeleteHypha clears both paths and all out-links from the named hypha and marks it as non-existent. It does not actually delete it from the memdb. Count is handled. diff --git a/storage/storage.go b/storage/storage.go deleted file mode 100644 index 528c109..0000000 --- a/storage/storage.go +++ /dev/null @@ -1,65 +0,0 @@ -package storage - -import ( - "github.com/hashicorp/go-memdb" -) - -// Create the DB schema -var schema = &memdb.DBSchema{ - Tables: map[string]*memdb.TableSchema{ - "hyphae": &memdb.TableSchema{ - Name: "hyphae", - Indexes: map[string]*memdb.IndexSchema{ - "id": &memdb.IndexSchema{ - Name: "id", - Unique: true, - Indexer: &memdb.StringFieldIndex{Field: "Name"}, - }, - "exists": &memdb.IndexSchema{ - Name: "exists", - Unique: false, - Indexer: &memdb.BoolFieldIndex{Field: "Exists"}, - }, - "out-links": &memdb.IndexSchema{ - Name: "out-links", - Unique: false, - Indexer: &memdb.StringSliceFieldIndex{Field: "OutLinks"}, - }, - "back-links": &memdb.IndexSchema{ - Name: "back-links", - Unique: false, - Indexer: &memdb.StringSliceFieldIndex{Field: "BackLinks"}, - }, - }, - }, - }, -} - -var DB *memdb.MemDB - -func init() { - var err error - DB, err = memdb.NewMemDB(schema) - if err != nil { - panic(err) - } -} - -func ForEveryRecord(table string, λ func(obj interface{})) error { - txn := DB.Txn(false) - defer txn.Abort() - - it, err := txn.Get(table, "id") - if err != nil { - return err - } - - for obj := it.Next(); obj != nil; obj = it.Next() { - λ(obj) - } - - return nil -} - -func TxnW() *memdb.Txn { return DB.Txn(true) } -func TxnR() *memdb.Txn { return DB.Txn(false) }