From 1db7c2a1630c3d80c3c696c8fabaa5476eb2184e Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Thu, 9 May 2024 18:41:05 +0200 Subject: feat(importer): make timeout configurable via command-line --- import/main.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'import') diff --git a/import/main.go b/import/main.go index 52b4515..90f2b74 100644 --- a/import/main.go +++ b/import/main.go @@ -17,12 +17,11 @@ import ( "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 @@ func main() { 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 -- cgit 1.4.1