Skip to content

Commit c7d216c

Browse files
committed
Move event bus pusher to its own common module
1 parent fe8e16b commit c7d216c

4 files changed

Lines changed: 45 additions & 37 deletions

File tree

build.sbt

Lines changed: 41 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ lazy val commontest = project
9999

100100
lazy val common = project
101101
.dependsOn(commoneventconsumer)
102-
.dependsOn(apiModels % "test->test", apiModels % "compile->compile")
103102
.settings(LocalDynamoDBCommon.settings)
104103
.settings(standardSettings: _*)
105104
.settings(
@@ -124,8 +123,7 @@ lazy val common = project
124123
"org.postgresql" % "postgresql" % "42.7.10",
125124
"ch.qos.logback" % "logback-core" % logbackVersion,
126125
"ch.qos.logback" % "logback-classic" % logbackVersion,
127-
"net.logstash.logback" % "logstash-logback-encoder" % "8.1",
128-
"software.amazon.awssdk" % "eventbridge" % "2.20.162",
126+
"net.logstash.logback" % "logstash-logback-encoder" % "8.1"
129127
),
130128
fork := true,
131129
startDynamoDBLocal := startDynamoDBLocal.dependsOn(Test / compile).value,
@@ -250,33 +248,33 @@ lazy val apiModels = {
250248

251249
def lambda(projectName: String, directoryName: String, mainClassName: Option[String] = None): Project =
252250
Project(projectName, file(directoryName))
253-
.enablePlugins(AssemblyPlugin)
254-
.settings(
255-
organization := "com.gu",
256-
resolvers ++= Seq(
257-
"Guardian GitHub Releases" at "https://guardian.github.com/maven/repo-releases",
258-
"snapshots" at "https://oss.sonatype.org/content/repositories/snapshots"
259-
),
260-
libraryDependencies ++= Seq(
261-
"com.amazonaws" % "aws-lambda-java-core" % "1.4.0",
262-
"org.slf4j" % "slf4j-api" % slf4jVersion,
263-
"com.gu" %% "simple-configuration-core" % simpleConfigurationVersion,
264-
"com.gu" %% "simple-configuration-ssm" % simpleConfigurationVersion,
265-
"ch.qos.logback" % "logback-classic" % logbackVersion,
266-
"net.logstash.logback" % "logstash-logback-encoder" % "8.1",
267-
specs2 % Test
268-
),
269-
assemblyJarName := s"$projectName.jar",
270-
assembly / assemblyMergeStrategy := {
271-
case "META-INF/MANIFEST.MF" => MergeStrategy.discard
272-
case _ => MergeStrategy.first
273-
},
274-
Test / run / fork := true,
275-
scalacOptions := compilerOptions,
276-
mainClass := mainClassName,
277-
// Workaround Mockito causes deadlock on SBT classloaders: https://github.com/sbt/sbt/issues/3022
278-
Test / parallelExecution := false
279-
)
251+
.enablePlugins(AssemblyPlugin)
252+
.settings(
253+
organization := "com.gu",
254+
resolvers ++= Seq(
255+
"Guardian GitHub Releases" at "https://guardian.github.com/maven/repo-releases",
256+
"snapshots" at "https://oss.sonatype.org/content/repositories/snapshots"
257+
),
258+
libraryDependencies ++= Seq(
259+
"com.amazonaws" % "aws-lambda-java-core" % "1.4.0",
260+
"org.slf4j" % "slf4j-api" % slf4jVersion,
261+
"com.gu" %% "simple-configuration-core" % simpleConfigurationVersion,
262+
"com.gu" %% "simple-configuration-ssm" % simpleConfigurationVersion,
263+
"ch.qos.logback" % "logback-classic" % logbackVersion,
264+
"net.logstash.logback" % "logstash-logback-encoder" % "8.1",
265+
specs2 % Test
266+
),
267+
assemblyJarName := s"$projectName.jar",
268+
assembly / assemblyMergeStrategy := {
269+
case "META-INF/MANIFEST.MF" => MergeStrategy.discard
270+
case _ => MergeStrategy.first
271+
},
272+
Test / run / fork := true,
273+
scalacOptions := compilerOptions,
274+
mainClass := mainClassName,
275+
// Workaround Mockito causes deadlock on SBT classloaders: https://github.com/sbt/sbt/issues/3022
276+
Test / parallelExecution := false
277+
)
280278

281279
lazy val schedulelambda = lambda("schedule", "schedulelambda")
282280
.dependsOn(commonscheduledynamodb)
@@ -303,8 +301,16 @@ lazy val schedulelambda = lambda("schedule", "schedulelambda")
303301
)
304302
}
305303

