about summary refs log tree commit diff stats
path: root/internal/importer/main.go
diff options
context:
space:
mode:
authorAlan Pearce2024-05-13 21:50:14 +0200
committerAlan Pearce2024-05-13 22:25:46 +0200
commit6b40e0c0fa90f11be14a93f1d6275779fd645cac (patch)
tree0df5bea87242450829ca441d235c077a0e09a149 /internal/importer/main.go
parent2722f24af87f437ed9fcb8cc743ad1784141fd3a (diff)
downloadsearchix-6b40e0c0fa90f11be14a93f1d6275779fd645cac.tar.lz
searchix-6b40e0c0fa90f11be14a93f1d6275779fd645cac.tar.zst
searchix-6b40e0c0fa90f11be14a93f1d6275779fd645cac.zip
refactor: combine import and web server into one binary
Diffstat (limited to 'internal/importer/main.go')
-rw-r--r--internal/importer/main.go16
1 files changed, 3 insertions, 13 deletions
diff --git a/internal/importer/main.go b/internal/importer/main.go
index a6f15e9..2d87e33 100644
--- a/internal/importer/main.go
+++ b/internal/importer/main.go
@@ -8,23 +8,18 @@ import (
 	"os/exec"
 	"path"
 	"searchix/internal/config"
-	"searchix/internal/search"
+	"searchix/internal/index"
 	"strings"
 )
 
-func Start(cfg *config.Config, replace bool) error {
+func Start(cfg *config.Config, indexer *index.WriteIndex, replace bool) error {
 	if len(cfg.Importer.Sources) == 0 {
 		slog.Info("No sources enabled")
 
 		return nil
 	}
 
-	indexer, err := search.NewIndexer(cfg.DataPath, replace)
-	if err != nil {
-		log.Fatalf("Failed to create indexer: %v", err)
-	}
-
-	ctx, cancel := context.WithTimeout(context.Background(), cfg.Importer.Timeout)
+	ctx, cancel := context.WithTimeout(context.Background(), cfg.Importer.Timeout.Duration)
 	defer cancel()
 
 	var imp Importer
@@ -81,10 +76,5 @@ func Start(cfg *config.Config, replace bool) error {
 		}
 	}
 
-	err = indexer.Close()
-	if err != nil {
-		slog.Error("error closing indexer", "error", err)
-	}
-
 	return nil
 }