httpapi

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2026 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AdminHandler

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

AdminHandler serves admin UI and admin JSON APIs.

func NewAdminHandler

func NewAdminHandler(catalog CatalogStore, channelsSvc ChannelsService, automation ...AutomationDeps) (*AdminHandler, error)

func (*AdminHandler) Close

func (h *AdminHandler) Close()

Close cancels all in-flight dynamic sync workers and waits for them to finish. It is safe to call multiple times.

func (*AdminHandler) RegisterRoutes

func (h *AdminHandler) RegisterRoutes(mux *http.ServeMux, adminAuth string)

func (*AdminHandler) SetDVRScheduler

func (h *AdminHandler) SetDVRScheduler(scheduler DVRScheduler)

func (*AdminHandler) SetDVRService

func (h *AdminHandler) SetDVRService(service DVRService)

func (*AdminHandler) SetJSONBodyLimitBytes

func (h *AdminHandler) SetJSONBodyLimitBytes(limit int64)

func (*AdminHandler) SetLogger

func (h *AdminHandler) SetLogger(logger *slog.Logger)

func (*AdminHandler) SetSourceHealthClearRuntime

func (h *AdminHandler) SetSourceHealthClearRuntime(provider SourceHealthClearRuntime)

func (*AdminHandler) SetTunerStatusProvider

func (h *AdminHandler) SetTunerStatusProvider(provider TunerStatusProvider)

type AutomationDeps

type AutomationDeps struct {
	Settings  AutomationSettingsStore
	Scheduler AutomationScheduler
	Runner    AutomationRunner
	JobFuncs  map[string]jobs.JobFunc
}

AutomationDeps contains services required by automation API/UI handlers.

type AutomationRunner

type AutomationRunner interface {
	Start(ctx context.Context, jobName, triggeredBy string, fn jobs.JobFunc) (int64, error)
	GetRun(ctx context.Context, runID int64) (jobs.Run, error)
	ListRuns(ctx context.Context, jobName string, limit, offset int) ([]jobs.Run, error)
}

AutomationRunner starts and queries asynchronous job runs.

type AutomationScheduler

type AutomationScheduler interface {
	ListSchedules(ctx context.Context) ([]scheduler.JobSchedule, error)
	UpdateJobSchedule(ctx context.Context, jobName string, enabled bool, cronSpec string) error
	UpdateTimezone(ctx context.Context, timezone string) error
	ValidateCron(spec string) error
	Timezone() string
	LoadFromSettings(ctx context.Context) error
}

AutomationScheduler manages schedule state and runtime updates.

type AutomationSettingsStore

type AutomationSettingsStore interface {
	GetSetting(ctx context.Context, key string) (string, error)
	SetSettings(ctx context.Context, values map[string]string) error
	DeleteAllStreamMetrics(ctx context.Context) (int64, error)
}

AutomationSettingsStore reads and writes automation settings.

type CatalogStore

type CatalogStore interface {
	GetGroups(ctx context.Context) ([]playlist.Group, error)
	ListGroupsPaged(ctx context.Context, limit, offset int, includeCounts bool) ([]playlist.Group, int, error)
	ListItems(ctx context.Context, q playlist.Query) ([]playlist.Item, int, error)
	ListCatalogItems(ctx context.Context, q playlist.Query) ([]playlist.Item, int, error)
	CatalogSearchWarningForQuery(search string, searchRegex bool) (sqlite.CatalogSearchWarning, error)
	ListActiveItemKeysByCatalogFilter(ctx context.Context, groupNames []string, searchQuery string, searchRegex bool) ([]string, error)
}

CatalogStore captures read APIs required by the admin HTTP layer.

type ChannelsService

