2020-01-14 22:22:34 -05:00
|
|
|
package model
|
2016-03-16 20:27:48 -04:00
|
|
|
|
|
|
|
|
import "time"
|
|
|
|
|
|
2016-04-21 10:44:27 -04:00
|
|
|
const NowPlayingExpire = 60 * time.Minute
|
2016-03-16 20:27:48 -04:00
|
|
|
|
|
|
|
|
type NowPlayingInfo struct {
|
2020-01-09 23:33:01 -05:00
|
|
|
TrackID string
|
2016-03-17 09:34:32 -04:00
|
|
|
Start time.Time
|
|
|
|
|
Username string
|
|
|
|
|
PlayerId int
|
|
|
|
|
PlayerName string
|
2016-03-16 20:27:48 -04:00
|
|
|
}
|
|
|
|
|
|
2016-03-23 13:51:02 -04:00
|
|
|
// This repo must have the semantics of a FIFO queue, for each playerId
|
2016-03-16 20:27:48 -04:00
|
|
|
type NowPlayingRepository interface {
|
2016-03-23 10:06:26 -04:00
|
|
|
// Insert at the head of the queue
|
2016-03-24 17:14:13 -04:00
|
|
|
Enqueue(*NowPlayingInfo) error
|
2016-03-23 10:06:26 -04:00
|
|
|
|
2016-03-23 13:51:02 -04:00
|
|
|
// Removes and returns the element at the end of the queue
|
|
|
|
|
Dequeue(playerId int) (*NowPlayingInfo, error)
|
|
|
|
|
|
2016-03-23 10:06:26 -04:00
|
|
|
// Returns the element at the head of the queue (last inserted one)
|
|
|
|
|
Head(playerId int) (*NowPlayingInfo, error)
|
|
|
|
|
|
2016-03-23 13:51:02 -04:00
|
|
|
// Returns the element at the end of the queue (first inserted one)
|
|
|
|
|
Tail(playerId int) (*NowPlayingInfo, error)
|
|
|
|
|
|
|
|
|
|
// Size of the queue for the playerId
|
|
|
|
|
Count(playerId int) (int64, error)
|
2016-03-23 10:06:26 -04:00
|
|
|
|
2020-01-10 21:45:17 -05:00
|
|
|
// Returns all heads from all playerIds
|
2016-03-23 10:06:26 -04:00
|
|
|
GetAll() ([]*NowPlayingInfo, error)
|
2016-03-16 20:27:48 -04:00
|
|
|
}
|