all repos — searchix @ 1db7c2a1630c3d80c3c696c8fabaa5476eb2184e

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

feat(importer): make timeout configurable via command-line

Alan Pearce
commit

1db7c2a1630c3d80c3c696c8fabaa5476eb2184e

parent

778e1d774f574f45c179d0fecf0c1da9cc359b80

1 file changed, 5 insertions(+), 6 deletions(-)

jump to
M import/main.goimport/main.go
@@ -17,12 +17,11 @@
"github.com/ardanlabs/conf/v3" ) -const timeout = 30 * time.Minute - type Config struct { - ConfigFile string `conf:"short:c"` - LogLevel slog.Level `conf:"default:INFO"` - Replace bool `conf:"default:false,help:whether to remove existing database, if exists"` + ConfigFile string `conf:"short:c"` + LogLevel slog.Level `conf:"default:INFO"` + Timeout time.Duration `conf:"default:30m,help:maximum time to wait for all fetchers and importers combined"` + Replace bool `conf:"default:false,help:whether to remove existing database, if exists"` } func main() {
@@ -56,7 +55,7 @@ if err != nil {
log.Fatalf("Failed to create indexer: %v", err) } - ctx, cancel := context.WithTimeout(context.Background(), timeout) + ctx, cancel := context.WithTimeout(context.Background(), runtimeConfig.Timeout) defer cancel() var imp importer.Importer