type ChannelsService interface {
	Create(ctx context.Context, itemKey, guideName, channelKey string, dynamicRule *channels.DynamicSourceRule) (channels.Channel, error)
	Delete(ctx context.Context, channelID int64) error
	List(ctx context.Context) ([]channels.Channel, error)
	ListPaged(ctx context.Context, limit, offset int) ([]channels.Channel, int, error)
	Reorder(ctx context.Context, channelIDs []int64) error
	Update(ctx context.Context, channelID int64, guideName *string, enabled *bool, dynamicRule *channels.DynamicSourceRule) (channels.Channel, error)
	SyncDynamicSources(ctx context.Context, channelID int64, matchedItemKeys []string) (channels.DynamicSourceSyncResult, error)
	ListDynamicChannelQueries(ctx context.Context) ([]channels.DynamicChannelQuery, error)
	ListDynamicChannelQueriesPaged(ctx context.Context, limit, offset int) ([]channels.DynamicChannelQuery, int, error)
	GetDynamicChannelQuery(ctx context.Context, queryID int64) (channels.DynamicChannelQuery, error)
	CreateDynamicChannelQuery(ctx context.Context, create channels.DynamicChannelQueryCreate) (channels.DynamicChannelQuery, error)
	UpdateDynamicChannelQuery(ctx context.Context, queryID int64, update channels.DynamicChannelQueryUpdate) (channels.DynamicChannelQuery, error)
	DeleteDynamicChannelQuery(ctx context.Context, queryID int64) error
	ListDynamicGeneratedChannelsPaged(ctx context.Context, queryID int64, limit, offset int) ([]channels.Channel, int, error)
	ReorderDynamicGeneratedChannels(ctx context.Context, queryID int64, channelIDs []int64) error
	SyncDynamicChannelBlocks(ctx context.Context) (channels.DynamicChannelSyncResult, error)

	ListSources(ctx context.Context, channelID int64, enabledOnly bool) ([]channels.Source, error)
	ListSourcesPaged(ctx context.Context, channelID int64, enabledOnly bool, limit, offset int) ([]channels.Source, int, error)
	AddSource(ctx context.Context, channelID int64, itemKey string, allowCrossChannel bool) (channels.Source, error)
	DeleteSource(ctx context.Context, channelID, sourceID int64) error
	ReorderSources(ctx context.Context, channelID int64, sourceIDs []int64) error
	UpdateSource(ctx context.Context, channelID, sourceID int64, enabled *bool) (channels.Source, error)
	ClearSourceHealth(ctx context.Context, channelID int64) (int64, error)
	ClearAllSourceHealth(ctx context.Context) (int64, error)

	DuplicateSuggestions(ctx context.Context, minItems int, searchQuery string, limit, offset int) ([]channels.DuplicateGroup, int, error)
}

ChannelsService captures channel/source operations needed by admin routes.

type DVRScheduler

type DVRScheduler interface {
	ValidateCron(spec string) error
	UpdateJobSchedule(ctx context.Context, jobName string, enabled bool, cronSpec string) error
}

DVRScheduler captures scheduler operations needed by DVR configuration handlers.

type DVRService

type DVRService interface {
	GetState(ctx context.Context) (dvr.ConfigState, error)
	UpdateConfig(ctx context.Context, instance dvr.InstanceConfig) (dvr.ConfigState, error)
	TestConnection(ctx context.Context) (dvr.TestResult, error)
	ListLineups(ctx context.Context, refresh bool) ([]dvr.DVRLineup, error)
	Sync(ctx context.Context, req dvr.SyncRequest) (dvr.SyncResult, error)
	ReverseSync(ctx context.Context, req dvr.ReverseSyncRequest) (dvr.ReverseSyncResult, error)
	ReverseSyncChannel(ctx context.Context, channelID int64, req dvr.ReverseSyncRequest) (dvr.ReverseSyncResult, error)
	ListChannelMappings(ctx context.Context, enabledOnly bool, includeDynamic bool) ([]dvr.ChannelMapping, error)
	ListChannelMappingsPaged(ctx context.Context, enabledOnly bool, includeDynamic bool, limit, offset int) ([]dvr.ChannelMapping, int, error)
	GetChannelMapping(ctx context.Context, channelID int64) (dvr.ChannelMapping, error)
	UpdateChannelMapping(ctx context.Context, channelID int64, update dvr.ChannelMappingUpdate) (dvr.ChannelMapping, error)
	ReloadLineup(ctx context.Context) error
}

DVRService captures DVR integration operations exposed to admin APIs.

type SourceHealthClearRuntime

type SourceHealthClearRuntime interface {
	ClearSourceHealth(channelID int64) error
	ClearAllSourceHealth() error
}

SourceHealthClearRuntime clears runtime health caches/persistence state after source-health mutations.

type TunerRecoveryTrigger

type TunerRecoveryTrigger interface {
	TriggerSessionRecovery(channelID int64, reason string) error
}

TunerRecoveryTrigger optionally enables admin-triggered shared-session recovery requests from the tuner status UI/API.

type TunerStatusProvider

type TunerStatusProvider interface {
	TunerStatusSnapshot() stream.TunerStatusSnapshot
}

TunerStatusProvider captures runtime tuner/session status.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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