Skip to content

Commit

Permalink
use config value for max upload queue size (#772)
Browse files Browse the repository at this point in the history
  • Loading branch information
frostbyte73 authored Sep 12, 2024
1 parent 7ccc032 commit 0396afb
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions pkg/config/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ type BaseConfig struct {
BackupStorage string `yaml:"backup_storage"` // backup file location for failed uploads
ClusterID string `yaml:"cluster_id"` // cluster this instance belongs to
EnableChromeSandbox bool `yaml:"enable_chrome_sandbox"` // enable Chrome sandbox, requires extra docker configuration
MaxUploadQueue int `yaml:"max_upload_queue"` // maximum upload queue size, in minutes
StorageConfig `yaml:",inline"` // upload config (S3, Azure, GCP, or AliOSS)
SessionLimits `yaml:"session_limits"` // session duration limits

Expand Down
4 changes: 4 additions & 0 deletions pkg/config/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const (
trackCpuCost = 0.5
maxCpuUtilization = 0.8
maxConcurrentWeb = 18
maxUploadQueue = 60

defaultTemplatePort = 7980
defaultTemplateBaseTemplate = "http://localhost:%d/"
Expand Down Expand Up @@ -115,6 +116,9 @@ func NewServiceConfig(confString string) (*ServiceConfig, error) {
if conf.MaxConcurrentWeb <= 0 {
conf.MaxConcurrentWeb = maxConcurrentWeb
}
if conf.MaxUploadQueue <= 0 {
conf.MaxUploadQueue = maxUploadQueue
}

if conf.TemplateBase == "" {
conf.TemplateBase = fmt.Sprintf(defaultTemplateBaseTemplate, conf.TemplatePort)
Expand Down
2 changes: 1 addition & 1 deletion pkg/pipeline/sink/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ type imageUpdate struct {
}

func newImageSink(u uploader.Uploader, p *config.PipelineConfig, o *config.ImageConfig, callbacks *gstreamer.Callbacks) (*ImageSink, error) {
maxPendingUploads := 900 / o.CaptureInterval
maxPendingUploads := (p.MaxUploadQueue * 60) / int(o.CaptureInterval)
return &ImageSink{
Uploader: u,
ImageConfig: o,
Expand Down
2 changes: 1 addition & 1 deletion pkg/pipeline/sink/segments.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func newSegmentSink(u uploader.Uploader, p *config.PipelineConfig, o *config.Seg
outputType = types.OutputTypeTS
}

maxPendingUploads := 900 / o.SegmentDuration
maxPendingUploads := (p.MaxUploadQueue * 60) / o.SegmentDuration
s := &SegmentSink{
Uploader: u,
SegmentConfig: o,
Expand Down

0 comments on commit 0396afb

Please sign in to comment.