Refactor Agents to be singleton

Initial work for Last.fm scrobbler
This commit is contained in:
Deluan
2021-06-22 11:15:51 -04:00
committed by Deluan Quintão
parent f9fa9667a3
commit d5461d0ae9
17 changed files with 289 additions and 212 deletions
+9 -7
View File
@@ -3,9 +3,11 @@ package agents
import (
"context"
"errors"
"github.com/navidrome/navidrome/model"
)
type Constructor func(ctx context.Context) Interface
type Constructor func(ds model.DataStore) Interface
type Interface interface {
AgentName() string
@@ -31,27 +33,27 @@ var (
)
type ArtistMBIDRetriever interface {
GetMBID(id string, name string) (string, error)
GetMBID(ctx context.Context, id string, name string) (string, error)
}
type ArtistURLRetriever interface {
GetURL(id, name, mbid string) (string, error)
GetURL(ctx context.Context, id, name, mbid string) (string, error)
}
type ArtistBiographyRetriever interface {
GetBiography(id, name, mbid string) (string, error)
GetBiography(ctx context.Context, id, name, mbid string) (string, error)
}
type ArtistSimilarRetriever interface {
GetSimilar(id, name, mbid string, limit int) ([]Artist, error)
GetSimilar(ctx context.Context, id, name, mbid string, limit int) ([]Artist, error)
}
type ArtistImageRetriever interface {
GetImages(id, name, mbid string) ([]ArtistImage, error)
GetImages(ctx context.Context, id, name, mbid string) ([]ArtistImage, error)
}
type ArtistTopSongsRetriever interface {
GetTopSongs(id, artistName, mbid string, count int) ([]Song, error)
GetTopSongs(ctx context.Context, id, artistName, mbid string, count int) ([]Song, error)
}
var Map map[string]Constructor