Skip to content
This repository was archived by the owner on Feb 20, 2026. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.improving.app.common.config

import com.typesafe.config.{Config, ConfigFactory}

class AppConfig(useDyanmo: Boolean = false) {
val configFile: String = if (useDyanmo) {
"application-dynamo-journal.conf"
} else {
"application-cass-journal.conf"
}

def loadConfig: Config = ConfigFactory
.load(configFile)
.withFallback(ConfigFactory.defaultApplication())
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,19 @@ import akka.actor.typed.ActorSystem
import akka.actor.typed.scaladsl.Behaviors
import akka.http.scaladsl.Http
import akka.http.scaladsl.model.{HttpRequest, HttpResponse}
import com.typesafe.config.ConfigFactory
import com.improving.app.common.config.AppConfig
import com.typesafe.config.{Config, ConfigFactory}
import com.typesafe.scalalogging.StrictLogging
import org.scalatest.time.SpanSugar.convertIntToGrainOfTime

import scala.concurrent.{ExecutionContext, Future}
import scala.util.{Failure, Success}

/**
* This trait is extended by the gRPC services. This file represents the typical pattern for a gRPC server
* and the parts that only vary across projects is the projectName, port, and ServiceHandler/ServiceImpl to use.
* This trait is extended by the gRPC services. This file represents the typical pattern for a gRPC server and the parts
* that only vary across projects is the projectName, port, and ServiceHandler/ServiceImpl to use.
*/
trait ServiceMain extends App with StrictLogging{
trait ServiceMain extends App with StrictLogging {
// projectName is the name of the service, usually in the format of 'improving-app-SOME-SERVICE'
protected val projectName: String

Expand All @@ -30,10 +31,9 @@ trait ServiceMain extends App with StrictLogging{
*/
protected def run(): Unit = {

val conf = ConfigFactory
.load("application.conf")
.withFallback(ConfigFactory.defaultApplication())
implicit val system = ActorSystem[Nothing](Behaviors.empty, projectName, conf)
val appConfig: AppConfig = new AppConfig(args(0).equals("dynamo"))
val conf: Config = appConfig.loadConfig
implicit val system: ActorSystem[Nothing] = ActorSystem[Nothing](Behaviors.empty, projectName, conf)

// ActorSystem threads will keep the app alive until `system.terminate()` is called

Expand All @@ -55,4 +55,4 @@ trait ServiceMain extends App with StrictLogging{
system.terminate()
}
}
}
}
27 changes: 27 additions & 0 deletions event/src/main/resources/application-dynamo-journal.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Important: enable HTTP/2 in ActorSystem's config
akka.http.server.preview.enable-http2 = on

akka.actor.provider = cluster

//FIXME - autocreate only for dev
akka.actor.serialization-bindings{
"com.improving.app.common.serialize.PBMsgSerializable" = proto
}
akka.remote.artery.canonical.port = 0

akka.actor.allow-java-serialization = off
akka.persistence {
snapshot-store.plugin = "my-dynamodb-snapshot-store"
}
datastax-java-driver.advanced.reconnect-on-init = true
datastax-java-driver {
basic.contact-points = ["10.152.183.5:9042"]
basic.load-balancing-policy.local-datacenter = "datacenter1"
}

my-dynamodb-journal = ${dynamodb-journal}
my-dynamodb-journal {
journal-table = "event_service"
journal-name = "event_service"
endpoint = "https://dynamodb.us-east-1.amazonaws.com"
}
27 changes: 27 additions & 0 deletions member/src/main/resources/application-dynamo-journal.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Important: enable HTTP/2 in ActorSystem's config
akka.http.server.preview.enable-http2 = on

akka.actor.provider = cluster

//FIXME - autocreate only for dev
akka.actor.serialization-bindings{
"com.improving.app.common.serialize.PBMsgSerializable" = proto
}
akka.remote.artery.canonical.port = 0

akka.actor.allow-java-serialization = off
akka.persistence {
snapshot-store.plugin = "my-dynamodb-snapshot-store"
}
datastax-java-driver.advanced.reconnect-on-init = true
datastax-java-driver {
basic.contact-points = ["10.152.183.5:9042"]
basic.load-balancing-policy.local-datacenter = "datacenter1"
}

my-dynamodb-journal = ${dynamodb-journal}
my-dynamodb-journal {
journal-table = "member_service"
journal-name = "member_service"
endpoint = "https://dynamodb.us-east-1.amazonaws.com"
}
27 changes: 27 additions & 0 deletions organization/src/main/resources/application-dynamo-journal.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Important: enable HTTP/2 in ActorSystem's config
akka.http.server.preview.enable-http2 = on

akka.actor.provider = cluster

//FIXME - autocreate only for dev
akka.actor.serialization-bindings{
"com.improving.app.common.serialize.PBMsgSerializable" = proto
}
akka.remote.artery.canonical.port = 0

akka.actor.allow-java-serialization = off
akka.persistence {
snapshot-store.plugin = "my-dynamodb-snapshot-store"
}
datastax-java-driver.advanced.reconnect-on-init = true
datastax-java-driver {
basic.contact-points = ["10.152.183.5:9042"]
basic.load-balancing-policy.local-datacenter = "datacenter1"
}

my-dynamodb-journal = ${dynamodb-journal}
my-dynamodb-journal {
journal-table = "organization_service"
journal-name = "organization_service"
endpoint = "https://dynamodb.us-east-1.amazonaws.com"
}
27 changes: 27 additions & 0 deletions product/src/main/resources/application-dynamo-journal.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Important: enable HTTP/2 in ActorSystem's config
akka.http.server.preview.enable-http2 = on

akka.actor.provider = cluster

//FIXME - autocreate only for dev
akka.actor.serialization-bindings{
"com.improving.app.common.serialize.PBMsgSerializable" = proto
}
akka.remote.artery.canonical.port = 0

akka.actor.allow-java-serialization = off
akka.persistence {
snapshot-store.plugin = "my-dynamodb-snapshot-store"
}
datastax-java-driver.advanced.reconnect-on-init = true
datastax-java-driver {
basic.contact-points = ["10.152.183.5:9042"]
basic.load-balancing-policy.local-datacenter = "datacenter1"
}

my-dynamodb-journal = ${dynamodb-journal}
my-dynamodb-journal {
journal-table = "product_service"
journal-name = "product_service"
endpoint = "https://dynamodb.us-east-1.amazonaws.com"
}
5 changes: 5 additions & 0 deletions project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ object Dependencies {
val cats = "2.9.0"
val circe = "0.14.5"
val gatling = "3.9.5"
val dynamoDB = "1.3.0"
}

import Versions._
Expand Down Expand Up @@ -124,4 +125,8 @@ object Dependencies {
"io.gatling" % "gatling-test-framework" % Versions.gatling % "test",
"com.github.phisgr" % "gatling-grpc" % "0.16.0" % "test"
)

val dynamoDBDependencies: Seq[ModuleID] = Seq(
"com.typesafe.akka" %% "akka-persistence-dynamodb" % Versions.dynamoDB
)
}
2 changes: 1 addition & 1 deletion project/Helpers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ object C {
"org.wvlet.airframe" %% "airframe-ulid" % V.airframeUlidVersion,
) ++ akkaHttpTestingDependencies ++ scalaPbDependencies ++ scalaPbValidationDependencies ++ Seq(
scalaPbCompilerPlugin
),
) ++ dynamoDBDependencies,
dockerSettings(port, artifactName),
)
}
Expand Down
27 changes: 27 additions & 0 deletions store/src/main/resources/application-dynamo-journal.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Important: enable HTTP/2 in ActorSystem's config
akka.http.server.preview.enable-http2 = on

