Documentation ¶
Overview ¶
Background processing on songs is structured in terms of a workflow, where each song goes through a series of consecutive states or 'actions'. These actions are usually triggered upon import of a new song.
This has some advantages with respect to running everything sequentially in a background goroutine, most importantly that the song state machine can be easily restarted, making the processing components stateless.
Index ¶
- Variables
- func NewSongStateMachine(db services.Database, storage services.Storage, idx services.Index, ...) *tasks.StateMachine
- func RegisterSongAction(name string, fn func(*SongActionBase) SongAction)
- type ActivateSongAction
- type CheckMetadataAction
- type DeactivateSongAction
- type EncodeMp3Action
- type SongAction
- type SongActionBase
- type TimbreAnalysisAction
Constants ¶
This section is empty.
Variables ¶
var (
NoOpAction = []string{}
)
Functions ¶
func NewSongStateMachine ¶
func NewSongStateMachine(db services.Database, storage services.Storage, idx services.Index, tc services.TaskClient) *tasks.StateMachine
func RegisterSongAction ¶
func RegisterSongAction(name string, fn func(*SongActionBase) SongAction)
Types ¶
type ActivateSongAction ¶
type ActivateSongAction struct {
*SongActionBase
}
ActivateSongAction makes a song 'active' in the db.
func (*ActivateSongAction) HandleSong ¶
type CheckMetadataAction ¶
type CheckMetadataAction struct {
*SongActionBase
}
CheckMetadataAction checks whether metadata for a song is sufficient, and triggers a check on last.fm if it isn't.
func (*CheckMetadataAction) HandleSong ¶
type DeactivateSongAction ¶
type DeactivateSongAction struct {
*SongActionBase
}
DeactivateSongAction makes a song 'inactive' in the db.
func (*DeactivateSongAction) HandleSong ¶
type EncodeMp3Action ¶
type EncodeMp3Action struct {
*SongActionBase
}
func (*EncodeMp3Action) HandleSong ¶
type SongAction ¶
type SongAction interface { GetDb() services.Database HandleSong(session services.Session, song *api.Song, w io.Writer) error }
SongAction is the common interface for song actions.
type SongActionBase ¶
SongActionBase provides context to the song state machine actions.
func (*SongActionBase) GetDb ¶
func (a *SongActionBase) GetDb() services.Database
type TimbreAnalysisAction ¶
type TimbreAnalysisAction struct {
*SongActionBase
}
TimbreAnalysisAction computes the timbre fingerprint of a song.