FEAT: Discovery Video Service Subscription
Build, Push and Deploy CMS / build-push-deploy (push) Successful in 2m35s
Build, Push and Deploy Discovery / build-push-deploy (push) Successful in 1m55s
Deploy Infrastructure / pulumi-up (push) Successful in 2s

This commit is contained in:
FahdShalhoub
2026-08-29 16:50:58 +03:00
parent 98950aba20
commit 6f9e04ee97
34 changed files with 1754 additions and 65 deletions
+25 -1
View File
@@ -187,7 +187,7 @@ func (c MediaConvertEvents) handleJobEvent(ctx context.Context, body string) boo
}
}
err := repositories.VideoRepo.UpdateVideoOutcomeByJobID(ctx, event.Detail.JobID, status, playbackURL)
video, err := repositories.VideoRepo.UpdateVideoOutcomeByJobID(ctx, event.Detail.JobID, status, playbackURL)
if errors.Is(err, repositories.ErrVideoNotFound) {
// Not a fault: the topic carries every job in the account, including
// ones this service never submitted.
@@ -202,5 +202,29 @@ func (c MediaConvertEvents) handleJobEvent(ctx context.Context, body string) boo
}
log.Printf("Recorded A Job Outcome: job=%q status=%q playback=%q", event.Detail.JobID, status, playbackURL)
// Only a video that came out ready is worth showing, so only that one is
// announced. A failed job has already had its status recorded above, and
// the catalogue has no use for it.
if status != models.VideoStatusReady {
return true
}
if err := services.CatalogueClient.AnnounceVideo(ctx, services.CatalogueVideo{
VideoID: video.ID,
Title: video.Title,
PlaybackURL: video.PlaybackURL,
Categories: video.CategoryNames,
}); err != nil {
// Worth another attempt: the outcome is already recorded, and the
// update is idempotent, so a redelivery re-runs it and tries the
// announcement again. The cost is that a consumer can see the same
// video twice, which is what at-least-once delivery means anyway.
log.Printf("Something Went Wrong Announcing A Ready Video: video=%q job=%q: %s",
video.ID, event.Detail.JobID, err)
return false
}
log.Printf("Announced A Ready Video: video=%q playback=%q", video.ID, video.PlaybackURL)
return true
}