Run exporter in goroutine

Use channel to pass data from exporter to importer
This commit is contained in:
Philipp Wolfer 2023-11-15 18:16:00 +01:00
parent 1ba165a631
commit 298697dcfc
No known key found for this signature in database
GPG key ID: 8FDF744D4919943B
7 changed files with 124 additions and 42 deletions

View file

@ -61,9 +61,8 @@ var listensCmd = &cobra.Command{
fmt.Printf("From timestamp: %v (%v)\n", timestamp, timestamp.Unix())
// Export from source
listens, err := exportBackend.ExportListens(timestamp)
cobra.CheckErr(err)
fmt.Printf("Loaded %v listens from %v.\n", len(listens), sourceName)
listens := make(chan models.ListensResult, 1000)
go exportBackend.ExportListens(timestamp, listens)
// Import into target
result, err := importBackend.ImportListens(listens, timestamp)

View file

@ -61,9 +61,8 @@ var lovesCmd = &cobra.Command{
fmt.Printf("From timestamp: %v (%v)\n", timestamp, timestamp.Unix())
// Export from source
loves, err := exportBackend.ExportLoves(timestamp)
cobra.CheckErr(err)
fmt.Printf("Loaded %v loves from %v.\n", len(loves), sourceName)
loves := make(chan models.LovesResult, 1000)
go exportBackend.ExportLoves(timestamp, loves)
// Import into target
result, err := importBackend.ImportLoves(loves, timestamp)