streaminganalytics

package
v1.1.17 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2026 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Package streaminganalytics provides streaming analytics and performance telemetry services. It aggregates real-time streaming metrics, processes time-series data, and provides analytical insights for media streaming performance, bandwidth usage, and viewer behavior.

Index

Constants

View Source
const (
	EventTypeSessionStart  = "session_start"
	EventTypeSessionEnd    = "session_end"
	EventTypeRebufferStart = "rebuffer_start"
	EventTypeBuffering     = "buffering"
)

Event type constants

Variables

This section is empty.

Functions

This section is empty.

Types

type AnalyticsRepository

type AnalyticsRepository interface {
	GetMediaAnalyticsByTimeRange(ctx context.Context, mediaID string, startTime, endTime time.Time, limit int) ([]*models.MediaAnalytics, error)
	GetAllMediaAnalyticsByTimeRange(ctx context.Context, startTime, endTime time.Time, limit int) ([]*models.MediaAnalytics, error)
	GetBandwidthByTimeRange(ctx context.Context, startTime, endTime time.Time, limit int) ([]*models.MediaAnalytics, error)
	StoreMediaAnalytics(ctx context.Context, analytics *models.MediaAnalytics) error
}

AnalyticsRepository defines the interface for media analytics data access

type PopularityRepository

type PopularityRepository interface {
	GetPopularMediaByPeriod(ctx context.Context, period string, limit int, cursor *string) ([]*models.MediaPopularity, error)
	IncrementViewCount(ctx context.Context, mediaID, period string, incrementBy int64) error
	UpsertPopularity(ctx context.Context, popularity *models.MediaPopularity) error
}

PopularityRepository defines the interface for media popularity aggregates

type Service

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

Service provides streaming analytics functionality

func NewService

func NewService(
	analyticsRepo AnalyticsRepository,
	popularityRepo PopularityRepository,
	sessionRepo SessionRepository,
	logger *zap.Logger,
) *Service

NewService creates a new streaming analytics service

func (*Service) AggregateRollup

func (s *Service) AggregateRollup(ctx context.Context, window time.Duration) error

AggregateRollup performs time-windowed rollup aggregation (called by scheduled job)

func (*Service) GetBandwidthUsage

func (s *Service) GetBandwidthUsage(ctx context.Context, period model.TimePeriod) (*model.BandwidthReport, error)

GetBandwidthUsage retrieves bandwidth usage report for a given time period

func (*Service) GetPopularStreams

func (s *Service) GetPopularStreams(ctx context.Context, first int, after *string) (*model.StreamConnection, error)

GetPopularStreams retrieves the most popular streams based on stored popularity data

func (*Service) GetStreamingAnalytics

func (s *Service) GetStreamingAnalytics(ctx context.Context, mediaID string) (*model.StreamingAnalytics, error)

GetStreamingAnalytics retrieves detailed analytics for a specific media item

func (*Service) RecordStreamingEvent

func (s *Service) RecordStreamingEvent(ctx context.Context, mediaID, userID, eventType, quality string, duration float64, bytesLoaded int64) error

RecordStreamingEvent records a streaming event for analytics ingestion and updates popularity aggregates

type SessionRepository

type SessionRepository interface {
}

SessionRepository defines the interface for media session data access

Jump to

Keyboard shortcuts

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