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
- type AnalyticsRepository
- type PopularityRepository
- type Service
- func (s *Service) AggregateRollup(ctx context.Context, window time.Duration) error
- func (s *Service) GetBandwidthUsage(ctx context.Context, period model.TimePeriod) (*model.BandwidthReport, error)
- func (s *Service) GetPopularStreams(ctx context.Context, first int, after *string) (*model.StreamConnection, error)
- func (s *Service) GetStreamingAnalytics(ctx context.Context, mediaID string) (*model.StreamingAnalytics, error)
- func (s *Service) RecordStreamingEvent(ctx context.Context, mediaID, userID, eventType, quality string, ...) error
- type SessionRepository
Constants ¶
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 ¶
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
type SessionRepository ¶
type SessionRepository interface {
}
SessionRepository defines the interface for media session data access