Skip to content

Commit

Permalink
config: Create storage-fallback-urls flag
Browse files Browse the repository at this point in the history
  • Loading branch information
victorges committed Jun 21, 2024
1 parent bbf1581 commit 05886e5
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions config/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ type Cli struct {
EncryptKey string
VodDecryptPublicKey string
VodDecryptPrivateKey string
StorageFallbackURLs map[string]string
GateURL string
StreamHealthHookURL string
BroadcasterURL string
Expand Down
3 changes: 2 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ func main() {
fs.StringVar(&cli.EncryptKey, "encrypt", "", "Key for encrypting network traffic within Serf. Must be a base64-encoded 32-byte key.")
fs.StringVar(&cli.VodDecryptPublicKey, "catalyst-public-key", "", "Public key of the catalyst node for encryption")
fs.StringVar(&cli.VodDecryptPrivateKey, "catalyst-private-key", "", "Private key of the catalyst node for encryption")
config.CommaMapFlag(fs, &cli.StorageFallbackURLs, "storage-fallback-urls", map[string]string{}, `Comma-separated map of primary to backup storage URLs. If a file fails downloading from one of the primary storages (detected by prefix), it will fallback to the corresponding backup URL after having the prefix replaced`)
fs.StringVar(&cli.GateURL, "gate-url", "http://localhost:3004/api/access-control/gate", "Address to contact playback gating API for access control verification")
config.InvertedBoolFlag(fs, &cli.MistTriggerSetup, "mist-trigger-setup", true, "Overwrite Mist triggers with the ones built into catalyst-api")
fs.IntVar(&cli.SerfQueueSize, "serf-queue-size", 100000, "Size of internal serf queue before messages are dropped")
Expand Down Expand Up @@ -226,7 +227,7 @@ func main() {
}
// Start the "co-ordinator" that determines whether to send jobs to the Catalyst transcoding pipeline
// or an external one
vodEngine, err := pipeline.NewCoordinator(pipeline.Strategy(cli.VodPipelineStrategy), cli.SourceOutput, cli.ExternalTranscoder, statusClient, metricsDB, vodDecryptPrivateKey, cli.BroadcasterURL, cli.SourcePlaybackHosts, c2)
vodEngine, err := pipeline.NewCoordinator(pipeline.Strategy(cli.VodPipelineStrategy), cli.SourceOutput, cli.ExternalTranscoder, statusClient, metricsDB, vodDecryptPrivateKey, cli.StorageFallbackURLs, cli.BroadcasterURL, cli.SourcePlaybackHosts, c2)
if err != nil {
glog.Fatalf("Error creating VOD pipeline coordinator: %v", err)
}
Expand Down
9 changes: 8 additions & 1 deletion pipeline/coordinator.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,16 @@ type Coordinator struct {
MetricsDB *sql.DB
InputCopy clients.InputCopier
VodDecryptPrivateKey *rsa.PrivateKey
StorageFallbackURLs map[string]string
SourceOutputURL *url.URL
C2PA *c2pa.C2PA
}

func NewCoordinator(strategy Strategy, sourceOutputURL, extTranscoderURL string, statusClient clients.TranscodeStatusClient, metricsDB *sql.DB, VodDecryptPrivateKey *rsa.PrivateKey, broadcasterURL string, sourcePlaybackHosts map[string]string, c2pa *c2pa.C2PA) (*Coordinator, error) {
func NewCoordinator(
strategy Strategy, sourceOutputURL, extTranscoderURL string, statusClient clients.TranscodeStatusClient,
metricsDB *sql.DB, VodDecryptPrivateKey *rsa.PrivateKey, storageFallbackURLs map[string]string, broadcasterURL string,
sourcePlaybackHosts map[string]string, c2pa *c2pa.C2PA) (*Coordinator, error) {

if !strategy.IsValid() {
return nil, fmt.Errorf("invalid strategy: %s", strategy)
}
Expand Down Expand Up @@ -205,12 +210,14 @@ func NewCoordinator(strategy Strategy, sourceOutputURL, extTranscoderURL string,
Broadcaster: broadcaster,
probe: video.Probe{},
sourcePlaybackHosts: sourcePlaybackHosts,
storageFallbackURLs: storageFallbackURLs,
},
pipeExternal: &external{extTranscoder},
Jobs: cache.New[*JobInfo](),
MetricsDB: metricsDB,
InputCopy: clients.NewInputCopy(),
VodDecryptPrivateKey: VodDecryptPrivateKey,
StorageFallbackURLs: storageFallbackURLs,
SourceOutputURL: sourceOutput,
C2PA: c2pa,
}, nil
Expand Down
1 change: 1 addition & 0 deletions pipeline/ffmpeg.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ type ffmpeg struct {
Broadcaster clients.BroadcasterClient
probe video.Prober
sourcePlaybackHosts map[string]string
storageFallbackURLs map[string]string
}

func init() {
Expand Down

0 comments on commit 05886e5

Please sign in to comment.