usecases

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 5, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FailedGetUserErrorTemplate = "failed to get user ID: %w"
	ConvertUserIDErrorTemplate = "failed to convert user ID to integer: %w"
	FailedMediaErrorTemplate   = "failed to fetch media list: %w"
)

Variables

View Source
var (
	ErrNoTracker = errors.New("no tracker set up")
	ErrNoMapper  = errors.New("no mapper set up")
)

Functions

This section is empty.

Types

type Getter added in v0.2.0

type Getter interface {
	Get(string) (*http.Response, error)
}

Getter provides a way to retrieve data through HTTP GET requests

type Mapper

type Mapper interface {
	io.Closer

	MapIDs(context.Context, []entities.SourceID) ([]entities.TargetID, error)
	Refresh(context.Context, Getter) error
}

Mapper transforms IDs between two services based on the data from a provider

type MediaLister added in v0.2.0

type MediaLister interface {
	// Generate fetches the user media list from the Tracker and transform the IDs
	// found to the target service through the Mapper
	Generate(ctx context.Context, name string) (entities.CustomList, error)

	// GetUserID searches the Tracker for the user ID by their name/handle
	GetUserID(ctx context.Context, name string) (string, error)

	// Close closes both the Tracker and Mapper
	Close() error

	// Refresh requests the Mapper to update its mapping definitions
	Refresh(ctx context.Context, client Getter) error
}

func NewMediaLister added in v0.2.0

func NewMediaLister(tracker Tracker, mapper Mapper) (MediaLister, error)

type Tracker

type Tracker interface {
	io.Closer

	GetUserID(ctx context.Context, name string) (string, error)
	GetMediaListIDs(ctx context.Context, userId string) ([]entities.SourceID, error)
}

Tracker provides access to user metadata such as ID and media list from an upstream media tracking service

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL