about summary refs log tree commit diff stats
path: root/searchix.go
diff options
context:
space:
mode:
authorAlan Pearce2025-01-23 14:54:12 +0100
committerAlan Pearce2025-01-24 13:04:41 +0100
commit200857159766d3c6c5831450048348444c5666f4 (patch)
tree36fb6ebbbc91e609106c8f199e01cf00ab830c3f /searchix.go
parent7496bb7e0652d86e2afd05d35e6632dab27c954a (diff)
downloadsearchix-200857159766d3c6c5831450048348444c5666f4.tar.lz
searchix-200857159766d3c6c5831450048348444c5666f4.tar.zst
searchix-200857159766d3c6c5831450048348444c5666f4.zip
perf: pass context to importer for better tracing
Diffstat (limited to 'searchix.go')
-rw-r--r--searchix.go14
1 files changed, 11 insertions, 3 deletions
diff --git a/searchix.go b/searchix.go
index 031db31..615afc6 100644
--- a/searchix.go
+++ b/searchix.go
@@ -44,7 +44,7 @@ type IndexOptions struct {
 	Logger    *log.Logger
 }
 
-func (s *Server) SetupIndex(options *IndexOptions) error {
+func (s *Server) SetupIndex(ctx context.Context, options *IndexOptions) error {
 	var i uint
 	cfgEnabledSources := make([]string, len(s.cfg.Importer.Sources))
 	for key := range s.cfg.Importer.Sources {
@@ -78,6 +78,7 @@ func (s *Server) SetupIndex(options *IndexOptions) error {
 			options.Update,
 		)
 		err = importer.Start(
+			ctx,
 			s.cfg,
 			s.log.Named("importer"),
 			write,
@@ -105,7 +106,14 @@ func (s *Server) SetupIndex(options *IndexOptions) error {
 			})
 			if len(newSources) > 0 {
 				s.log.Info("adding new sources", "sources", newSources)
-				err := importer.Start(s.cfg, options.Logger.Named("importer"), write, false, &newSources)
+				err := importer.Start(
+					ctx,
+					s.cfg,
+					options.Logger.Named("importer"),
+					write,
+					false,
+					&newSources,
+				)
 				if err != nil {
 					return errors.Wrap(err, "Failed to update index with new sources")
 				}
@@ -189,7 +197,7 @@ func (s *Server) startUpdateTimer(
 				Status:      sentry.CheckInStatusInProgress,
 			}, monitorConfig)
 
-			err = importer.Start(s.cfg, s.log.Named("importer"), s.writeIndex, false, nil)
+			err = importer.Start(ctx, s.cfg, s.log.Named("importer"), s.writeIndex, false, nil)
 			s.wg.Done()
 			if err != nil {
 				s.log.Warn("error updating index", "error", err)