From 778cafc4eefb4e883541453a92f01585bf3d796b Mon Sep 17 00:00:00 2001 From: Wai Sing Yiu Date: Fri, 27 Sep 2024 13:12:01 +0100 Subject: [PATCH 1/2] Filter out irrelevant collection IDs from front update events --- app/services/FaciaPress.scala | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/services/FaciaPress.scala b/app/services/FaciaPress.scala index 8d775049a96..3d2ff9b5e0d 100644 --- a/app/services/FaciaPress.scala +++ b/app/services/FaciaPress.scala @@ -66,6 +66,8 @@ class FaciaPress(val faciaPressTopic: FaciaPressTopic, val configAgent: ConfigAg path <- configAgent.getConfigsUsingCollectionId(id) } yield path + val pathToCollectionIdsLookup = configAgent.getConfigCollectionMap + def sendEvents(pressType: PressType) = Future.traverse( paths.filter(_ => pressType match { case Live => pressCommand.live @@ -74,7 +76,11 @@ class FaciaPress(val faciaPressTopic: FaciaPressTopic, val configAgent: ConfigAg ) { path => val event = PressJob(FrontPath(path), pressType, forceConfigUpdate = pressCommand.forceConfigUpdate) - val publishResultFuture = faciaPressTopic.publish(event, pressCommand.collectionIds) + val collectionIdsRelevantToPath = pressCommand.collectionIds.filter(collectionId => { + pathToCollectionIdsLookup.get(path).exists(_.contains(collectionId)) + }) + + val publishResultFuture = faciaPressTopic.publish(event, collectionIdsRelevantToPath) publishResultFuture.onComplete { case Failure(error) => From 89d8b5859b6d5e8122bb2064144ab6dcfc1db3e5 Mon Sep 17 00:00:00 2001 From: Wai Sing Yiu Date: Fri, 20 Sep 2024 12:42:47 +0100 Subject: [PATCH 2/2] Add Fanout payload to SNS messages --- app/services/FaciaPress.scala | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/services/FaciaPress.scala b/app/services/FaciaPress.scala index 3d2ff9b5e0d..d8b27903fb4 100644 --- a/app/services/FaciaPress.scala +++ b/app/services/FaciaPress.scala @@ -45,7 +45,14 @@ class FaciaPressTopic(val config: ApplicationConfiguration) { maybeTopic match { case Some(topic) if collectionIds.nonEmpty => import SNSTopics._ - val event = Json.toJson(job).as[JsObject] ++ JsObject(Map("collectionIds" -> Json.toJson(collectionIds))) + val fanoutPayload = Json.toJson(Map( + "collectionIds" -> Json.toJson(collectionIds), + "timestamp" -> Json.toJson(System.currentTimeMillis()), + )).toString() + val event = Json.toJson(job).as[JsObject] ++ JsObject(Map( + "collectionIds" -> Json.toJson(collectionIds), + "fanoutPayload" -> Json.toJson(fanoutPayload), + )) topic.client.publishMessageFuture(topic.topicArn, Json.stringify(event)) case Some(topic) =>