Documentation ¶
Index ¶
- Constants
- Variables
- func Connect(ctx context.Context, cfg config.Config) (radio.StorageService, error)
- func ConnectDB(ctx context.Context, cfg config.Config, multistatement bool) (*sqlx.DB, error)
- func IsDuplicateKeyErr(err error) bool
- func MatchName(regex, name string) bool
- func ProcessQuery(q string) string
- func SplitQuery(q string) []string
- type NewsStorage
- func (ns NewsStorage) AddComment(comment radio.NewsComment) (radio.NewsCommentID, error)
- func (ns NewsStorage) Comments(postid radio.NewsPostID) ([]radio.NewsComment, error)
- func (ns NewsStorage) CommentsPublic(postid radio.NewsPostID) ([]radio.NewsComment, error)
- func (ns NewsStorage) Create(post radio.NewsPost) (radio.NewsPostID, error)
- func (ns NewsStorage) Delete(id radio.NewsPostID) error
- func (ns NewsStorage) Get(id radio.NewsPostID) (*radio.NewsPost, error)
- func (ns NewsStorage) List(limit int64, offset int64) (radio.NewsList, error)
- func (ns NewsStorage) ListPublic(limit int64, offset int64) (radio.NewsList, error)
- func (ns NewsStorage) Update(post radio.NewsPost) error
- type QueueStorage
- type RelayStorage
- type RequestStorage
- type ScheduleStorage
- type SearchService
- type SessionStorage
- type SongStorage
- func (ss SongStorage) AddFavorite(song radio.Song, nick string) (bool, error)
- func (ss SongStorage) AddPlay(song radio.Song, user radio.User, ldiff *radio.Listeners) error
- func (ss SongStorage) Create(song radio.Song) (*radio.Song, error)
- func (ss SongStorage) FavoriteCount(song radio.Song) (int64, error)
- func (ss SongStorage) Favorites(song radio.Song) ([]string, error)
- func (ss SongStorage) FavoritesOf(nick string, limit, offset int64) ([]radio.Song, int64, error)
- func (ss SongStorage) FavoritesOfDatabase(nick string) ([]radio.Song, error)
- func (ss SongStorage) FromHash(hash radio.SongHash) (*radio.Song, error)
- func (ss SongStorage) FromMetadata(metadata string) (*radio.Song, error)
- func (ss SongStorage) LastPlayed(key radio.LastPlayedKey, amountPerPage int) ([]radio.Song, error)
- func (ss SongStorage) LastPlayedCount() (int64, error)
- func (ss SongStorage) LastPlayedPagination(key radio.LastPlayedKey, amountPerPage, pageCount int) (prev, next []radio.LastPlayedKey, err error)
- func (ss SongStorage) PlayedCount(song radio.Song) (int64, error)
- func (ss SongStorage) RemoveFavorite(song radio.Song, nick string) (bool, error)
- func (ss SongStorage) UpdateHashLink(old, new radio.SongHash) error
- func (ss SongStorage) UpdateLength(song radio.Song, length time.Duration) error
- type StatusStorage
- type StorageService
- func (s *StorageService) Close() error
- func (s *StorageService) News(ctx context.Context) radio.NewsStorage
- func (s *StorageService) NewsTx(ctx context.Context, tx radio.StorageTx) (radio.NewsStorage, radio.StorageTx, error)
- func (s *StorageService) Queue(ctx context.Context) radio.QueueStorage
- func (s *StorageService) QueueTx(ctx context.Context, tx radio.StorageTx) (radio.QueueStorage, radio.StorageTx, error)
- func (s *StorageService) Relay(ctx context.Context) radio.RelayStorage
- func (s *StorageService) RelayTx(ctx context.Context, tx radio.StorageTx) (radio.RelayStorage, radio.StorageTx, error)
- func (s *StorageService) Request(ctx context.Context) radio.RequestStorage
- func (s *StorageService) RequestTx(ctx context.Context, tx radio.StorageTx) (radio.RequestStorage, radio.StorageTx, error)
- func (s *StorageService) Schedule(ctx context.Context) radio.ScheduleStorage
- func (s *StorageService) ScheduleTx(ctx context.Context, tx radio.StorageTx) (radio.ScheduleStorage, radio.StorageTx, error)
- func (s *StorageService) Search() radio.SearchService
- func (s *StorageService) Sessions(ctx context.Context) radio.SessionStorage
- func (s *StorageService) SessionsTx(ctx context.Context, tx radio.StorageTx) (radio.SessionStorage, radio.StorageTx, error)
- func (s *StorageService) Song(ctx context.Context) radio.SongStorage
- func (s *StorageService) SongTx(ctx context.Context, tx radio.StorageTx) (radio.SongStorage, radio.StorageTx, error)
- func (s *StorageService) Status(ctx context.Context) radio.StatusStorage
- func (s *StorageService) Submissions(ctx context.Context) radio.SubmissionStorage
- func (s *StorageService) SubmissionsTx(ctx context.Context, tx radio.StorageTx) (radio.SubmissionStorage, radio.StorageTx, error)
- func (s *StorageService) Track(ctx context.Context) radio.TrackStorage
- func (s *StorageService) TrackTx(ctx context.Context, tx radio.StorageTx) (radio.TrackStorage, radio.StorageTx, error)
- func (s *StorageService) User(ctx context.Context) radio.UserStorage
- func (s *StorageService) UserTx(ctx context.Context, tx radio.StorageTx) (radio.UserStorage, radio.StorageTx, error)
- type SubmissionStorage
- func (ss SubmissionStorage) All() ([]radio.PendingSong, error)
- func (ss SubmissionStorage) GetSubmission(id radio.SubmissionID) (*radio.PendingSong, error)
- func (ss SubmissionStorage) InsertPostPending(pend radio.PendingSong) error
- func (ss SubmissionStorage) InsertSubmission(song radio.PendingSong) error
- func (ss SubmissionStorage) LastSubmissionTime(identifier string) (time.Time, error)
- func (ss SubmissionStorage) RemoveSubmission(id radio.SubmissionID) error
- func (ss SubmissionStorage) SubmissionStats(identifier string) (radio.SubmissionStats, error)
- func (ss SubmissionStorage) UpdateSubmissionTime(identifier string) error
- type TrackStorage
- func (ts TrackStorage) All() ([]radio.Song, error)
- func (ts TrackStorage) AllRaw() ([]radio.Song, error)
- func (ts TrackStorage) BeforeLastRequested(before time.Time) ([]radio.Song, error)
- func (ts TrackStorage) DecrementRequestCount(before time.Time) error
- func (ts TrackStorage) Delete(id radio.TrackID) error
- func (ts TrackStorage) Get(id radio.TrackID) (*radio.Song, error)
- func (ts TrackStorage) Insert(song radio.Song) (radio.TrackID, error)
- func (ts TrackStorage) NeedReplacement() ([]radio.Song, error)
- func (ts TrackStorage) QueueCandidates() ([]radio.TrackID, error)
- func (ts TrackStorage) Unusable() ([]radio.Song, error)
- func (ts TrackStorage) UpdateLastPlayed(id radio.TrackID) error
- func (ts TrackStorage) UpdateLastRequested(id radio.TrackID) error
- func (ts TrackStorage) UpdateMetadata(song radio.Song) error
- func (ts TrackStorage) UpdateRequestInfo(id radio.TrackID) error
- func (ts TrackStorage) UpdateUsable(song radio.Song, state radio.TrackState) error
- type UserStorage
- func (us UserStorage) All() ([]radio.User, error)
- func (us UserStorage) ByNick(nick string) (*radio.User, error)
- func (us UserStorage) Create(user radio.User) (radio.UserID, error)
- func (us UserStorage) CreateDJ(user radio.User, dj radio.DJ) (radio.DJID, error)
- func (us UserStorage) Get(name string) (*radio.User, error)
- func (us UserStorage) GetByDJID(id radio.DJID) (*radio.User, error)
- func (us UserStorage) GetByID(id radio.UserID) (*radio.User, error)
- func (us UserStorage) LookupName(name string) (*radio.User, error)
- func (us UserStorage) Permissions() ([]radio.UserPermission, error)
- func (us UserStorage) RecordListeners(listeners radio.Listeners, user radio.User) error
- func (us UserStorage) Update(user radio.User) (radio.User, error)
Constants ¶
const ( // FavePriorityIncrement is the amount we increase/decrease priority by // on a track when it gets favorited/unfavorited FavePriorityIncrement = 1 // RequestPriorityIncremenet is the amount we increase priority by when // a track gets requested RequestPriorityIncrement = 1 // RequestCountIncrement is the amount we increase requestcount by when // a track gets requested RequestCountIncrement = 2 )
Variables ¶
var DatabaseConnectFunc = sqlx.ConnectContext
Functions ¶
func ConnectDB ¶
ConnectDB connects to the configured mariadb instance and returns the raw database object. Argument multistatement indicates if we should allow queries with multiple statements in them.
func IsDuplicateKeyErr ¶
func ProcessQuery ¶
func SplitQuery ¶
Types ¶
type NewsStorage ¶
type NewsStorage struct {
// contains filtered or unexported fields
}
NewsStorage implements radio.NewsStorage
func (NewsStorage) AddComment ¶
func (ns NewsStorage) AddComment(comment radio.NewsComment) (radio.NewsCommentID, error)
func (NewsStorage) Comments ¶
func (ns NewsStorage) Comments(postid radio.NewsPostID) ([]radio.NewsComment, error)
Comments implements radio.NewsStorage
func (NewsStorage) CommentsPublic ¶
func (ns NewsStorage) CommentsPublic(postid radio.NewsPostID) ([]radio.NewsComment, error)
CommentsPublic implements radio.NewsStorage
func (NewsStorage) Create ¶
func (ns NewsStorage) Create(post radio.NewsPost) (radio.NewsPostID, error)
Create implements radio.NewsStorage
func (NewsStorage) Delete ¶
func (ns NewsStorage) Delete(id radio.NewsPostID) error
Delete implements radio.NewsStorage
func (NewsStorage) Get ¶
func (ns NewsStorage) Get(id radio.NewsPostID) (*radio.NewsPost, error)
Get implements radio.NewsStorage
func (NewsStorage) ListPublic ¶
ListPublic implements radio.NewsStorage
type QueueStorage ¶
type QueueStorage struct {
// contains filtered or unexported fields
}
QueueStorage is a radio.QueueStorage backed by a sql database
func (QueueStorage) Load ¶
func (qs QueueStorage) Load(name string) ([]radio.QueueEntry, error)
Load loads the queue name given from the database configured
Implements radio.QueueStorage
func (QueueStorage) Store ¶
func (qs QueueStorage) Store(name string, queue []radio.QueueEntry) error
Store stores the queue given under name in the database configured
Implements radio.QueueStorage
type RelayStorage ¶
type RelayStorage struct {
// contains filtered or unexported fields
}
RelayStorage implements radio.RelayStorage
type RequestStorage ¶
type RequestStorage struct {
// contains filtered or unexported fields
}
RequestStorage implements radio.RequestStorage
func (RequestStorage) LastRequest ¶
func (rs RequestStorage) LastRequest(identifier string) (time.Time, error)
LastRequest implements radio.RequestStorage
func (RequestStorage) UpdateLastRequest ¶
func (rs RequestStorage) UpdateLastRequest(identifier string) error
UpdateLastRequest implements radio.RequestStorage
type ScheduleStorage ¶
type ScheduleStorage struct {
// contains filtered or unexported fields
}
func (ScheduleStorage) History ¶
func (ss ScheduleStorage) History(day radio.ScheduleDay, limit, offset int64) ([]radio.ScheduleEntry, error)
func (ScheduleStorage) Latest ¶
func (ss ScheduleStorage) Latest() ([]*radio.ScheduleEntry, error)
func (ScheduleStorage) Update ¶
func (ss ScheduleStorage) Update(entry radio.ScheduleEntry) error
type SearchService ¶
type SearchService struct {
// contains filtered or unexported fields
}
type SessionStorage ¶
type SessionStorage struct {
// contains filtered or unexported fields
}
SessionStorage implements radio.SessionStorage
func (SessionStorage) Delete ¶
func (ss SessionStorage) Delete(token radio.SessionToken) error
Delete implements radio.SessionStorage
func (SessionStorage) Get ¶
func (ss SessionStorage) Get(token radio.SessionToken) (radio.Session, error)
Get implements radio.SessionStorage
type SongStorage ¶
type SongStorage struct {
// contains filtered or unexported fields
}
SongStorage implements radio.SongStorage
func (SongStorage) AddFavorite ¶
AddFavorite implements radio.SongStorage
func (SongStorage) FavoriteCount ¶
func (ss SongStorage) FavoriteCount(song radio.Song) (int64, error)
FavoriteCount implements radio.SongStorage
func (SongStorage) Favorites ¶
func (ss SongStorage) Favorites(song radio.Song) ([]string, error)
Favorites implements radio.SongStorage
func (SongStorage) FavoritesOf ¶
FavoritesOf implements radio.SongStorage
func (SongStorage) FavoritesOfDatabase ¶
func (ss SongStorage) FavoritesOfDatabase(nick string) ([]radio.Song, error)
FavoritesOfDatabase implements radio.SongStorage
func (SongStorage) FromMetadata ¶
func (ss SongStorage) FromMetadata(metadata string) (*radio.Song, error)
FromMetadata implements radio.SongStorage
func (SongStorage) LastPlayed ¶
func (ss SongStorage) LastPlayed(key radio.LastPlayedKey, amountPerPage int) ([]radio.Song, error)
LastPlayed implements radio.SongStorage
func (SongStorage) LastPlayedCount ¶
func (ss SongStorage) LastPlayedCount() (int64, error)
LastPlayedCount implements radio.SongStorage
func (SongStorage) LastPlayedPagination ¶
func (ss SongStorage) LastPlayedPagination(key radio.LastPlayedKey, amountPerPage, pageCount int) (prev, next []radio.LastPlayedKey, err error)
func (SongStorage) PlayedCount ¶
func (ss SongStorage) PlayedCount(song radio.Song) (int64, error)
PlayedCount implements radio.SongStorage
func (SongStorage) RemoveFavorite ¶
RemoveFavorite implements radio.SongStorage
func (SongStorage) UpdateHashLink ¶
func (ss SongStorage) UpdateHashLink(old, new radio.SongHash) error
func (SongStorage) UpdateLength ¶
UpdateLength implements radio.SongStorage
type StatusStorage ¶
type StatusStorage struct {
// contains filtered or unexported fields
}
type StorageService ¶
type StorageService struct {
// contains filtered or unexported fields
}
StorageService implements radio.StorageService with a sql database
func (*StorageService) Close ¶
func (s *StorageService) Close() error
func (*StorageService) News ¶
func (s *StorageService) News(ctx context.Context) radio.NewsStorage
func (*StorageService) NewsTx ¶
func (s *StorageService) NewsTx(ctx context.Context, tx radio.StorageTx) (radio.NewsStorage, radio.StorageTx, error)
func (*StorageService) Queue ¶
func (s *StorageService) Queue(ctx context.Context) radio.QueueStorage
func (*StorageService) QueueTx ¶
func (s *StorageService) QueueTx(ctx context.Context, tx radio.StorageTx) (radio.QueueStorage, radio.StorageTx, error)
func (*StorageService) Relay ¶
func (s *StorageService) Relay(ctx context.Context) radio.RelayStorage
func (*StorageService) RelayTx ¶
func (s *StorageService) RelayTx(ctx context.Context, tx radio.StorageTx) (radio.RelayStorage, radio.StorageTx, error)
func (*StorageService) Request ¶
func (s *StorageService) Request(ctx context.Context) radio.RequestStorage
func (*StorageService) RequestTx ¶
func (s *StorageService) RequestTx(ctx context.Context, tx radio.StorageTx) (radio.RequestStorage, radio.StorageTx, error)
func (*StorageService) Schedule ¶
func (s *StorageService) Schedule(ctx context.Context) radio.ScheduleStorage
func (*StorageService) ScheduleTx ¶
func (s *StorageService) ScheduleTx(ctx context.Context, tx radio.StorageTx) (radio.ScheduleStorage, radio.StorageTx, error)
func (*StorageService) Search ¶
func (s *StorageService) Search() radio.SearchService
func (*StorageService) Sessions ¶
func (s *StorageService) Sessions(ctx context.Context) radio.SessionStorage
func (*StorageService) SessionsTx ¶
func (s *StorageService) SessionsTx(ctx context.Context, tx radio.StorageTx) (radio.SessionStorage, radio.StorageTx, error)
func (*StorageService) Song ¶
func (s *StorageService) Song(ctx context.Context) radio.SongStorage
func (*StorageService) SongTx ¶
func (s *StorageService) SongTx(ctx context.Context, tx radio.StorageTx) (radio.SongStorage, radio.StorageTx, error)
func (*StorageService) Status ¶
func (s *StorageService) Status(ctx context.Context) radio.StatusStorage
func (*StorageService) Submissions ¶
func (s *StorageService) Submissions(ctx context.Context) radio.SubmissionStorage
func (*StorageService) SubmissionsTx ¶
func (s *StorageService) SubmissionsTx(ctx context.Context, tx radio.StorageTx) (radio.SubmissionStorage, radio.StorageTx, error)
func (*StorageService) Track ¶
func (s *StorageService) Track(ctx context.Context) radio.TrackStorage
func (*StorageService) TrackTx ¶
func (s *StorageService) TrackTx(ctx context.Context, tx radio.StorageTx) (radio.TrackStorage, radio.StorageTx, error)
func (*StorageService) User ¶
func (s *StorageService) User(ctx context.Context) radio.UserStorage
type SubmissionStorage ¶
type SubmissionStorage struct {
// contains filtered or unexported fields
}
SubmissionStorage implements radio.SubmissionStorage
func (SubmissionStorage) All ¶
func (ss SubmissionStorage) All() ([]radio.PendingSong, error)
func (SubmissionStorage) GetSubmission ¶
func (ss SubmissionStorage) GetSubmission(id radio.SubmissionID) (*radio.PendingSong, error)
func (SubmissionStorage) InsertPostPending ¶
func (ss SubmissionStorage) InsertPostPending(pend radio.PendingSong) error
func (SubmissionStorage) InsertSubmission ¶
func (ss SubmissionStorage) InsertSubmission(song radio.PendingSong) error
func (SubmissionStorage) LastSubmissionTime ¶
func (ss SubmissionStorage) LastSubmissionTime(identifier string) (time.Time, error)
LastSubmissionTime implements radio.SubmissionStorage
func (SubmissionStorage) RemoveSubmission ¶
func (ss SubmissionStorage) RemoveSubmission(id radio.SubmissionID) error
func (SubmissionStorage) SubmissionStats ¶
func (ss SubmissionStorage) SubmissionStats(identifier string) (radio.SubmissionStats, error)
func (SubmissionStorage) UpdateSubmissionTime ¶
func (ss SubmissionStorage) UpdateSubmissionTime(identifier string) error
UpdateSubmissionTime implements radio.SubmissionStorage
type TrackStorage ¶
type TrackStorage struct {
// contains filtered or unexported fields
}
TrackStorage implements radio.TrackStorage
func (TrackStorage) All ¶
func (ts TrackStorage) All() ([]radio.Song, error)
All implements radio.TrackStorage
func (TrackStorage) BeforeLastRequested ¶
BeforeLastRequested implements radio.TrackStorage
func (TrackStorage) DecrementRequestCount ¶
func (ts TrackStorage) DecrementRequestCount(before time.Time) error
DecrementRequestCount implements radio.TrackStorage
func (TrackStorage) NeedReplacement ¶
func (ts TrackStorage) NeedReplacement() ([]radio.Song, error)
func (TrackStorage) QueueCandidates ¶
func (ts TrackStorage) QueueCandidates() ([]radio.TrackID, error)
QueueCandidates implements radio.TrackStorage
Candidates are returned based on their lastplayed and lastrequested values
func (TrackStorage) Unusable ¶
func (ts TrackStorage) Unusable() ([]radio.Song, error)
Unusable implements radio.TrackStorage
func (TrackStorage) UpdateLastPlayed ¶
func (ts TrackStorage) UpdateLastPlayed(id radio.TrackID) error
UpdateLastPlayed implements radio.TrackStorage
func (TrackStorage) UpdateLastRequested ¶
func (ts TrackStorage) UpdateLastRequested(id radio.TrackID) error
UpdateLastRequested implements radio.TrackStorage
func (TrackStorage) UpdateMetadata ¶
func (ts TrackStorage) UpdateMetadata(song radio.Song) error
func (TrackStorage) UpdateRequestInfo ¶
func (ts TrackStorage) UpdateRequestInfo(id radio.TrackID) error
UpdateRequestInfo updates the time the track given was last requested and increases the time between requests for the song.
implements radio.TrackStorage
func (TrackStorage) UpdateUsable ¶
func (ts TrackStorage) UpdateUsable(song radio.Song, state radio.TrackState) error
type UserStorage ¶
type UserStorage struct {
// contains filtered or unexported fields
}
UserStorage implements radio.UserStorage
func (UserStorage) ByNick ¶
func (us UserStorage) ByNick(nick string) (*radio.User, error)
ByNick implements radio.UserStorage
func (UserStorage) Get ¶
func (us UserStorage) Get(name string) (*radio.User, error)
Get implements radio.UserStorage
func (UserStorage) LookupName ¶
func (us UserStorage) LookupName(name string) (*radio.User, error)
LookupName implements radio.UserStorage
func (UserStorage) Permissions ¶
func (us UserStorage) Permissions() ([]radio.UserPermission, error)
Permissions implements radio.UserStorage
func (UserStorage) RecordListeners ¶
RecordListeners implements radio.UserStorage