akka.actor.provider = cluster

//FIXME - autocreate only for dev
akka.actor.serialization-bindings{
"com.improving.app.common.serialize.PBMsgSerializable" = proto
}
akka.remote.artery.canonical.port = 0

akka.actor.allow-java-serialization = off
akka.persistence {
snapshot-store.plugin = "my-dynamodb-snapshot-store"
}
datastax-java-driver.advanced.reconnect-on-init = true
datastax-java-driver {
basic.contact-points = ["10.152.183.5:9042"]
basic.load-balancing-policy.local-datacenter = "datacenter1"
}

my-dynamodb-journal = ${dynamodb-journal}
my-dynamodb-journal {
journal-table = "store_service"
journal-name = "store_service"
endpoint = "https://dynamodb.us-east-1.amazonaws.com"
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,11 @@ datastax-java-driver.advanced.reconnect-on-init = true
datastax-java-driver {
basic.contact-points = ["10.152.183.5:9042"]
basic.load-balancing-policy.local-datacenter = "datacenter1"
}

my-dynamodb-journal = ${dynamodb-journal}
my-dynamodb-journal { # and add some overrides
journal-table = "tenant_service"
journal-name = "tenant_service"
endpoint = "https://dynamodb.us-east-1.amazonaws.com" # or where your deployment is
}
27 changes: 27 additions & 0 deletions tenant/src/main/resources/application-dynamo-journal.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Important: enable HTTP/2 in ActorSystem's config
akka.http.server.preview.enable-http2 = on

akka.actor.provider = cluster

//FIXME - autocreate only for dev
akka.actor.serialization-bindings{
"com.improving.app.common.serialize.PBMsgSerializable" = proto
}
akka.remote.artery.canonical.port = 0

akka.actor.allow-java-serialization = off
akka.persistence {
snapshot-store.plugin = "my-dynamodb-snapshot-store"
}
datastax-java-driver.advanced.reconnect-on-init = true
datastax-java-driver {
basic.contact-points = ["10.152.183.5:9042"]
basic.load-balancing-policy.local-datacenter = "datacenter1"
}

my-dynamodb-journal = ${dynamodb-journal}
my-dynamodb-journal {
journal-table = "tenant_service"
journal-name = "tenant_service"
endpoint = "https://dynamodb.us-east-1.amazonaws.com"
}