video

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2021 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var InitialMigration = `` /* 561-byte string literal not displayed */

Functions

func FurloughVideos added in v0.5.0

func FurloughVideos(lib *Library, maxSize uint64) (uint64, uint64, error)

FurloughVideos deletes older videos locally, leaving them only on S3, keeping total size of local videos at maxSize.

func RetireVideos added in v0.5.0

func RetireVideos(lib *Library, maxSize uint64) (uint64, uint64, error)

RetireVideos deletes older videos from S3, keeping total size of remote videos at maxSize.

func SetLogger

func SetLogger(l *zap.SugaredLogger)

func SpawnLibraryCleaning added in v0.5.0

func SpawnLibraryCleaning(lib *Library) chan<- interface{}

func SpawnS3uploader added in v0.10.11

func SpawnS3uploader(lib *Library) chan<- interface{}

func StringToSize added in v0.5.0

func StringToSize(s string) uint64

Types

type AddParams

type AddParams struct {
	URL      string
	SDHash   string
	Type     string
	Path     string
	Channel  string
	Size     int64
	Checksum string
}

type Config added in v0.5.0

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

func Configure added in v0.5.0

func Configure() *Config

func (*Config) DB added in v0.5.0

func (c *Config) DB(db *db.DB) *Config

DB is SQL DB instance which is used for storing videos.

func (*Config) LocalStorage added in v0.5.0

func (c *Config) LocalStorage(s storage.LocalDriver) *Config

LocalStorage is a local storage driver for accessing videos on disk.

func (*Config) MaxLocalSize added in v0.5.0

func (c *Config) MaxLocalSize(s string) *Config

func (*Config) MaxRemoteSize added in v0.5.0

func (c *Config) MaxRemoteSize(s string) *Config

func (*Config) RemoteStorage added in v0.5.0

func (c *Config) RemoteStorage(s storage.RemoteDriver) *Config

LocalStorage is a remote (S3) storage driver for accessing remote videos.

type DBTX

type DBTX interface {
	ExecContext(context.Context, string, ...interface{}) (sql.Result, error)
	PrepareContext(context.Context, string) (*sql.Stmt, error)
	QueryContext(context.Context, string, ...interface{}) (*sql.Rows, error)
	QueryRowContext(context.Context, string, ...interface{}) *sql.Row
	BeginTx(context.Context, *sql.TxOptions) (*sql.Tx, error)
}

type Library

type Library struct {
	*Config
	// contains filtered or unexported fields
}

Library contains methods for accessing videos database.

func NewLibrary

func NewLibrary(cfg *Config) *Library

func (Library) Add

func (q Library) Add(params AddParams) (*Video, error)

Add records data about video into database.

func (Library) Furlough added in v0.5.0

func (q Library) Furlough(v *Video) error

func (Library) Get

func (q Library) Get(sdHash string) (*Video, error)

func (Library) ListLocal added in v0.5.0

func (q Library) ListLocal() ([]*Video, error)

func (Library) ListLocalOnly added in v0.5.0

func (q Library) ListLocalOnly() ([]*Video, error)

func (Library) ListRemoteOnly added in v0.5.0

func (q Library) ListRemoteOnly() ([]*Video, error)

func (Library) New added in v0.10.11

func (q Library) New(sdHash string) *storage.LocalStream

func (Library) Retire added in v0.5.0

func (q Library) Retire(v *Video) error

func (Library) UpdateRemotePath added in v0.5.0

func (q Library) UpdateRemotePath(sdHash, url string) error

type Queries

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

func New

func New(db DBTX) *Queries

func (*Queries) Add

func (q *Queries) Add(ctx context.Context, arg AddParams) (*Video, error)

func (*Queries) Delete added in v0.5.0

func (q *Queries) Delete(ctx context.Context, sdHash string) error

func (*Queries) Get

func (q *Queries) Get(ctx context.Context, sdHash string) (*Video, error)

func (*Queries) ListLocal added in v0.5.0

func (q *Queries) ListLocal(ctx context.Context) ([]*Video, error)

func (*Queries) ListLocalOnly added in v0.5.0

func (q *Queries) ListLocalOnly(ctx context.Context) ([]*Video, error)

func (*Queries) ListRemoteOnly added in v0.5.0

func (q *Queries) ListRemoteOnly(ctx context.Context) ([]*Video, error)

func (*Queries) UpdatePath added in v0.5.0

func (q *Queries) UpdatePath(ctx context.Context, sdHash, path string) error

func (*Queries) UpdateRemotePath added in v0.5.0

func (q *Queries) UpdateRemotePath(ctx context.Context, sdHash, url string) error

type Video

type Video struct {
	SDHash     string
	CreatedAt  string
	URL        string
	Path       string
	RemotePath string
	Type       string
	Channel    string

	LastAccessed sql.NullTime
	AccessCount  int64

	Size     int64
	Checksum string
}

func (Video) GetLocation added in v0.5.0

func (v Video) GetLocation() (string, bool)

GetLocation returns a video location suitable for using in HTTP redirect response. Bool in return value signifies if it's a remote location (S3) or local (relative HTTP path).

func (Video) GetSize added in v0.5.0

func (v Video) GetSize() int64

func (Video) GetWeight added in v0.5.0

func (v Video) GetWeight() int64

type VideoLibrary added in v0.10.11

type VideoLibrary interface {
	Get(sdHash string) (*Video, error)
	New(sdHash string) *storage.LocalStream
	Add(params AddParams) (*Video, error)
}

Jump to

Keyboard shortcuts

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