Consistently defer messages for jobs

This commit is contained in:
Eduard Urbach 2018-03-29 00:26:19 +02:00
parent dde6702e65
commit dee5bb1fe0
11 changed files with 25 additions and 16 deletions

View File

@ -10,6 +10,8 @@ import (
func main() { func main() {
color.Yellow("Refreshing anime characters...") color.Yellow("Refreshing anime characters...")
defer color.Green("Finished.")
defer arn.Node.Close() defer arn.Node.Close()
rateLimiter := time.NewTicker(500 * time.Millisecond) rateLimiter := time.NewTicker(500 * time.Millisecond)
@ -26,6 +28,4 @@ func main() {
fmt.Printf("%s %s (%d characters)\n", anime.ID, anime.Title.Canonical, len(chars.Items)) fmt.Printf("%s %s (%d characters)\n", anime.ID, anime.Title.Canonical, len(chars.Items))
} }
color.Green("Finished.")
} }

View File

@ -37,6 +37,8 @@ func init() {
func main() { func main() {
color.Yellow("Downloading anime images") color.Yellow("Downloading anime images")
defer color.Green("Finished.")
defer arn.Node.Close() defer arn.Node.Close()
if from < 0 { if from < 0 {
@ -53,8 +55,6 @@ func main() {
work(anime) work(anime)
} }
color.Green("Finished downloading anime images.")
// Give file buffers some time, just to be safe // Give file buffers some time, just to be safe
time.Sleep(time.Second) time.Sleep(time.Second)
} }

View File

@ -13,6 +13,8 @@ var popularity = map[string]*arn.AnimePopularity{}
// made to it. // made to it.
func main() { func main() {
color.Yellow("Updating anime ratings") color.Yellow("Updating anime ratings")
defer color.Green("Finished.")
defer arn.Node.Close() defer arn.Node.Close()
allAnimeLists, err := arn.AllAnimeLists() allAnimeLists, err := arn.AllAnimeLists()
@ -93,8 +95,6 @@ func main() {
anime.Popularity = popularity[animeID] anime.Popularity = popularity[animeID]
anime.Save() anime.Save()
} }
color.Green("Finished.")
} }
func average(floatSlice []float64) float64 { func average(floatSlice []float64) float64 {

View File

@ -72,6 +72,12 @@ func main() {
count++ count++
} }
// Log number of links
color.Yellow("Queued up %d links", count) color.Yellow("Queued up %d links", count)
// Wait for completion
malCrawler.Wait() malCrawler.Wait()
// Finished
color.Green("Finished.")
} }

View File

@ -10,6 +10,8 @@ import (
func main() { func main() {
color.Yellow("Refreshing episode information for each anime.") color.Yellow("Refreshing episode information for each anime.")
defer color.Green("Finished.")
defer arn.Node.Close() defer arn.Node.Close()
if InvokeShellArgs() { if InvokeShellArgs() {
@ -59,8 +61,6 @@ func main() {
color.Cyan("Low priority queue (%d):", len(lowPriority)) color.Cyan("Low priority queue (%d):", len(lowPriority))
refreshQueue(lowPriority) refreshQueue(lowPriority)
} }
color.Green("Finished.")
} }
func refreshQueue(queue []*arn.Anime) { func refreshQueue(queue []*arn.Anime) {

View File

@ -12,6 +12,8 @@ const delayBetweenRequests = 1000
func main() { func main() {
color.Yellow("Downloading soundtracks") color.Yellow("Downloading soundtracks")
defer color.Green("Finished.")
defer arn.Node.Close() defer arn.Node.Close()
for track := range arn.StreamSoundTracks() { for track := range arn.StreamSoundTracks() {
@ -34,6 +36,4 @@ func main() {
// Delay a little // Delay a little
time.Sleep(delayBetweenRequests) time.Sleep(delayBetweenRequests)
} }
color.Green("Finished.")
} }

View File

@ -13,6 +13,8 @@ import (
func main() { func main() {
color.Yellow("Syncing characters with Kitsu DB") color.Yellow("Syncing characters with Kitsu DB")
defer color.Green("Finished.")
defer arn.Node.Close() defer arn.Node.Close()
kitsuCharacters := kitsu.StreamCharacters() kitsuCharacters := kitsu.StreamCharacters()
@ -104,6 +106,4 @@ func main() {
// Log // Log
fmt.Printf("%s %s %s\n", color.GreenString("✔"), character.ID, character.Name) fmt.Printf("%s %s %s\n", color.GreenString("✔"), character.ID, character.Name)
} }
color.Green("Finished.")
} }

View File

@ -12,6 +12,8 @@ import (
func main() { func main() {
color.Yellow("Syncing media relations with Kitsu DB") color.Yellow("Syncing media relations with Kitsu DB")
defer color.Green("Finished.")
defer arn.Node.Close() defer arn.Node.Close()
kitsuMediaRelations := kitsu.StreamMediaRelations() kitsuMediaRelations := kitsu.StreamMediaRelations()
@ -70,6 +72,4 @@ func main() {
for _, animeRelations := range relations { for _, animeRelations := range relations {
animeRelations.Save() animeRelations.Save()
} }
color.Green("Finished.")
} }

View File

@ -10,6 +10,8 @@ import (
func main() { func main() {
color.Yellow("Syncing Shoboi Anime") color.Yellow("Syncing Shoboi Anime")
defer color.Green("Finished.")
defer arn.Node.Close() defer arn.Node.Close()
// Priority queues // Priority queues
@ -43,8 +45,6 @@ func main() {
// This is a lazy hack: Wait 5 minutes for goroutines to finish their remaining work. // This is a lazy hack: Wait 5 minutes for goroutines to finish their remaining work.
time.Sleep(5 * time.Minute) time.Sleep(5 * time.Minute)
color.Green("Finished.")
} }
func refreshQueue(queue []*arn.Anime) { func refreshQueue(queue []*arn.Anime) {

View File

@ -22,6 +22,8 @@ var packages = []string{
} }
func main() { func main() {
defer color.Green("Finished.")
wg := sync.WaitGroup{} wg := sync.WaitGroup{}
for _, pkg := range packages { for _, pkg := range packages {

View File

@ -13,6 +13,7 @@ import (
var rateLimiter = time.NewTicker(500 * time.Millisecond) var rateLimiter = time.NewTicker(500 * time.Millisecond)
func main() { func main() {
defer color.Green("Finished.")
defer arn.Node.Close() defer arn.Node.Close()
// Replace this with ID list from twist.moe later // Replace this with ID list from twist.moe later