adapters

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: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache interface {
	io.Closer

	GetString(ctx context.Context, key string) (string, error)
	SetString(ctx context.Context, key, value string, options ...CacheOption) error
}

Cache is a solution for fast storage and retrieval of ephemeral data

type CacheOption added in v0.2.0

type CacheOption interface {
	Apply(params *CacheParams) error
}

func WithTTL added in v0.2.0

func WithTTL(duration time.Duration) CacheOption

type CacheOptionFn added in v0.2.0

type CacheOptionFn func(params *CacheParams) error

func (CacheOptionFn) Apply added in v0.2.0

func (fn CacheOptionFn) Apply(params *CacheParams) error

type CacheParams added in v0.2.0

type CacheParams struct {
	TTL time.Duration
}

func NewCacheParams added in v0.2.0

func NewCacheParams(options ...CacheOption) (*CacheParams, error)

type CachedTracker added in v0.2.0

type CachedTracker struct {
	Cache   Cache
	Tracker usecases.Tracker
	TTL     CachedTrackerTTL
}

CachedTracker wraps a Tracker with a passthrough cache

func (*CachedTracker) Close added in v0.2.0

func (wrapper *CachedTracker) Close() error

func (*CachedTracker) GetMediaListIDs added in v0.2.0

func (wrapper *CachedTracker) GetMediaListIDs(ctx context.Context, userId string) ([]string, error)

func (*CachedTracker) GetUserID added in v0.2.0

func (wrapper *CachedTracker) GetUserID(ctx context.Context, name string) (string, error)

type CachedTrackerTTL added in v0.2.0

type CachedTrackerTTL struct {
	UserID       time.Duration
	MediaListIDs time.Duration
}

type JSONLocalProvider added in v0.2.0

type JSONLocalProvider[F Metadata] struct {
	Fs   fs.FS
	Name string
}

JSONLocalProvider is a filesystem-based metadata provider

func (JSONLocalProvider[F]) Fetch added in v0.2.0

func (source JSONLocalProvider[F]) Fetch(ctx context.Context, client usecases.Getter) ([]Metadata, error)

func (JSONLocalProvider[F]) String added in v0.2.0

func (source JSONLocalProvider[F]) String() string

type JSONProvider added in v0.2.0

type JSONProvider[F Metadata] string

JSONLocalProvider is a HTTP-based metadata provider

func (JSONProvider[F]) Fetch added in v0.2.0

func (source JSONProvider[F]) Fetch(ctx context.Context, client usecases.Getter) ([]Metadata, error)

func (JSONProvider[F]) String added in v0.2.0

func (source JSONProvider[F]) String() string

type Mapper added in v0.2.0

type Mapper struct {
	Provider Provider[Metadata]
	Store    Store
}

Mapper handles the mapping of media data. It also handles the retrieval of data from a provider and its persistent storage

func (*Mapper) Close added in v0.2.0

func (mapper *Mapper) Close() error

func (*Mapper) MapIDs added in v0.2.0

func (mapper *Mapper) MapIDs(ctx context.Context, ids []entities.SourceID) ([]entities.TargetID, error)

func (*Mapper) Refresh added in v0.2.0

func (mapper *Mapper) Refresh(ctx context.Context, client usecases.Getter) error

type Metadata

type Metadata interface {
	GetSourceID() string
	GetTargetID() string
}

Metadata represents any data that contains both the source Tracker media ID and the target service media ID

type Provider added in v0.2.0

type Provider[T Metadata] interface {
	fmt.Stringer

	Fetch(ctx context.Context, client usecases.Getter) ([]T, error)
}

Provider is a source of mapping media data

type Store

type Store interface {
	io.Closer

	GetMedia(ctx context.Context, id string) (*entities.Media, error)
	GetMediaBulk(ctx context.Context, ids []string) ([]*entities.Media, error)
	PutMedia(ctx context.Context, media *entities.Media) error
	PutMediaBulk(ctx context.Context, medias []*entities.Media) error
}

Store handles the persistent storage and retrieval of media mapping data

Jump to

Keyboard shortcuts

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