Skip to content

Commit

Permalink
add sqs endpoint for localstack
Browse files Browse the repository at this point in the history
  • Loading branch information
marjisound committed Oct 8, 2024
1 parent 748da57 commit 8ac1d25
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
7 changes: 6 additions & 1 deletion backend/app/AppComponents.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import org.apache.pekko.actor.{ActorSystem, CoordinatedShutdown}
import org.apache.pekko.actor.CoordinatedShutdown.Reason
import cats.syntax.either._
import com.amazonaws.client.builder.AwsClientBuilder
import com.amazonaws.services.sqs.{AmazonSQSClient, AmazonSQSClientBuilder}
import com.gu.pandomainauth
import com.gu.pandomainauth.PublicSettings
Expand Down Expand Up @@ -75,7 +76,11 @@ class AppComponents(context: Context, config: Config)
val ingestionExecutionContext = actorSystem.dispatchers.lookup("ingestion-context")

val s3Client = new S3Client(config.s3)(s3ExecutionContext)
val sqsClient = AmazonSQSClientBuilder.standard().withRegion(config.sqs.region).build()

val sqsClient = if (config.sqs.endpoint.isDefined)
AmazonSQSClientBuilder.standard().withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration(config.sqs.endpoint.get, config.sqs.region)).build()
else
AmazonSQSClientBuilder.standard().withRegion(config.sqs.region).build()

val workerName = config.worker.name.getOrElse(InetAddress.getLocalHost.getHostName)

Expand Down
3 changes: 2 additions & 1 deletion backend/app/services/Config.scala
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,8 @@ case class S3Config(
)

case class SQSConfig(
region: String
region: String,
endpoint: Option[String]
)

case class BucketConfig(
Expand Down
1 change: 1 addition & 0 deletions backend/app/utils/AwsDiscovery.scala
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ object AwsDiscovery extends Logging {
transcriptionOutputQueueUrl = readSSMParameter("transcribe/transcriptionOutputQueueUrl", stack, stage, ssmClient),
transcriptionServiceQueueUrl = readSSMParameter("transcribe/transcriptionServiceQueueUrl", stack, stage, ssmClient)
),
sqs = config.sqs.copy(endpoint = None),
underlying = config.underlying
.withValue("play.http.secret.key", fromAnyRef(readSSMParameter("pfi/playSecret", stack, stage, ssmClient)))
.withValue("pekko.actor.provider", fromAnyRef("local")) // disable Pekko clustering, we query EC2 directly
Expand Down
7 changes: 4 additions & 3 deletions backend/conf/application.conf
Original file line number Diff line number Diff line change
Expand Up @@ -207,12 +207,13 @@ ocr {

transcribe {
whisperModelFilename = "ggml-base.bin"
transcriptionServiceQueueUrl = "http://sqs.eu-west-1.localhost.localstack.cloud:4566/000000000000/transcription-service-task-queue-DEV.fifo"
transcriptionOutputQueueUrl = "http://sqs.eu-west-1.localhost.localstack.cloud:4566/000000000000/giant-output-queue-DEV.fifo"
transcriptionServiceQueueUrl = "http://localhost:4566/000000000000/transcription-service-task-queue-DEV.fifo"
transcriptionOutputQueueUrl = "http://localhost:4566/000000000000/giant-output-queue-DEV.fifo"
}

sqs {
region = "eu-west-1"
region = "eu-west-1",
endpoint = "http://localhost:4566"
}

# This will overwrite some settings from above
Expand Down

0 comments on commit 8ac1d25

Please sign in to comment.