Implement Scrobble buffering/retrying

This commit is contained in:
Deluan 2021-06-24 00:01:05 -04:00
parent fb183e58e9
commit 289da56f64
17 changed files with 513 additions and 96 deletions

View file

@ -33,6 +33,7 @@ type DataStore interface {
Property(ctx context.Context) PropertyRepository
User(ctx context.Context) UserRepository
UserProps(ctx context.Context) UserPropsRepository
ScrobbleBuffer(ctx context.Context) ScrobbleBufferRepository
Resource(ctx context.Context, model interface{}) ResourceRepository

21
model/scrobble_buffer.go Normal file
View file

@ -0,0 +1,21 @@
package model
import "time"
type ScrobbleEntry struct {
MediaFile
Service string
UserID string `json:"user_id" orm:"column(user_id)"`
PlayTime time.Time
EnqueueTime time.Time
}
type ScrobbleEntries []ScrobbleEntry
type ScrobbleBufferRepository interface {
UserIDs(service string) ([]string, error)
Enqueue(service, userId, mediaFileId string, playTime time.Time) error
Next(service string, userId string) (*ScrobbleEntry, error)
Dequeue(entry *ScrobbleEntry) error
Length() (int64, error)
}