Add badger database for query/server modes
This commit is contained in:
parent
4b2d1495da
commit
86bcf0fe94
38
METANOIA.go
38
METANOIA.go
|
@ -13,6 +13,7 @@ import (
|
|||
"git.gammaspectra.live/S.O.N.G/Hibiki/utilities/audio/format/flac"
|
||||
"git.gammaspectra.live/S.O.N.G/Hibiki/utilities/audio/format/mp3"
|
||||
"git.gammaspectra.live/S.O.N.G/Hibiki/utilities/audio/format/opus"
|
||||
"git.gammaspectra.live/S.O.N.G/Hibiki/utilities/specializedstore"
|
||||
"git.gammaspectra.live/S.O.N.G/METANOIA/database"
|
||||
"git.gammaspectra.live/S.O.N.G/METANOIA/store"
|
||||
"git.gammaspectra.live/S.O.N.G/MakyuuIchaival/httputils"
|
||||
|
@ -33,7 +34,6 @@ import (
|
|||
"time"
|
||||
)
|
||||
|
||||
var printDb *store.AppendStore
|
||||
var panakoInstance *panako.Instance
|
||||
var printStrategy *panako.Strategy
|
||||
var db *database.Database
|
||||
|
@ -322,20 +322,20 @@ func main() {
|
|||
}
|
||||
defer db.Close()
|
||||
|
||||
printDb, err = store.NewAppendStore(*printDbOption, true, true)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
defer printDb.Close()
|
||||
|
||||
//TODO: check if mutex is correct!
|
||||
|
||||
panakoInstance = panako.NewDefaultPackedInstance()
|
||||
|
||||
printStrategy = panakoInstance.GetStrategy(printDb)
|
||||
|
||||
if *cmdOption == "add" {
|
||||
printDb, err := store.NewAppendStore(*printDbOption, true, true)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
defer printDb.Close()
|
||||
|
||||
printStrategy = panakoInstance.GetStrategy(printDb)
|
||||
|
||||
var release *database.Release
|
||||
releases := database.GetReleasesFromDatabaseByIdentifier(db, "test")
|
||||
if len(releases) == 0 {
|
||||
|
@ -362,6 +362,15 @@ func main() {
|
|||
|
||||
pending.WaitGroup.Wait()
|
||||
} else if *cmdOption == "query" {
|
||||
printDb, err := specializedstore.NewBadgerStore(*printDbOption, true, false, 100000)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
defer printDb.Close()
|
||||
|
||||
printStrategy = panakoInstance.GetStrategy(printDb)
|
||||
|
||||
pathEntry, err := filepath.Abs(*pathOption)
|
||||
if err != nil {
|
||||
log.Panic(err)
|
||||
|
@ -415,6 +424,15 @@ func main() {
|
|||
|
||||
log.Printf("finished querying %s", pathEntry)
|
||||
} else if *cmdOption == "server" {
|
||||
printDb, err := specializedstore.NewBadgerStore(*printDbOption, true, false, 100000)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
defer printDb.Close()
|
||||
|
||||
printStrategy = panakoInstance.GetStrategy(printDb)
|
||||
|
||||
tlsConfiguration, err := tlsutils.NewTLSConfiguration(*certificatePath, *keypairPath, *sniAddressOption)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
|
|
Loading…
Reference in a new issue