From dc80a4a4feef6b0d3148845290a6087a50183842 Mon Sep 17 00:00:00 2001 From: Timon Ringwald Date: Sun, 21 Aug 2022 21:23:38 +0200 Subject: [PATCH] multi threaded anime list requests --- anilist.go | 5 ++--- go.mod | 2 +- go.sum | 4 ++-- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/anilist.go b/anilist.go index c125d13..b5ff665 100644 --- a/anilist.go +++ b/anilist.go @@ -5,7 +5,6 @@ import ( "git.milar.in/milarin/anilist" "git.milar.in/milarin/channel" - "git.milar.in/milarin/slices" ) type Pair[A, B any] struct { @@ -29,7 +28,7 @@ func GetCurrentlyWatchingAnimes() (<-chan *anilist.MediaList, error) { return nil, ErrAnimeListNotObtainable.Wrap(err, "access token acquisition failed") } - media := slices.Map(AnimeStatus, func(status anilist.MediaListStatus) <-chan *anilist.MediaList { + media := channel.Map(channel.Of(AnimeStatus...), func(status anilist.MediaListStatus) <-chan *anilist.MediaList { return anilist.NewApi(token).GetMediaList(context.Background(), anilist.MediaListQuery{ UserName: AnilistUsername, Type: anilist.MediaTypeAnime, @@ -37,7 +36,7 @@ func GetCurrentlyWatchingAnimes() (<-chan *anilist.MediaList, error) { }, nil).Chan }) - return channel.Merge(media...), nil + return channel.FlatChan(media), nil } var ( diff --git a/go.mod b/go.mod index 4a73f9c..1075a4d 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.18 require ( git.milar.in/milarin/adverr v1.0.0 git.milar.in/milarin/anilist v1.5.0 - git.milar.in/milarin/channel v0.0.7 + git.milar.in/milarin/channel v0.0.9 git.milar.in/milarin/envvars v1.0.3 git.milar.in/milarin/gmath v0.0.2 git.milar.in/milarin/slices v0.0.2 diff --git a/go.sum b/go.sum index f10033b..ec3e57a 100644 --- a/go.sum +++ b/go.sum @@ -2,8 +2,8 @@ git.milar.in/milarin/adverr v1.0.0 h1:9povP074PjpoZlNuiKPa9w6fDA8a4RSI5hEDo5T9Tq git.milar.in/milarin/adverr v1.0.0/go.mod h1:wwfglcey4R3vqjNL/d8mbnvFJGzETRXzAEolIHZY32w= git.milar.in/milarin/anilist v1.5.0 h1:fSiAXY/topNk4ISEp2QtcG9HHKLJfMc8w05iqc+Paf0= git.milar.in/milarin/anilist v1.5.0/go.mod h1:8PTHXFMA45JpfRFIpcdrKwDHue8fbT/wwV1BuHFn6c0= -git.milar.in/milarin/channel v0.0.7 h1:cVKtwgH/EE7U+XTHcoFCClJ4LR349KanzjX9xKwRcNg= -git.milar.in/milarin/channel v0.0.7/go.mod h1:We83LTI8S7u7II3pD+A2ChCDWJfCkcBUCUqii9HjTtM= +git.milar.in/milarin/channel v0.0.9 h1:vYJnXOaIn/+mng1+8CyepQgDfRse2s4FSLNc7zv85To= +git.milar.in/milarin/channel v0.0.9/go.mod h1:We83LTI8S7u7II3pD+A2ChCDWJfCkcBUCUqii9HjTtM= git.milar.in/milarin/envvars v1.0.3 h1:go6pYExUzPx+aLvJ5BKNkaANkBNmcrlRJ8TtWsk4uWY= git.milar.in/milarin/envvars v1.0.3/go.mod h1:rLh/HN6S254h6m2lklnImcpsy4kHFxaOjM6+Nv9GHKI= git.milar.in/milarin/gmath v0.0.2 h1:avz+75f8XqAYA1wEB6kis0R5xvRuepBKTqBuJBjh6Yw=