304+
lazy val commonEventBusPusher = project
305+
.dependsOn(apiModels % "test->test", apiModels % "compile->compile")
306+
.settings(Seq(
307+
libraryDependencies ++= Seq(
308+
"software.amazon.awssdk" % "eventbridge" % "2.20.162"
309+
),
310+
))
311+
306312
lazy val football = lambda("football", "football")
307-
.dependsOn(common)
313+
.dependsOn(commonEventBusPusher)
308314
.settings(
309315
resolvers += "Guardian GitHub Releases" at "https://guardian.github.com/maven/repo-releases",
310316
libraryDependencies ++= Seq(
@@ -433,10 +439,11 @@ lazy val notificationworkerlambda = lambda("notificationworkerlambda", "notifica
433439
// Hopefully this workaround can be removed once play-json-extensions either updates to Play 3.0 or is merged into play-json
434440
ExclusionRule(organization = "com.typesafe.play")
435441
),
436-
)
442+
)
437443

438444
lazy val fakebreakingnewslambda = lambda("fakebreakingnewslambda", "fakebreakingnewslambda", Some("fakebreakingnews.LocalRun"))
439445
.dependsOn(common)
446+
.dependsOn(apiModels % "test->test", apiModels % "compile->compile")
440447
.settings(
441448
libraryDependencies ++= Seq(
442449
"com.squareup.okhttp3" % "okhttp" % okHttpVersion,
@@ -462,12 +469,14 @@ lazy val reportExtractor = lambda("reportextractor", "reportextractor", Some("co
462469

463470
lazy val liveactivities = lambda("liveactivities", "liveactivities", Some("com.gu.liveactivities.LambdaLocalRun"))
464471
.dependsOn(common)
472+
.dependsOn(commonEventBusPusher)
465473
.settings(LocalDynamoDBLiveActivities.settings)
466474
.settings(
467475
libraryDependencies ++= Seq(
468476
"com.turo" % "pushy" % "0.13.10",
469477
"com.squareup.okhttp3" % "okhttp" % okHttpVersion,
470478
"software.amazon.awssdk" % "dynamodb" % awsSdk2Version,
479+
"software.amazon.awssdk" % "eventbridge" % "2.20.162",
471480
"org.scanamo" %% "scanamo" % "6.0.0",
472481
"org.scanamo" %% "scanamo-testkit" % "6.0.0" % "test"
473482
),

common/src/main/scala/aws/LiveActivityPusher.scala renamed to commonEventBusPusher/src/main/scala/com/gu/mobile/liveactivities/event/bus/LiveActivityPusher.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package aws
1+
package com.gu.mobile.liveactivities.event.bus
22

33
import com.gu.mobile.notifications.client.models.liveActitivites._
44
import org.slf4j.Logger

football/src/main/scala/com/gu/mobile/notifications/football/Lambda.scala

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
package com.gu.mobile.notifications.football
22

3-
import aws.LiveActivityPusher
4-
5-
import java.net.{URI, URL}
3+
import java.net.URI
64
import java.time.ZonedDateTime
75
import java.util.concurrent.TimeUnit
86
import com.amazonaws.regions.Regions
97
import com.amazonaws.services.dynamodbv2.{AmazonDynamoDBAsync, AmazonDynamoDBAsyncClientBuilder}
108
import com.gu.contentapi.client.GuardianContentClient
9+
import com.gu.mobile.liveactivities.event.bus.LiveActivityPusher
1110
import com.gu.mobile.notifications.football.lib.{ArticleSearcher, DynamoDistinctCheck, DynamoMatchLiveActivity, DynamoMatchNotification, EventConsumer, EventFilter, FootballData, LiveActivityEventConsumer, NotificationHttpProvider, NotificationSender, NotificationsApiClient, PaFootballClient, SyntheticMatchEventGenerator}
1211
import com.gu.mobile.notifications.football.notificationbuilders.{MatchStatusLiveActivityPayloadBuilder, MatchStatusNotificationBuilder}
1312
import play.api.libs.json.Json

liveactivities/src/main/scala/com/gu/liveactivities/Lambda.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package com.gu.liveactivities
22

3-
import aws.LiveActivityPusher
43
import com.gu.liveactivities.service.{Authentication, LiveActivityChannelRepository}
54
import com.gu.liveactivities.util.{Configuration, IosConfiguration, Logging}
5+
import com.gu.mobile.liveactivities.event.bus.LiveActivityPusher
66
import software.amazon.awssdk.auth.credentials.{AwsCredentialsProviderChain, DefaultCredentialsProvider, ProfileCredentialsProvider}
77
import software.amazon.awssdk.core.client.config.ClientOverrideConfiguration
88
import software.amazon.awssdk.regions.Region

0 commit comments

Comments
 (0)