lives

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(domain string, b Builder)

Types

type BucketSnapshot added in v0.0.5

type BucketSnapshot struct {
	Platform           string    `json:"platform"`
	CapacityPerSec     int       `json:"capacityPerSec"`
	TokensAvailable    int       `json:"tokensAvailable"`
	CurrentLevelIndex  int       `json:"currentLevelIndex"`
	ConsecutiveAtLimit int       `json:"consecutiveAtLimit"`
	LastRefillAt       time.Time `json:"lastRefillAt"`
	LastSecondUsed     int       `json:"lastSecondUsed"`
	Levels             []int     `json:"levels"`
}

type Builder

type Builder interface {
	Build(*url.URL) (LiveApi, error)
}

type Level added in v0.0.5

type Level struct {
	LimitPerSec int
}

type LiveApi

type LiveApi interface {
	GetInfo() (*LiveState, error)
}

func New

func New(sUrl string) (liveApi LiveApi, err error)

type LiveConfig

type LiveConfig struct {
	Id             int
	RoomUrl        string
	Interval       int
	Format         string
	MonitorType    int
	MonitorStartAt string
	MonitorStopAt  string
}

type LiveSession

type LiveSession struct {
	Id              int
	Config          LiveConfig
	State           LiveState
	LiveApi         LiveApi
	EventDispatcher interfaces.Module
	ListenerManager interfaces.Module
	RecorderManager interfaces.Module
	// contains filtered or unexported fields
}

func NewLiveSession

func NewLiveSession(id int, config LiveConfig, liveAPI LiveApi) *LiveSession

func (*LiveSession) GetState

func (s *LiveSession) GetState() LiveState

func (*LiveSession) UpdateState

func (s *LiveSession) UpdateState(newState LiveState)

type LiveState

type LiveState struct {
	LiveId      int
	RoomName    string
	Anchor      string
	Platform    string
	IsLive      bool
	StreamInfos []*StreamUrlInfo
}

type PlatformBucket added in v0.0.5

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

func NewPlatformBucket added in v0.0.5

func NewPlatformBucket(platform string, levels []Level) *PlatformBucket

func (*PlatformBucket) Acquire added in v0.0.5

func (b *PlatformBucket) Acquire(ctx context.Context, n int) error

func (*PlatformBucket) TryAcquire added in v0.0.5

func (b *PlatformBucket) TryAcquire(n int) bool

type StreamUrlInfo

type StreamUrlInfo struct {
	Url                  *url.URL
	Name                 string
	Description          string
	Resolution           int
	Vbitrate             int
	HeadersForDownloader map[string]string
}

type TokenBucketManager added in v0.0.5

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

func GetBucketManager added in v0.0.5

func GetBucketManager() *TokenBucketManager

func NewTokenBucketManager added in v0.0.5

func NewTokenBucketManager(levels []Level) *TokenBucketManager

func (*TokenBucketManager) Acquire added in v0.0.5

func (m *TokenBucketManager) Acquire(ctx context.Context, platform string) error

func (*TokenBucketManager) AcquireBatch added in v0.0.5

func (m *TokenBucketManager) AcquireBatch(ctx context.Context, platform string, n int) error

func (*TokenBucketManager) EnsureBucket added in v0.0.5

func (m *TokenBucketManager) EnsureBucket(platform string) *PlatformBucket

func (*TokenBucketManager) Start added in v0.0.5

func (m *TokenBucketManager) Start()

func (*TokenBucketManager) Status added in v0.0.5

func (m *TokenBucketManager) Status() map[string]BucketSnapshot

func (*TokenBucketManager) Stop added in v0.0.5

func (m *TokenBucketManager) Stop()

func (*TokenBucketManager) TryAcquire added in v0.0.5

func (m *TokenBucketManager) TryAcquire(ctx context.Context, platform string) bool

func (*TokenBucketManager) TryAcquireBatch added in v0.0.5

func (m *TokenBucketManager) TryAcquireBatch(ctx context.Context, platform string, n int) bool

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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