diff options
author | René 'Necoro' Neumann <necoro@necoro.eu> | 2020-04-25 17:00:57 +0200 |
---|---|---|
committer | René 'Necoro' Neumann <necoro@necoro.eu> | 2020-04-25 17:00:57 +0200 |
commit | 573ce1982da2e754947453fdaf0d50204873acb4 (patch) | |
tree | f6528235dce77db514ce4442ee8817e993fdcc86 /main.go | |
parent | d21881150c09986571a563eaf30bc1687787e63f (diff) | |
download | feed2imap-go-573ce1982da2e754947453fdaf0d50204873acb4.tar.gz feed2imap-go-573ce1982da2e754947453fdaf0d50204873acb4.tar.bz2 feed2imap-go-573ce1982da2e754947453fdaf0d50204873acb4.zip |
Larger restructuring
Diffstat (limited to '')
-rw-r--r-- | main.go | 17 |
1 files changed, 9 insertions, 8 deletions
@@ -7,11 +7,10 @@ import ( "os" "sync" - "github.com/Necoro/feed2imap-go/internal/config" "github.com/Necoro/feed2imap-go/internal/feed" "github.com/Necoro/feed2imap-go/internal/imap" - "github.com/Necoro/feed2imap-go/internal/log" - "github.com/Necoro/feed2imap-go/internal/yaml" + "github.com/Necoro/feed2imap-go/pkg/config" + "github.com/Necoro/feed2imap-go/pkg/log" ) var cfgFile = flag.String("f", "config.yml", "configuration file") @@ -51,7 +50,7 @@ func run() error { log.Print("Starting up...") - cfg, feeds, err := yaml.Load(*cfgFile) + cfg, err := config.Load(*cfgFile) if err != nil { return err } @@ -60,12 +59,14 @@ func run() error { return fmt.Errorf("Configuration invalid: %w", err) } - err = feeds.LoadCache(*cacheFile) + state := feed.NewState(cfg) + + err = state.LoadCache(*cacheFile) if err != nil { return err } - if success := feeds.Parse(); success == 0 { + if success := state.Fetch(); success == 0 { return fmt.Errorf("No successfull feed fetch.") } @@ -81,11 +82,11 @@ func run() error { defer c.Disconnect() - feeds.ForeachGo(func(f *feed.Feed, wg *sync.WaitGroup) { + state.ForeachGo(func(f *feed.Feed, wg *sync.WaitGroup) { processFeed(f, cfg, c, wg) }) - if err = feeds.StoreCache(*cacheFile); err != nil { + if err = state.StoreCache(*cacheFile); err != nil { return err } |