-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Print out progress state as and download progresses
- Loading branch information
1 parent
90baece
commit aae4d41
Showing
7 changed files
with
125 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package stream | ||
|
||
import "sync" | ||
|
||
type ProgressState struct { | ||
NoOfProductsDownloaded <-chan int | ||
NoOfProductsConvertedAsCSV <-chan int | ||
} | ||
|
||
func (s ProgressState) Ignore() { | ||
var waitGroup sync.WaitGroup | ||
waitGroup.Add(2) | ||
go func() { | ||
for range s.NoOfProductsDownloaded { | ||
} | ||
waitGroup.Done() | ||
}() | ||
go func() { | ||
for range s.NoOfProductsConvertedAsCSV { | ||
} | ||
waitGroup.Done() | ||
}() | ||
waitGroup.Wait() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package products | ||
|
||
// ProgressState comprises of progress state that can be used for displaying the consumer the current state of the operation | ||
type ProgressState struct { | ||
NoOfProductsDownloaded int | ||
NoOfProductsConvertedAsCSV int | ||
} | ||
|
||
// ProgressHandler used as callback to process the progress state as the process happens | ||
type ProgressHandler func(state ProgressState) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters