Add a cached http client

This commit is contained in:
Deluan
2021-02-07 23:26:05 -05:00
committed by Deluan Quintão
parent 9d24106066
commit 28cdf1e693
11 changed files with 234 additions and 14 deletions
+62
View File
@@ -0,0 +1,62 @@
package agents
import (
"context"
"errors"
)
type Constructor func(ctx context.Context) Interface
type Interface interface{}
type Artist struct {
Name string
MBID string
}
type ArtistImage struct {
URL string
Size int
}
type Track struct {
Name string
MBID string
}
var (
ErrNotFound = errors.New("not found")
)
type ArtistMBIDRetriever interface {
GetMBID(name string) (string, error)
}
type ArtistURLRetriever interface {
GetURL(name, mbid string) (string, error)
}
type ArtistBiographyRetriever interface {
GetBiography(name, mbid string) (string, error)
}
type ArtistSimilarRetriever interface {
GetSimilar(name, mbid string, limit int) ([]Artist, error)
}
type ArtistImageRetriever interface {
GetImages(name, mbid string) ([]ArtistImage, error)
}
type ArtistTopSongsRetriever interface {
GetTopSongs(artistName, mbid string, count int) ([]Track, error)
}
var Map map[string]Constructor
func Register(name string, init Constructor) {
if Map == nil {
Map = make(map[string]Constructor)
}
Map[name] = init
}