summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsiddharth <s@ricketyspace.net>2021-11-29 21:13:32 -0500
committersiddharth <s@ricketyspace.net>2021-11-29 21:13:32 -0500
commitf79f656ca9d7bb6f96bc4196fdbcd3a691147c77 (patch)
tree7926088e230c0f0b70c660a812f9c9be7b92c720
parente45715e188255f03107187eb9af103d7b81c9a06 (diff)
state: update ProcessState
Remove FeedsProcessing. Use a local variable to track the feeds that are being processed instead in the `main` function.
-rw-r--r--fern.go11
-rw-r--r--state/state.go2
2 files changed, 6 insertions, 7 deletions
diff --git a/fern.go b/fern.go
index 8735d61..0da251e 100644
--- a/fern.go
+++ b/fern.go
@@ -38,19 +38,20 @@ func main() {
defer pState.DB.Write() // Write database to disk before returning.
// Process all feeds.
+ processing := 0
for _, feed := range fConf.Feeds {
f := feed
go f.Process(pState)
- pState.FeedsProcessing += 1
+ processing += 1
}
// Wait for all feeds finish processing.
- for pState.FeedsProcessing > 0 {
+ for processing > 0 {
fTxt := "feeds"
- if pState.FeedsProcessing == 1 {
+ if processing == 1 {
fTxt = "feed"
}
fmt.Printf("Waiting for %d %s to finish processing\n",
- pState.FeedsProcessing, fTxt)
+ processing, fTxt)
fr := <-pState.FeedResultChan
if fr.Err == nil {
fmt.Printf("[%s]: %s\n",
@@ -59,6 +60,6 @@ func main() {
fmt.Printf("[%s]: %s: %v\n",
fr.FeedId, fr.FeedResult, fr.Err.Error())
}
- pState.FeedsProcessing -= 1
+ processing -= 1
}
}
diff --git a/state/state.go b/state/state.go
index b8a48d4..c43071b 100644
--- a/state/state.go
+++ b/state/state.go
@@ -25,8 +25,6 @@ type ProcessState struct {
// caller about the number of entries that are being
// downloaded for a feed.
FeedResultChan chan FeedResult
- // Number of feeds that are being processed.
- FeedsProcessing int
}
func NewProcessState() *ProcessState {