client

package
v0.19.2 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2024 License: MIT Imports: 24 Imported by: 2

Documentation

Index

Constants

View Source
const (
	MasterPlaylistName = "master.m3u8"

	SchemaRemote = "remote://"

	Dev = iota + 1
	Prod
)

Variables

View Source
var (
	ErrNotOK             = errors.New("http response not OK")
	ErrNotFound          = errors.New("fragment not found")
	ErrChannelNotEnabled = resolve.ErrChannelNotEnabled
)
View Source
var (
	TranscodedCacheSizeBytes = prometheus.NewGauge(prometheus.GaugeOpts{
		Name: "transcoded_cache_size_bytes",
	})
	TranscodedCacheItemsCount = prometheus.NewGauge(prometheus.GaugeOpts{
		Name: "transcoded_cache_items_count",
	})
	TranscodedResult = prometheus.NewCounterVec(prometheus.CounterOpts{
		Name: "transcoded_request_result",
	}, []string{"type"})

	TranscodedCacheQueryCount = prometheus.NewCounter(prometheus.CounterOpts{
		Name: "transcoded_cache_query_count",
	})
	TranscodedCacheMiss = prometheus.NewCounter(prometheus.CounterOpts{
		Name: "transcoded_cache_miss",
	})
	TranscodedCacheRetry = prometheus.NewCounter(prometheus.CounterOpts{
		Name: "transcoded_cache_retry",
	})

	FetchSizeBytes = prometheus.NewCounterVec(prometheus.CounterOpts{
		Name: "fetch_size_bytes",
	}, []string{"source"})
	FetchDurationSeconds = prometheus.NewCounterVec(prometheus.CounterOpts{
		Name: "fetch_duration_seconds",
	}, []string{"source"})
	FetchCount = prometheus.NewCounterVec(prometheus.CounterOpts{
		Name: "fetch_count",
	}, []string{"source"})
	FetchFailureCount = prometheus.NewCounterVec(prometheus.CounterOpts{
		Name: "fetch_failure_count",
	}, []string{"source", "type"})
)

Functions

func RegisterMetrics

func RegisterMetrics()

Types

type Client

type Client struct {
	*Configuration
	// contains filtered or unexported fields
}

func New

func New(cfg *Configuration) Client

func (Client) BuildURL

func (c Client) BuildURL(loc streamLocation, filename string) string

func (Client) GetPlaybackPath

func (c Client) GetPlaybackPath(lbryURL, sdHash string) string

GetPlaybackPath returns a root HLS playlist path.

func (Client) PlayFragment

func (c Client) PlayFragment(lbryURL, sdHash, fragmentName string, w http.ResponseWriter, r *http.Request) (int64, error)

PlayFragment retrieves requested stream fragment and serves it into the provided HTTP response.

func (Client) RestoreCache

func (c Client) RestoreCache() (int64, error)

RestoreCache restores cache from disk. LRU data is not restored.

type Configuration

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

func Configure

func Configure() *Configuration

func (*Configuration) CacheSize

func (c *Configuration) CacheSize(size int64) *Configuration

CacheSize defines local disk cache size for downloaded transcoded videos.

func (*Configuration) HTTPClient

func (c *Configuration) HTTPClient(httpClient HTTPRequester) *Configuration

func (*Configuration) ItemsToPrune

func (c *Configuration) ItemsToPrune(i uint32) *Configuration

ItemsToPrune defines how many items to prune during cache cleanup

func (*Configuration) LogLevel

func (c *Configuration) LogLevel(l int) *Configuration

LogLevel sets verbosity of logging. `Dev` outputs a lot of debugging info, `Prod` is more restrained.

func (*Configuration) RemoteServer

func (c *Configuration) RemoteServer(s string) *Configuration

RemoteServer is full URL of remote transcoded videos storage server (sans forward slash at the end).

func (*Configuration) Server

func (c *Configuration) Server(server string) *Configuration

Server sets transcoder server API address.

func (*Configuration) VideoPath

func (c *Configuration) VideoPath(videoPath string) *Configuration

VideoPath is where transcoded videos will be downloaded and stored.

type Fragment

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

func (Fragment) Path

func (f Fragment) Path() string

func (Fragment) Size

func (f Fragment) Size() int64

type HTTPRequester

type HTTPRequester interface {
	Do(req *http.Request) (res *http.Response, err error)
}

Jump to

Keyboard shortcuts

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