2016-03-17 01:27:48 +01:00
|
|
|
package engine
|
|
|
|
|
|
|
|
import "time"
|
|
|
|
|
2016-03-17 22:35:10 +01:00
|
|
|
const NowPlayingExpire = time.Duration(60) * time.Minute
|
2016-03-17 01:27:48 +01:00
|
|
|
|
|
|
|
type NowPlayingInfo struct {
|
2016-03-17 14:34:32 +01:00
|
|
|
TrackId string
|
|
|
|
Start time.Time
|
|
|
|
Username string
|
|
|
|
PlayerId int
|
|
|
|
PlayerName string
|
2016-03-17 01:27:48 +01:00
|
|
|
}
|
|
|
|
|
2016-03-23 18:51:02 +01:00
|
|
|
// This repo must have the semantics of a FIFO queue, for each playerId
|
2016-03-17 01:27:48 +01:00
|
|
|
type NowPlayingRepository interface {
|
2016-03-23 15:06:26 +01:00
|
|
|
// Insert at the head of the queue
|
|
|
|
Enqueue(playerId int, playerName string, trackId, username string) error
|
|
|
|
|
2016-03-23 18:51:02 +01:00
|
|
|
// Removes and returns the element at the end of the queue
|
|
|
|
Dequeue(playerId int) (*NowPlayingInfo, error)
|
|
|
|
|
2016-03-23 15:06:26 +01:00
|
|
|
// Returns the element at the head of the queue (last inserted one)
|
|
|
|
Head(playerId int) (*NowPlayingInfo, error)
|
|
|
|
|
2016-03-23 18:51:02 +01: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 15:06:26 +01:00
|
|
|
|
2016-03-23 18:51:02 +01:00
|
|
|
// Returns all tails from all playerIds
|
2016-03-23 15:06:26 +01:00
|
|
|
GetAll() ([]*NowPlayingInfo, error)
|
2016-03-17 01:27:48 +01:00
|
|
|
}
|