From 0dbfe37fbddb95c184d845c79bbe014597d55fe8 Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Thu, 23 May 2024 13:14:45 +0200 Subject: feat: stream files directly from fetcher to importer Use IndexMeta to store the information relevant to making conditional updates in future runs. --- internal/fetcher/main.go | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'internal/fetcher/main.go') diff --git a/internal/fetcher/main.go b/internal/fetcher/main.go index 65f62db..7ea0b03 100644 --- a/internal/fetcher/main.go +++ b/internal/fetcher/main.go @@ -2,34 +2,35 @@ package fetcher import ( "context" + "io" "log/slog" "searchix/internal/config" + "searchix/internal/index" "github.com/pkg/errors" ) type FetchedFiles struct { - Revision string - Options string - Packages string + Revision io.ReadCloser + Options io.ReadCloser + Packages io.ReadCloser } type Fetcher interface { - FetchIfNeeded(context.Context) (FetchedFiles, bool, error) + FetchIfNeeded(context.Context, *index.SourceMeta) (FetchedFiles, error) } func New( source *config.Source, - fetcherDataPath string, logger *slog.Logger, ) (fetcher Fetcher, err error) { switch source.Fetcher { case config.ChannelNixpkgs: - fetcher, err = NewNixpkgsChannelFetcher(source, fetcherDataPath, logger) + fetcher, err = NewNixpkgsChannelFetcher(source, logger) case config.Channel: - fetcher, err = NewChannelFetcher(source, fetcherDataPath, logger) + fetcher, err = NewChannelFetcher(source, logger) case config.Download: - fetcher, err = NewDownloadFetcher(source, fetcherDataPath, logger) + fetcher, err = NewDownloadFetcher(source, logger) default: err = errors.Errorf("unsupported fetcher type %s", source.Fetcher.String()) } -- cgit 1.4.1