Skip to content

Commit b0ed92c

Browse files
authored
Merge pull request #7 from SOFTNETWORK-APP/feature/message
Feature/message
2 parents ce3a875 + 2c32abb commit b0ed92c

File tree

11 files changed

+57
-30
lines changed

11 files changed

+57
-30
lines changed

api/build.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,6 @@ organization := "app.softnetwork.notification"
2828
name := "notification-api"
2929

3030
libraryDependencies ++= Seq(
31-
"app.softnetwork.persistence" %% "persistence-jdbc" % Versions.genericPersistence,
31+
"app.softnetwork.persistence" %% "akka-persistence-jdbc" % Versions.genericPersistence,
3232
"app.softnetwork.scheduler" %% "scheduler-api" % Versions.scheduler
3333
)
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package app.softnetwork.notification.api
2+
3+
import akka.actor.typed.ActorSystem
4+
import akka.http.scaladsl.model.{HttpRequest, HttpResponse}
5+
import app.softnetwork.persistence.launch.PersistentEntity
6+
import app.softnetwork.persistence.query.EventProcessorStream
7+
import app.softnetwork.scheduler.api.{SchedulerApi, SchedulerServiceApiHandler}
8+
9+
import scala.concurrent.Future
10+
11+
trait AllNotificationsWithSchedulerApi extends AllNotificationsApi with SchedulerApi {
12+
13+
override def entities: ActorSystem[_] => Seq[PersistentEntity[_, _, _, _]] = sys =>
14+
schedulerEntities(sys) ++ notificationEntities(sys)
15+
16+
override def eventProcessorStreams: ActorSystem[_] => Seq[EventProcessorStream[_]] = sys =>
17+
schedulerEventProcessorStreams(sys) ++
18+
notificationEventProcessorStreams(sys)
19+
20+
override def grpcServices
21+
: ActorSystem[_] => Seq[PartialFunction[HttpRequest, Future[HttpResponse]]] = system =>
22+
notificationServers(system).map(
23+
NotificationServiceApiHandler.partial(_)(system)
24+
) :+ SchedulerServiceApiHandler.partial(schedulerServer(system))(system)
25+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package app.softnetwork.notification.api
2+
3+
import app.softnetwork.persistence.jdbc.query.PostgresSchemaProvider
4+
5+
object AllNotificationsWithSchedulerPostgresLauncher
6+
extends AllNotificationsWithSchedulerApi
7+
with PostgresSchemaProvider

core/build.sbt

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
import app.softnetwork.sbt.build._
2-
31
organization := "app.softnetwork.notification"
42

53
name := "notification-core"
6-
7-
libraryDependencies ++= Seq(
8-
"app.softnetwork.scheduler" %% "scheduler-core" % Versions.scheduler
9-
)

core/src/main/scala/app/softnetwork/notification/launch/NotificationApplication.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import app.softnetwork.api.server.launch.HealthCheckApplication
66
import app.softnetwork.notification.api.NotificationServiceApiHandler
77
import app.softnetwork.notification.model.Notification
88
import app.softnetwork.persistence.query.SchemaProvider
9-
import app.softnetwork.scheduler.api.SchedulerServiceApiHandler
109

1110
import scala.concurrent.Future
1211

@@ -18,5 +17,5 @@ trait NotificationApplication[T <: Notification]
1817
: ActorSystem[_] => Seq[PartialFunction[HttpRequest, Future[HttpResponse]]] = system =>
1918
notificationServers(system).map(
2019
NotificationServiceApiHandler.partial(_)(system)
21-
) :+ SchedulerServiceApiHandler.partial(schedulerServer(system))(system)
20+
)
2221
}

core/src/main/scala/app/softnetwork/notification/launch/NotificationGuardian.scala

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ import app.softnetwork.notification.persistence.query.{
88
Scheduler2NotificationProcessorStream
99
}
1010
import app.softnetwork.notification.persistence.typed.NotificationBehavior
11-
import app.softnetwork.persistence.launch.PersistentEntity
11+
import app.softnetwork.persistence.launch.{PersistenceGuardian, PersistentEntity}
1212
import app.softnetwork.persistence.query.{EventProcessorStream, SchemaProvider}
13-
import app.softnetwork.scheduler.launch.SchedulerGuardian
14-
import app.softnetwork.scheduler.persistence.query.Scheduler2EntityProcessorStream
13+
import com.typesafe.scalalogging.StrictLogging
1514

1615
import scala.language.implicitConversions
1716

