video

package
v0.0.0-...-dec19c8 Latest Latest
Warning

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

Go to latest
Published: May 17, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Quotas

type Quotas struct {
	VideosPerUser uint
	MaxTotalSize  uint64
}

type Service

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

Service is a Video API service. It has two "realms": user-side API and service-side API.

User-side API provides CRUD operations with Video objects for a single user. While service-side API provides handlers for video updates by media processing services.

Besides different API handlers they also differs in authentication approach: user-side only checks for valid user id in jwt cookie, while service-API looks up jwt in Bearer token and checks for valid service role.

In production environment only user-side API should be exposed to public.

func NewService

func NewService(cfg *ServiceConfig) *Service

func (*Service) CreateVideo

func (svc *Service) CreateVideo(ctx context.Context, usr *user.User, req *model.CreateRequest) (*model.Video, error)

func (*Service) DeleteVideo

func (svc *Service) DeleteVideo(ctx context.Context, usr *user.User, vid string) error

func (*Service) GetQuotas

func (svc *Service) GetQuotas(ctx context.Context, usr *user.User) (*model.UserStats, error)

func (*Service) GetVideo

func (svc *Service) GetVideo(ctx context.Context, usr *user.User, vid string, resumeUpload bool) (*model.Video, error)

func (*Service) GetVideos

func (svc *Service) GetVideos(ctx context.Context, usr *user.User) ([]*model.Video, error)

func (*Service) GetVideosByStatus

func (svc *Service) GetVideosByStatus(ctx context.Context, status model.Status) ([]*model.Video, error)

func (*Service) NotifyPartUpload

func (svc *Service) NotifyPartUpload(ctx context.Context, vid string, part *model.Part) error

func (*Service) UpdateVideoStatus

func (svc *Service) UpdateVideoStatus(ctx context.Context, vid string, status model.Status) error

func (*Service) UpdateVideoStatusAndMeta

func (svc *Service) UpdateVideoStatusAndMeta(
	ctx context.Context,
	vid string,
	status model.Status,
	pbMeta []byte,
) error

func (*Service) WatchVideo

func (svc *Service) WatchVideo(ctx context.Context, usr *user.User, vid string, genURL bool) ([]byte, error)

type ServiceConfig

type ServiceConfig struct {
	Logger             *zap.Logger
	Store              Store
	UploadSessionStore SessionStore
	WatchSessionStore  SessionStore
	WatchURLPrefix     string
	UploadURLPrefix    string
	Quotas             Quotas
}

type SessionStore

type SessionStore interface {
	Set(ctx context.Context, session *session.Session) error
	Get(ctx context.Context, id string) (*session.Session, error)
}

SessionStore stores upload and watch sessions.

type Store

type Store interface {
	Create(ctx context.Context, vi *model.Video) error
	Get(ctx context.Context, id string, userID string) (*model.Video, error)
	GetAll(ctx context.Context, userID string) ([]*model.Video, error)
	Delete(ctx context.Context, id string, userID string) error
	Usage(ctx context.Context, userID string) (*model.UserUsage, error)

	GetListByStatus(ctx context.Context, status model.Status) ([]*model.Video, error)
	Update(ctx context.Context, vi *model.Video) error
	UpdateStatus(ctx context.Context, vi *model.Video) error

	UpdatePart(ctx context.Context, vid string, part *model.Part) error
	DeleteUploadedParts(ctx context.Context, vid string) error
}

Store is used by videoapi service to store Video and Part objects.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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