state

package
v2.8.1-beta2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 14, 2026 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrLaunchInProgress = errors.New("launch already in progress")

ErrLaunchInProgress is returned when a launch is attempted while another is in progress.

Functions

This section is empty.

Types

type LauncherManager added in v2.7.0

type LauncherManager struct {
	// contains filtered or unexported fields
}

LauncherManager manages the lifecycle of launcher contexts across the application. It provides thread-safe access to a shared context that gets canceled whenever a new launcher starts, allowing previous launcher cleanup routines to detect when they've been superseded and should skip their cleanup actions.

func NewLauncherManager added in v2.7.0

func NewLauncherManager() *LauncherManager

func (*LauncherManager) EndLaunch added in v2.8.0

func (lm *LauncherManager) EndLaunch()

EndLaunch releases the launch lock.

func (*LauncherManager) GetContext added in v2.7.0

func (lm *LauncherManager) GetContext() context.Context

GetContext returns the current launcher context. This context will be canceled when a new launcher starts.

func (*LauncherManager) NewContext added in v2.7.0

func (lm *LauncherManager) NewContext() context.Context

NewContext cancels the current launcher context and creates a new one. This should be called when starting a new launcher to invalidate any cleanup routines from previous launchers. Returns the newly created context.

func (*LauncherManager) TryStartLaunch added in v2.8.0

func (lm *LauncherManager) TryStartLaunch() error

TryStartLaunch attempts to acquire the launch lock. Returns ErrLaunchInProgress if a launch is already in progress.

type State

type State struct {
	Notifications chan<- models.Notification
	// contains filtered or unexported fields
}

State holds the runtime state of the Zaparoo service.

LOCKING RULES: The mu mutex protects all mutable fields. To prevent deadlocks:

  • Never send to channels while holding the lock (notifications, callbacks)
  • Never call external methods (reader.OnMediaChange, hooks) while holding the lock
  • Pattern: lock → modify state → copy needed data → unlock → send notifications

See SetActiveCard, SetActiveMedia, SetReader, RemoveReader for examples.

func NewState

func NewState(platform platforms.Platform, bootUUID string) (state *State, notificationCh <-chan models.Notification)

func (*State) ActiveMedia

func (s *State) ActiveMedia() *models.ActiveMedia

func (*State) BootUUID added in v2.7.0

func (s *State) BootUUID() string

func (*State) GetActiveCard

func (s *State) GetActiveCard() tokens.Token

func (*State) GetActivePlaylist

func (s *State) GetActivePlaylist() *playlists.Playlist

func (*State) GetContext

func (s *State) GetContext() context.Context

func (*State) GetLastScanned

func (s *State) GetLastScanned() tokens.Token

func (*State) GetReader

func (s *State) GetReader(device string) (readers.Reader, bool)

func (*State) GetSoftwareToken

func (s *State) GetSoftwareToken() *tokens.Token

func (*State) GetWroteToken

func (s *State) GetWroteToken() *tokens.Token

func (*State) Inbox added in v2.8.0

func (s *State) Inbox() *inbox.Service

Inbox returns the inbox service for adding system notifications.

func (*State) LauncherManager added in v2.7.0

func (s *State) LauncherManager() *LauncherManager

func (*State) ListReaders

func (s *State) ListReaders() []string

func (*State) RemoveReader

func (s *State) RemoveReader(device string)

func (*State) RunZapScriptEnabled

func (s *State) RunZapScriptEnabled() bool

func (*State) SetActiveCard

func (s *State) SetActiveCard(card tokens.Token)

func (*State) SetActiveMedia

func (s *State) SetActiveMedia(media *models.ActiveMedia)

func (*State) SetActivePlaylist

func (s *State) SetActivePlaylist(playlist *playlists.Playlist)

func (*State) SetInbox added in v2.8.0

func (s *State) SetInbox(svc *inbox.Service)

SetInbox sets the inbox service. Called during service startup after database is ready.

func (*State) SetOnMediaStartHook

func (s *State) SetOnMediaStartHook(hook func(*models.ActiveMedia))

func (*State) SetReader

func (s *State) SetReader(device string, reader readers.Reader)

func (*State) SetRunZapScript

func (s *State) SetRunZapScript(run bool)

func (*State) SetSoftwareToken

func (s *State) SetSoftwareToken(token *tokens.Token)

func (*State) SetWroteToken

func (s *State) SetWroteToken(token *tokens.Token)

func (*State) StopService

func (s *State) StopService()

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL