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
+32
View File
@@ -23,6 +23,19 @@ func baseURL() string {
return defaultBaseURL
}
// defaultDiscoveryBaseURL is where docker-compose publishes discovery on the
// host.
const defaultDiscoveryBaseURL = "http://localhost:8080"
// discoveryBaseURL is the Discovery service the scenarios read the catalogue
// from. Override it the same way as CMS_BASE_URL.
func discoveryBaseURL() string {
if v := strings.TrimSpace(os.Getenv("DISCOVERY_BASE_URL")); v != "" {
return strings.TrimRight(v, "/")
}
return defaultDiscoveryBaseURL
}
// response is one HTTP exchange, kept whole so a failing assertion can print
// the body it actually got rather than just a status code.
type response struct {
@@ -107,6 +120,25 @@ func newClient() *client {
}
}
// newDiscoveryClient is newClient pointed at the read side. Same plumbing —
// only the host differs, since both services speak the same JSON dialect.
func newDiscoveryClient() *client {
return &client{
base: discoveryBaseURL(),
http: &http.Client{Timeout: 30 * time.Second},
}
}
// catalogueVideoBody is GET /api/videos/{id} on discovery: the catalogue's own
// copy of a video, which is a different published shape from the CMS record of
// the same name.
type catalogueVideoBody struct {
ID string `json:"id"`
Title string `json:"title"`
PlaybackURL string `json:"playbackUrl"`
Categories []string `json:"categories"`
}
// postJSON marshals payload and posts it to a path on the CMS.
func (c *client) postJSON(path string, payload any) (response, error) {
encoded, err := json.Marshal(payload)