From 98dd23ffca9bc429384a6feace6befcda6c0a592 Mon Sep 17 00:00:00 2001 From: David Furey Date: Wed, 31 Jan 2024 11:48:52 +0000 Subject: [PATCH 1/2] Only require frontPressToolQueue and frontPressCronQueue if used This change allows you to run facia-press locally with less config --- facia-press/app/frontpress/FrontPressCron.scala | 2 +- facia-press/app/frontpress/JsonQueueWorker.scala | 2 +- facia-press/app/lifecycle/FaciaPressLifecycle.scala | 4 +++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/facia-press/app/frontpress/FrontPressCron.scala b/facia-press/app/frontpress/FrontPressCron.scala index 01e61b2422d2..9b253ffc9731 100644 --- a/facia-press/app/frontpress/FrontPressCron.scala +++ b/facia-press/app/frontpress/FrontPressCron.scala @@ -23,7 +23,7 @@ class FrontPressCron(liveFapiFrontPress: LiveFapiFrontPress, toolPressQueueWorke } } - override val queue: JsonMessageQueue[SNSNotification] = (Configuration.faciatool.frontPressCronQueue map { queueUrl => + override lazy val queue: JsonMessageQueue[SNSNotification] = (Configuration.faciatool.frontPressCronQueue map { queueUrl => val credentials = Configuration.aws.mandatoryCredentials JsonMessageQueue[SNSNotification]( diff --git a/facia-press/app/frontpress/JsonQueueWorker.scala b/facia-press/app/frontpress/JsonQueueWorker.scala index f2359427d03b..b35e06487a58 100644 --- a/facia-press/app/frontpress/JsonQueueWorker.scala +++ b/facia-press/app/frontpress/JsonQueueWorker.scala @@ -63,7 +63,7 @@ object JsonQueueWorker { abstract class JsonQueueWorker[A: Reads]()(implicit executionContext: ExecutionContext) extends GuLogging { import JsonQueueWorker._ - val queue: JsonMessageQueue[A] + def queue: JsonMessageQueue[A] val deleteOnFailure: Boolean = false final private val lastSuccessfulReceipt = DateTimeRecorder() diff --git a/facia-press/app/lifecycle/FaciaPressLifecycle.scala b/facia-press/app/lifecycle/FaciaPressLifecycle.scala index 39023ee073a6..402954aada98 100644 --- a/facia-press/app/lifecycle/FaciaPressLifecycle.scala +++ b/facia-press/app/lifecycle/FaciaPressLifecycle.scala @@ -21,7 +21,9 @@ class FaciaPressLifecycle( } override def start(): Unit = { - toolPressQueueWorker.start() + if (Configuration.faciatool.frontPressToolQueue.isDefined) { + toolPressQueueWorker.start() + } if (Configuration.faciatool.frontPressCronQueue.isDefined) { frontPressCron.start() } From f9eef32bc05f0869c561b3ccea0da6989b2ec531 Mon Sep 17 00:00:00 2001 From: David Furey Date: Wed, 31 Jan 2024 12:59:39 +0000 Subject: [PATCH 2/2] Scala format --- .../app/frontpress/FrontPressCron.scala | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/facia-press/app/frontpress/FrontPressCron.scala b/facia-press/app/frontpress/FrontPressCron.scala index 9b253ffc9731..12e2f9f94486 100644 --- a/facia-press/app/frontpress/FrontPressCron.scala +++ b/facia-press/app/frontpress/FrontPressCron.scala @@ -23,13 +23,17 @@ class FrontPressCron(liveFapiFrontPress: LiveFapiFrontPress, toolPressQueueWorke } } - override lazy val queue: JsonMessageQueue[SNSNotification] = (Configuration.faciatool.frontPressCronQueue map { queueUrl => - val credentials = Configuration.aws.mandatoryCredentials - - JsonMessageQueue[SNSNotification]( - AmazonSQSAsyncClient.asyncBuilder.withCredentials(credentials).withRegion(conf.Configuration.aws.region).build(), - queueUrl, - ) + override lazy val queue: JsonMessageQueue[SNSNotification] = (Configuration.faciatool.frontPressCronQueue map { + queueUrl => + val credentials = Configuration.aws.mandatoryCredentials + + JsonMessageQueue[SNSNotification]( + AmazonSQSAsyncClient.asyncBuilder + .withCredentials(credentials) + .withRegion(conf.Configuration.aws.region) + .build(), + queueUrl, + ) }) getOrElse { throw new RuntimeException("Required property 'frontpress.sqs.cron_queue_url' not set") }