Skip to content

Commit

Permalink
integrate generic scheduler api
Browse files Browse the repository at this point in the history
  • Loading branch information
fupelaqu committed Dec 18, 2022
1 parent 0d6f477 commit f51891c
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 14 deletions.
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ ThisBuild / organization := "app.softnetwork"

name := "payment"

ThisBuild / version := "0.1.1"
ThisBuild / version := "0.1.2"

ThisBuild / scalaVersion := "2.12.15"

Expand Down
4 changes: 2 additions & 2 deletions common/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ name := "payment-common"

libraryDependencies ++= Seq(
"app.softnetwork.persistence" %% "persistence-kv" % Versions.genericPersistence,
"app.softnetwork.persistence" %% "persistence-scheduler" % Versions.genericPersistence,
"app.softnetwork.persistence" %% "persistence-scheduler" % Versions.genericPersistence % "protobuf",
"app.softnetwork.scheduler" %% "scheduler-common" % Versions.scheduler,
"app.softnetwork.scheduler" %% "scheduler-common" % Versions.scheduler % "protobuf",
"app.softnetwork.api" %% "generic-server-api" % Versions.genericPersistence,
"app.softnetwork.protobuf" %% "scalapb-extensions" % "0.1.5",
"commons-validator" % "commons-validator" % "1.6"
Expand Down
1 change: 1 addition & 0 deletions core/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ organization := "app.softnetwork.payment"
name := "payment-core"

libraryDependencies ++= Seq(
"app.softnetwork.scheduler" %% "scheduler-core" % Versions.scheduler,
"app.softnetwork.persistence" %% "persistence-kv" % Versions.genericPersistence,
"app.softnetwork.persistence" %% "persistence-session" % Versions.genericPersistence
)
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import app.softnetwork.payment.spi._
import app.softnetwork.persistence._
import app.softnetwork.persistence.message.{BroadcastEvent, CrudEvent}
import app.softnetwork.persistence.typed._
import app.softnetwork.scheduler.config.Settings
import app.softnetwork.scheduler.config.SchedulerSettings
import app.softnetwork.serialization.asJson
import app.softnetwork.time.{now => _, _}
import org.slf4j.Logger
Expand Down Expand Up @@ -70,7 +70,7 @@ trait GenericPaymentBehavior
case _: SchedulerEventWithCommand =>
Set(
s"$persistenceId-to-scheduler",
Settings.SchedulerConfig.eventStreams.entityToSchedulerTag
SchedulerSettings.SchedulerConfig.eventStreams.entityToSchedulerTag
)
case _ => Set(persistenceId)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import sbt._
object Publication {

def settings: Seq[Def.Setting[_]] = Seq(
ThisBuild / Keys.publishTo := selectDestination((Keys.version in Keys.publish).value),
ThisBuild / Keys.publishTo := selectDestination((Keys.publish / Keys.version).value),
ThisBuild / Keys.publishMavenStyle := true,
ThisBuild / Keys.credentials += Credentials(Path.userHome / ".ivy2" / ".credentials")
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@ object Versions {

val genericPersistence = "0.2.5.15"

val scheduler = "0.1.2"

val scalatest = "3.1.1"
}
2 changes: 1 addition & 1 deletion testkit/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ organization := "app.softnetwork.payment"
name := "payment-testkit"

libraryDependencies ++= Seq(
"app.softnetwork.persistence" %% "persistence-scheduler-testkit" % Versions.genericPersistence,
"app.softnetwork.scheduler" %% "scheduler-testkit" % Versions.scheduler,
"app.softnetwork.persistence" %% "persistence-session-testkit" % Versions.genericPersistence
)
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package app.softnetwork.payment.api

import akka.http.scaladsl.testkit.PersistenceScalatestGrpcTest
import app.softnetwork.payment.launch.PaymentGuardian
import app.softnetwork.persistence.scalatest.InMemoryPersistenceTestKit
import org.scalatest.Suite

trait PaymentGrpcServer
extends PersistenceScalatestGrpcTest
with PaymentGrpcServices
with InMemoryPersistenceTestKit { _: Suite =>
override lazy val additionalConfig: String = grpcConfig
with InMemoryPersistenceTestKit { _: Suite with PaymentGuardian =>
override lazy val additionalConfig: String = paymentGrpcConfig
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,30 @@ package app.softnetwork.payment.api

import akka.actor.typed.ActorSystem
import akka.http.scaladsl.model.{HttpRequest, HttpResponse}
import app.softnetwork.api.server.GrpcServices
import app.softnetwork.payment.launch.PaymentGuardian
import app.softnetwork.scheduler.api.SchedulerGrpcServices

import scala.concurrent.Future

trait PaymentGrpcServices extends GrpcServices {
trait PaymentGrpcServices extends SchedulerGrpcServices {
_: PaymentGuardian =>

def interface: String

def port: Int

override def grpcServices
: ActorSystem[_] => Seq[PartialFunction[HttpRequest, Future[HttpResponse]]] =
paymentGrpcServices

def paymentGrpcServices
: ActorSystem[_] => Seq[PartialFunction[HttpRequest, Future[HttpResponse]]] =
system =>
Seq(
PaymentServiceApiHandler.partial(MockPaymentServer(system))(system)
)
) ++ schedulerGrpcServices(system)

def grpcConfig: String = s"""
def paymentGrpcConfig: String = schedulerGrpcConfig + s"""
|# Important: enable HTTP/2 in ActorSystem's config
|akka.http.server.preview.enable-http2 = on
|akka.grpc.client."${PaymentClient.name}"{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ trait PaymentRouteTestKit
override def paymentService: ActorSystem[_] => GenericPaymentService = system =>
MockPaymentService(system)

override lazy val additionalConfig: String = grpcConfig
override lazy val additionalConfig: String = paymentGrpcConfig

override def apiRoutes(system: ActorSystem[_]): Route =
paymentService(system).route ~
Expand Down

0 comments on commit f51891c

Please sign in to comment.