manager

package
v0.19.0 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2024 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TokenCtxField     = "token"
	AuthHeader        = "Authorization"
	AuthTokenPrefix   = "Bearer "
	AdminChannelField = "channel"
)

Variables

View Source
var (
	QueueLength = prometheus.NewGaugeVec(prometheus.GaugeOpts{
		Name: "transcoding_queue_length",
		Help: "Video queue length",
	}, []string{"queue"})

	QueueHits = prometheus.NewGaugeVec(prometheus.GaugeOpts{
		Name: "transcoding_queue_hits",
		Help: "Video queue hits",
	}, []string{"queue"})

	QueueItemAge = prometheus.NewSummaryVec(prometheus.SummaryOpts{
		Name: "transcoding_queue_item_age_seconds",
		Help: "Age of queue items before they get processed",
	}, []string{"queue"})
)

Functions

func CreateRoutes

func CreateRoutes(r *router.Router, manager *VideoManager, log logging.KVLogger, cb AuthCallback)

CreateRoutes creates a set of HTTP entrypoints that will route requests into video library.

func RegisterMetrics

func RegisterMetrics()

func SetLogger

func SetLogger(l *zap.SugaredLogger)

Types

type AuthCallback

type AuthCallback func(*fasthttp.RequestCtx) bool

type Gatekeeper

type Gatekeeper func(key string, value interface{}, queue *mfr.Queue) bool

Gatekeeper defines a function that checks if supplied queue item and its value should be admitted to the queue.

type HttpServerConfig

type HttpServerConfig struct {
	ManagerToken string
	Bind         string
}

type Pool

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

Pool contains queues which can admit items based on gatekeeper functions.

func NewPool

func NewPool() *Pool

func (*Pool) AddQueue

func (p *Pool) AddQueue(name string, minHits uint, k Gatekeeper)

AddQueue adds a queue and its gatekeeper function to the pool.

func (*Pool) Admit

func (p *Pool) Admit(key string, value interface{}) error

Admit retries to put item into the first queue that would accept it. Queues are traversed in the same order they are added. If gatekeeper returns an error, admission stops and the error is returned to the caller.

func (*Pool) Next

func (p *Pool) Next() *mfr.Item

Next returns the next item in the queue almost in a non-blocking way.

func (*Pool) Out

func (p *Pool) Out() <-chan *mfr.Item

func (*Pool) Start

func (p *Pool) Start()

Start will launch the cycle of retrieving items out of queues. Should be called after at least one `AddQueue` call. Queues are pooled sequentially.

func (*Pool) Stop

func (p *Pool) Stop()

Stop stops the queue polling routine.

type TranscodingRequest

type TranscodingRequest struct {
	resolve.ResolvedStream
	// contains filtered or unexported fields
}

func (*TranscodingRequest) Complete

func (r *TranscodingRequest) Complete()

func (*TranscodingRequest) Reject

func (r *TranscodingRequest) Reject()

func (*TranscodingRequest) Release

func (r *TranscodingRequest) Release()

type VideoLibrary

type VideoLibrary interface {
	GetURL(sdHash string) (string, error)
	GetAllChannels() ([]db.Channel, error)
}

type VideoManager

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

func NewManager

func NewManager(lib *library.Library, minHits int) *VideoManager

NewManager creates a video library manager with a pool for future transcoding requests.

func (*VideoManager) Library

func (m *VideoManager) Library() *library.Library

func (*VideoManager) Pool

func (m *VideoManager) Pool() *Pool

func (*VideoManager) RequestStatus

func (m *VideoManager) RequestStatus(sdHash string) int

func (*VideoManager) Requests

func (m *VideoManager) Requests() <-chan *TranscodingRequest

Requests returns next transcoding request to be processed. It polls all queues in the pool evenly.

func (*VideoManager) ResolveStream

func (m *VideoManager) ResolveStream(uri string) (*TranscodingRequest, error)

func (*VideoManager) StartHttpServer

func (m *VideoManager) StartHttpServer(config HttpServerConfig) (chan struct{}, error)

func (*VideoManager) Video

func (m *VideoManager) Video(uri string) (string, error)

Video checks if video exists in the library or waiting in one of the queues. If neither, it adds claim to the pool for later processing.

Jump to

Keyboard shortcuts

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