all repos — searchix @ 520dcca2755dbbab13ceebdc53d03beec8b94533

Search engine for NixOS, nix-darwin, home-manager and NUR users

feat: store data separate from search index

Alan Pearce
commit

520dcca2755dbbab13ceebdc53d03beec8b94533

parent

d25925f0d7c7e0951e739473795309514f5b558a

1 file changed, 14 insertions(+), 0 deletions(-)

changed files
M cmd/searchix-web/main.gocmd/searchix-web/main.go
@@ -20,6 +20,7 @@ "alin.ovh/searchix/internal/importer"
"alin.ovh/searchix/internal/index" "alin.ovh/searchix/internal/manpages" "alin.ovh/searchix/internal/server" + "alin.ovh/searchix/internal/storage" "alin.ovh/searchix/web" "alin.ovh/x/log" )
@@ -108,13 +109,24 @@ logger.Fatal("Failed to open data root", "error", err)
} defer root.Close() + store, err := storage.New(&storage.Options{ + Root: root, + Logger: logger.Named("store"), + }) + if err != nil { + logger.Fatal("Failed to create store", "error", err) + } + defer store.Close() + read, write, exists, err := index.OpenOrCreate( &index.Options{ + Config: cfg, Force: *replace, LowMemory: cfg.Importer.LowMemory, BatchSize: cfg.Importer.BatchSize, Logger: logger.Named("index"), Root: root, + Store: store, }, ) if err != nil {
@@ -129,12 +141,14 @@
s, err := web.New(cfg, logger, &server.Options{ ReadIndex: read, ManpagesURLMap: mdb, + Store: store, }) if err != nil { logger.Fatal("Failed to initialise searchix-web", "error", err) } imp, err := importer.New(cfg, &importer.Options{ + Storage: store, WriteIndex: write, LowMemory: cfg.Importer.LowMemory, Logger: logger.Named("importer"),