Skip to content

Commit

Permalink
Merge pull request #26862 from guardian/facia-press-dev
Browse files Browse the repository at this point in the history
Only require frontPressToolQueue and frontPressCronQueue if used
  • Loading branch information
davidfurey authored Jan 31, 2024
2 parents b7d32b1 + f9eef32 commit a82bc67
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
18 changes: 11 additions & 7 deletions facia-press/app/frontpress/FrontPressCron.scala
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,17 @@ class FrontPressCron(liveFapiFrontPress: LiveFapiFrontPress, toolPressQueueWorke
}
}

override 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")
}
Expand Down
2 changes: 1 addition & 1 deletion facia-press/app/frontpress/JsonQueueWorker.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
4 changes: 3 additions & 1 deletion facia-press/app/lifecycle/FaciaPressLifecycle.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down

0 comments on commit a82bc67

Please sign in to comment.