18-
trait NotificationGuardian[T <: Notification] extends SchedulerGuardian { _: SchemaProvider =>
17+
trait NotificationGuardian[T <: Notification] extends PersistenceGuardian with StrictLogging {
18+
_: SchemaProvider =>
1919

2020
import app.softnetwork.persistence.launch.PersistenceGuardian._
2121

@@ -27,31 +27,21 @@ trait NotificationGuardian[T <: Notification] extends SchedulerGuardian { _: Sch
2727
/** initialize all entities
2828
*/
2929
override def entities: ActorSystem[_] => Seq[PersistentEntity[_, _, _, _]] = sys =>
30-
schedulerEntities(sys) ++ notificationEntities(sys)
30+
notificationEntities(sys)
3131

3232
def scheduler2NotificationProcessorStream
3333
: ActorSystem[_] => Option[Scheduler2NotificationProcessorStream] = _ => None
3434

35-
override def scheduler2EntityProcessorStreams
36-
: ActorSystem[_] => Seq[Scheduler2EntityProcessorStream[_, _]] = sys =>
37-
scheduler2NotificationProcessorStream(sys) match {
38-
case Some(value) => Seq(value)
39-
case _ => Seq.empty
40-
}
41-
4235
def notificationCommandProcessorStream
4336
: ActorSystem[_] => Option[NotificationCommandProcessorStream] = _ => None
4437

4538
def notificationEventProcessorStreams: ActorSystem[_] => Seq[EventProcessorStream[_]] = sys =>
46-
notificationCommandProcessorStream(sys) match {
47-
case Some(value) => Seq(value)
48-
case _ => Seq.empty
49-
}
39+
Seq(scheduler2NotificationProcessorStream(sys)).flatten ++
40+
Seq(notificationCommandProcessorStream(sys)).flatten
5041

5142
/** initialize all event processor streams
5243
*/
5344
override def eventProcessorStreams: ActorSystem[_] => Seq[EventProcessorStream[_]] = sys =>
54-
schedulerEventProcessorStreams(sys) ++
5545
notificationEventProcessorStreams(sys)
5646

5747
/** initialize all notification servers

core/src/main/scala/app/softnetwork/notification/persistence/typed/NotificationBehavior.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import app.softnetwork.persistence.typed._
1818
import app.softnetwork.notification.message._
1919
import app.softnetwork.notification.model._
2020
import app.softnetwork.notification.spi.NotificationProvider
21-
import app.softnetwork.notification.model._
2221
import app.softnetwork.scheduler.config.SchedulerSettings
2322
import app.softnetwork.notification.model.NotificationStatus._
2423

project/src/main/scala/app/softnetwork/sbt/build/Versions.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ object Versions {
44

55
val genericPersistence = "0.2.5.15"
66

7-
val scheduler = "0.2.0"
7+
val scheduler = "0.2.1"
88

99
val server = "0.2.6.2"
1010

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
package app.softnetwork.notification.api
22

33
import akka.http.scaladsl.testkit.PersistenceScalatestGrpcTest
4+
import app.softnetwork.api.server.scalatest.ServerTestKit
45
import app.softnetwork.notification.launch.NotificationGuardian
56
import app.softnetwork.notification.model.Notification
67
import app.softnetwork.persistence.scalatest.InMemoryPersistenceTestKit
8+
import app.softnetwork.scheduler.launch.SchedulerGuardian
79
import org.scalatest.Suite
810

911
trait NotificationGrpcServer[T <: Notification]
1012
extends PersistenceScalatestGrpcTest
1113
with NotificationGrpcServices[T]
12-
with InMemoryPersistenceTestKit { _: Suite with NotificationGuardian[T] =>
14+
with InMemoryPersistenceTestKit {
15+
_: Suite with NotificationGuardian[T] with SchedulerGuardian with ServerTestKit =>
1316
override lazy val additionalConfig: String = notificationGrpcConfig
1417
}

testkit/src/main/scala/app/softnetwork/notification/api/NotificationGrpcServices.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@ import app.softnetwork.api.server.scalatest.ServerTestKit
66
import app.softnetwork.notification.launch.NotificationGuardian
77
import app.softnetwork.notification.model.Notification
88
import app.softnetwork.scheduler.api.SchedulerGrpcServices
9+
import app.softnetwork.scheduler.launch.SchedulerGuardian
910

1011
import scala.concurrent.Future
1112

1213
trait NotificationGrpcServices[T <: Notification] extends SchedulerGrpcServices {
13-
_: NotificationGuardian[T] with ServerTestKit =>
14+
_: NotificationGuardian[T] with SchedulerGuardian with ServerTestKit =>
1415

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

0 commit comments

Comments
 (0)