Skip to content
Merged
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
2 changes: 1 addition & 1 deletion api/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ organization := "app.softnetwork.notification"
name := "notification-api"

libraryDependencies ++= Seq(
"app.softnetwork.persistence" %% "persistence-jdbc" % Versions.genericPersistence,
"app.softnetwork.persistence" %% "akka-persistence-jdbc" % Versions.genericPersistence,
"app.softnetwork.scheduler" %% "scheduler-api" % Versions.scheduler
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package app.softnetwork.notification.api

import akka.actor.typed.ActorSystem
import akka.http.scaladsl.model.{HttpRequest, HttpResponse}
import app.softnetwork.persistence.launch.PersistentEntity
import app.softnetwork.persistence.query.EventProcessorStream
import app.softnetwork.scheduler.api.{SchedulerApi, SchedulerServiceApiHandler}

import scala.concurrent.Future

trait AllNotificationsWithSchedulerApi extends AllNotificationsApi with SchedulerApi {

override def entities: ActorSystem[_] => Seq[PersistentEntity[_, _, _, _]] = sys =>
schedulerEntities(sys) ++ notificationEntities(sys)

override def eventProcessorStreams: ActorSystem[_] => Seq[EventProcessorStream[_]] = sys =>
schedulerEventProcessorStreams(sys) ++
notificationEventProcessorStreams(sys)

override def grpcServices
: ActorSystem[_] => Seq[PartialFunction[HttpRequest, Future[HttpResponse]]] = system =>
notificationServers(system).map(
NotificationServiceApiHandler.partial(_)(system)
) :+ SchedulerServiceApiHandler.partial(schedulerServer(system))(system)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package app.softnetwork.notification.api

import app.softnetwork.persistence.jdbc.query.PostgresSchemaProvider

object AllNotificationsWithSchedulerPostgresLauncher
extends AllNotificationsWithSchedulerApi
with PostgresSchemaProvider
6 changes: 0 additions & 6 deletions core/build.sbt
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
import app.softnetwork.sbt.build._

organization := "app.softnetwork.notification"

name := "notification-core"

libraryDependencies ++= Seq(
"app.softnetwork.scheduler" %% "scheduler-core" % Versions.scheduler
)
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import app.softnetwork.api.server.launch.HealthCheckApplication
import app.softnetwork.notification.api.NotificationServiceApiHandler
import app.softnetwork.notification.model.Notification
import app.softnetwork.persistence.query.SchemaProvider
import app.softnetwork.scheduler.api.SchedulerServiceApiHandler

import scala.concurrent.Future

Expand All @@ -18,5 +17,5 @@ trait NotificationApplication[T <: Notification]
: ActorSystem[_] => Seq[PartialFunction[HttpRequest, Future[HttpResponse]]] = system =>
notificationServers(system).map(
NotificationServiceApiHandler.partial(_)(system)
) :+ SchedulerServiceApiHandler.partial(schedulerServer(system))(system)
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ import app.softnetwork.notification.persistence.query.{
Scheduler2NotificationProcessorStream
}
import app.softnetwork.notification.persistence.typed.NotificationBehavior
import app.softnetwork.persistence.launch.PersistentEntity
import app.softnetwork.persistence.launch.{PersistenceGuardian, PersistentEntity}
import app.softnetwork.persistence.query.{EventProcessorStream, SchemaProvider}
import app.softnetwork.scheduler.launch.SchedulerGuardian
import app.softnetwork.scheduler.persistence.query.Scheduler2EntityProcessorStream
import com.typesafe.scalalogging.StrictLogging

import scala.language.implicitConversions

trait NotificationGuardian[T <: Notification] extends SchedulerGuardian { _: SchemaProvider =>
trait NotificationGuardian[T <: Notification] extends PersistenceGuardian with StrictLogging {
_: SchemaProvider =>

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

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

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

override def scheduler2EntityProcessorStreams
: ActorSystem[_] => Seq[Scheduler2EntityProcessorStream[_, _]] = sys =>
scheduler2NotificationProcessorStream(sys) match {
case Some(value) => Seq(value)
case _ => Seq.empty
}

def notificationCommandProcessorStream
: ActorSystem[_] => Option[NotificationCommandProcessorStream] = _ => None

def notificationEventProcessorStreams: ActorSystem[_] => Seq[EventProcessorStream[_]] = sys =>
notificationCommandProcessorStream(sys) match {
case Some(value) => Seq(value)
case _ => Seq.empty
}
Seq(scheduler2NotificationProcessorStream(sys)).flatten ++
Seq(notificationCommandProcessorStream(sys)).flatten

/** initialize all event processor streams
*/
override def eventProcessorStreams: ActorSystem[_] => Seq[EventProcessorStream[_]] = sys =>
schedulerEventProcessorStreams(sys) ++
notificationEventProcessorStreams(sys)

/** initialize all notification servers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import app.softnetwork.persistence.typed._
import app.softnetwork.notification.message._
import app.softnetwork.notification.model._
import app.softnetwork.notification.spi.NotificationProvider
import app.softnetwork.notification.model._
import app.softnetwork.scheduler.config.SchedulerSettings
import app.softnetwork.notification.model.NotificationStatus._

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ object Versions {

val genericPersistence = "0.2.5.15"

val scheduler = "0.2.0"
val scheduler = "0.2.1"

val server = "0.2.6.2"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
package app.softnetwork.notification.api

import akka.http.scaladsl.testkit.PersistenceScalatestGrpcTest
import app.softnetwork.api.server.scalatest.ServerTestKit
import app.softnetwork.notification.launch.NotificationGuardian
import app.softnetwork.notification.model.Notification
import app.softnetwork.persistence.scalatest.InMemoryPersistenceTestKit
import app.softnetwork.scheduler.launch.SchedulerGuardian
import org.scalatest.Suite

trait NotificationGrpcServer[T <: Notification]
extends PersistenceScalatestGrpcTest
with NotificationGrpcServices[T]
with InMemoryPersistenceTestKit { _: Suite with NotificationGuardian[T] =>
with InMemoryPersistenceTestKit {
_: Suite with NotificationGuardian[T] with SchedulerGuardian with ServerTestKit =>
override lazy val additionalConfig: String = notificationGrpcConfig
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ import app.softnetwork.api.server.scalatest.ServerTestKit
import app.softnetwork.notification.launch.NotificationGuardian
import app.softnetwork.notification.model.Notification
import app.softnetwork.scheduler.api.SchedulerGrpcServices
import app.softnetwork.scheduler.launch.SchedulerGuardian

import scala.concurrent.Future

trait NotificationGrpcServices[T <: Notification] extends SchedulerGrpcServices {
_: NotificationGuardian[T] with ServerTestKit =>
_: NotificationGuardian[T] with SchedulerGuardian with ServerTestKit =>

override def grpcServices
: ActorSystem[_] => Seq[PartialFunction[HttpRequest, Future[HttpResponse]]] = system =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import app.softnetwork.scheduler.scalatest.SchedulerTestKit
import com.typesafe.config.Config
import org.scalatest.Suite
import app.softnetwork.notification.model.{BasicDevice, From, Mail, Platform, Push, SMS}
import app.softnetwork.persistence.launch.PersistentEntity
import app.softnetwork.persistence.query.EventProcessorStream

import java.net.ServerSocket

Expand Down Expand Up @@ -73,4 +75,11 @@ trait NotificationTestKit[T <: Notification]
asystem.eventStream.tell(Subscribe(probe.ref))

lazy val client: NotificationClient = NotificationClient(asystem)

override def entities: ActorSystem[_] => Seq[PersistentEntity[_, _, _, _]] = sys =>
schedulerEntities(sys) ++ notificationEntities(sys)

override def eventProcessorStreams: ActorSystem[_] => Seq[EventProcessorStream[_]] = sys =>
schedulerEventProcessorStreams(sys) ++
notificationEventProcessorStreams(sys)
}