state

package
v2.10.0 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2026 License: GPL-3.0 Imports: 13 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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(readerID string) (readers.Reader, bool)

GetReader returns the Reader for a given ReaderID.

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() []readers.Reader

ListReaders returns all registered Reader instances.

func (*State) RemoveReader

func (s *State) RemoveReader(readerID string)

RemoveReader removes a reader by its ReaderID and closes it.

func (*State) RestartRequested added in v2.10.0

func (s *State) RestartRequested() bool

RestartRequested returns true if the service shutdown was triggered by a restart request (e.g. after applying an update).

func (*State) RestartService added in v2.10.0

func (s *State) RestartService()

RestartService signals the service to shut down and restart with the new binary. Used after applying an update for graceful restart instead of os.Exit.

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(reader readers.Reader)

SetReader registers a reader using its ReaderID as the key. If a reader with the same ReaderID exists, it is closed first.

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