webstream

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2023 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Package webstream provides controls for streaming from the web server.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StreamAudioSource added in v0.0.8

func StreamAudioSource(
	ctx context.Context,
	source gostream.AudioSource,
	stream gostream.Stream,
	backoffOpts *BackoffTuningOptions,
	logger logging.Logger,
) error

StreamAudioSource starts a stream from an audio source with a throttled error handler.

func StreamVideoSource added in v0.0.8

func StreamVideoSource(
	ctx context.Context,
	source gostream.VideoSource,
	stream gostream.Stream,
	backoffOpts *BackoffTuningOptions,
	logger logging.Logger,
) error

StreamVideoSource starts a stream from a video source with a throttled error handler.

Types

type BackoffTuningOptions

type BackoffTuningOptions struct {
	// BaseSleep sets the initial amount of time to wait after an error.
	BaseSleep time.Duration
	// MaxSleep determines the maximum amount of time that streamSource is
	// permitted to a sleep after receiving a single error.
	MaxSleep time.Duration
	// Cooldown sets how long since the last error that we can reset our backoff. This
	// should be greater than MaxSleep. This prevents a scenario where we haven't made
	// a call to read for a long time and the error may go away sooner.
	Cooldown time.Duration
}

BackoffTuningOptions represents a set of parameters for determining exponential backoff when receiving multiple simultaneous errors.

BaseSleep is the duration to wait after receiving a new error. After that, the wait time doubles for every subsequent, consecutive error of the same type, until the wait duration reaches the MaxSleep duration.

func (*BackoffTuningOptions) GetSleepTimeFromErrorCount

func (opts *BackoffTuningOptions) GetSleepTimeFromErrorCount(errorCount int) time.Duration

GetSleepTimeFromErrorCount returns a sleep time from an error count.

Jump to

Keyboard shortcuts

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