diff options
author | Alan Pearce | 2024-05-23 13:14:45 +0200 |
---|---|---|
committer | Alan Pearce | 2024-05-23 13:14:45 +0200 |
commit | 0dbfe37fbddb95c184d845c79bbe014597d55fe8 (patch) | |
tree | e68a2db861211ceebe4c357a059a4cb511f707a9 /internal/fetcher/main.go | |
parent | 3053e41b1528ef898cccd44e056e4d167619af6b (diff) | |
download | searchix-0dbfe37fbddb95c184d845c79bbe014597d55fe8.tar.lz searchix-0dbfe37fbddb95c184d845c79bbe014597d55fe8.tar.zst searchix-0dbfe37fbddb95c184d845c79bbe014597d55fe8.zip |
feat: stream files directly from fetcher to importer
Use IndexMeta to store the information relevant to making conditional updates in future runs.
Diffstat (limited to 'internal/fetcher/main.go')
-rw-r--r-- | internal/fetcher/main.go | 17 |
1 files changed, 9 insertions, 8 deletions
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()) } |