Skip to content

Commit 2527a12

Browse files
committed
upgrade server and scheduler dependencies, add notification grp services
1 parent 86e0632 commit 2527a12

File tree

14 files changed

+58
-51
lines changed

14 files changed

+58
-51
lines changed
Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
package app.softnetwork.notification.api
22

33
import akka.actor.typed.ActorSystem
4-
import akka.http.scaladsl.model.{HttpRequest, HttpResponse}
4+
import app.softnetwork.api.server.GrpcService
55
import app.softnetwork.persistence.launch.PersistentEntity
66
import app.softnetwork.persistence.query.EventProcessorStream
77
import app.softnetwork.persistence.schema.SchemaProvider
8-
import app.softnetwork.scheduler.api.{SchedulerApi, SchedulerServiceApiHandler}
9-
10-
import scala.concurrent.Future
8+
import app.softnetwork.scheduler.api.SchedulerApi
119

1210
trait AllNotificationsWithSchedulerApi extends AllNotificationsApi with SchedulerApi {
1311
_: SchemaProvider =>
@@ -19,9 +17,6 @@ trait AllNotificationsWithSchedulerApi extends AllNotificationsApi with Schedule
1917
schedulerEventProcessorStreams(sys) ++
2018
notificationEventProcessorStreams(sys)
2119

22-
override def grpcServices
23-
: ActorSystem[_] => Seq[PartialFunction[HttpRequest, Future[HttpResponse]]] = system =>
24-
notificationServers(system).map(
25-
NotificationServiceApiHandler.partial(_)(system)
26-
) :+ SchedulerServiceApiHandler.partial(schedulerServer(system))(system)
20+
override def grpcServices: ActorSystem[_] => Seq[GrpcService] = system =>
21+
notificationGrpcServices(system) ++ schedulerGrpcServices(system)
2722
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
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.api.server.GrpcService
6+
7+
import scala.concurrent.Future
8+
9+
class NotificationGrpcService(server: NotificationServer) extends GrpcService {
10+
override def grpcService: ActorSystem[_] => PartialFunction[HttpRequest, Future[HttpResponse]] =
11+
system => NotificationServiceApiHandler.partial(server)(system)
12+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package app.softnetwork.notification.api
2+
3+
import akka.actor.typed.ActorSystem
4+
import app.softnetwork.api.server.{GrpcService, GrpcServices}
5+
import app.softnetwork.notification.launch.NotificationGuardian
6+
import app.softnetwork.notification.model.Notification
7+
8+
trait NotificationGrpcServices[T <: Notification] extends GrpcServices {
9+
_: NotificationGuardian[T] =>
10+
override def grpcServices: ActorSystem[_] => Seq[GrpcService] = system =>
11+
notificationGrpcServices(system)
12+
}
Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,11 @@
11
package app.softnetwork.notification.launch
22

3-
import akka.actor.typed.ActorSystem
4-
import akka.http.scaladsl.model.{HttpRequest, HttpResponse}
53
import app.softnetwork.api.server.launch.HealthCheckApplication
6-
import app.softnetwork.notification.api.NotificationServiceApiHandler
4+
import app.softnetwork.notification.api.NotificationGrpcServices
75
import app.softnetwork.notification.model.Notification
86
import app.softnetwork.persistence.schema.SchemaProvider
97

10-
import scala.concurrent.Future
11-
128
trait NotificationApplication[T <: Notification]
139
extends HealthCheckApplication
14-
with NotificationGuardian[T] { _: SchemaProvider =>
15-
override def grpcServices
16-
: ActorSystem[_] => Seq[PartialFunction[HttpRequest, Future[HttpResponse]]] = system =>
17-
notificationServers(system).map(
18-
NotificationServiceApiHandler.partial(_)(system)
19-
)
20-
}
10+
with NotificationGuardian[T]
11+
with NotificationGrpcServices[T] { _: SchemaProvider => }

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
package app.softnetwork.notification.launch
22

33
import akka.actor.typed.ActorSystem
4+
import app.softnetwork.api.server.GrpcService
45
import app.softnetwork.notification.NotificationCoreBuildInfo
5-
import app.softnetwork.notification.api.NotificationServer
6+
import app.softnetwork.notification.api.{NotificationGrpcService, NotificationServer}
67
import app.softnetwork.notification.model.Notification
78
import app.softnetwork.notification.persistence.query.{
89
NotificationCommandProcessorStream,
@@ -50,6 +51,9 @@ trait NotificationGuardian[T <: Notification] extends PersistenceGuardian with S
5051
*/
5152
def notificationServers: ActorSystem[_] => Seq[NotificationServer]
5253

54+
def notificationGrpcServices: ActorSystem[_] => Seq[GrpcService] = sys =>
55+
notificationServers(sys).map(new NotificationGrpcService(_))
56+
5357
override def systemVersion(): String =
5458
sys.env.getOrElse("VERSION", NotificationCoreBuildInfo.version)
5559
}

project/Versions.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
object Versions {
22

3-
val genericPersistence = "0.6.1"
3+
val genericPersistence = "0.6.2"
44

5-
val scheduler = "0.6.2"
5+
val scheduler = "0.6.3"
66

77
val scalatest = "3.2.16"
88
}

testkit/src/main/scala/app/softnetwork/notification/api/NotificationGrpcServer.scala renamed to testkit/src/main/scala/app/softnetwork/notification/api/NotificationGrpcServerTestKit.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ import app.softnetwork.persistence.scalatest.InMemoryPersistenceTestKit
88
import app.softnetwork.scheduler.launch.SchedulerGuardian
99
import org.scalatest.Suite
1010

11-
trait NotificationGrpcServer[T <: Notification]
11+
trait NotificationGrpcServerTestKit[T <: Notification]
1212
extends PersistenceScalatestGrpcTest
13-
with NotificationGrpcServices[T]
13+
with NotificationGrpcServicesTestKit[T]
1414
with InMemoryPersistenceTestKit {
1515
_: Suite with NotificationGuardian[T] with SchedulerGuardian with ServerTestKit =>
1616
override lazy val additionalConfig: String = notificationGrpcConfig

testkit/src/main/scala/app/softnetwork/notification/api/NotificationGrpcServices.scala renamed to testkit/src/main/scala/app/softnetwork/notification/api/NotificationGrpcServicesTestKit.scala

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,19 @@
11
package app.softnetwork.notification.api
22

33
import akka.actor.typed.ActorSystem
4-
import akka.http.scaladsl.model.{HttpRequest, HttpResponse}
4+
import app.softnetwork.api.server.GrpcService
55
import app.softnetwork.api.server.scalatest.ServerTestKit
66
import app.softnetwork.notification.launch.NotificationGuardian
77
import app.softnetwork.notification.model.Notification
8-
import app.softnetwork.scheduler.api.SchedulerGrpcServices
8+
import app.softnetwork.scheduler.api.SchedulerGrpcServicesTestKit
99
import app.softnetwork.scheduler.launch.SchedulerGuardian
1010

11-
import scala.concurrent.Future
12-
13-
trait NotificationGrpcServices[T <: Notification] extends SchedulerGrpcServices {
11+
trait NotificationGrpcServicesTestKit[T <: Notification] extends SchedulerGrpcServicesTestKit {
1412
_: NotificationGuardian[T] with SchedulerGuardian with ServerTestKit =>
1513

16-
override def grpcServices
17-
: ActorSystem[_] => Seq[PartialFunction[HttpRequest, Future[HttpResponse]]] = system =>
14+
override def grpcServices: ActorSystem[_] => Seq[GrpcService] = system =>
1815
notificationGrpcServices(system) ++ schedulerGrpcServices(system)
1916

20-
def notificationGrpcServices
21-
: ActorSystem[_] => Seq[PartialFunction[HttpRequest, Future[HttpResponse]]] = system =>
22-
notificationServers(system).map(
23-
NotificationServiceApiHandler.partial(_)(system)
24-
)
25-
2617
def notificationGrpcConfig: String = schedulerGrpcConfig + s"""
2718
|# Important: enable HTTP/2 in ActorSystem's config
2819
|akka.http.server.preview.enable-http2 = on

testkit/src/main/scala/app/softnetwork/notification/scalatest/AllNotificationsTestKit.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package app.softnetwork.notification.scalatest
33
import akka.actor.typed.ActorSystem
44
import app.softnetwork.notification.api.{
55
AllNotificationsServer,
6-
NotificationGrpcServer,
6+
NotificationGrpcServerTestKit,
77
NotificationServer
88
}
99
import app.softnetwork.notification.config.InternalConfig
@@ -25,7 +25,7 @@ import org.scalatest.Suite
2525
import org.slf4j.{Logger, LoggerFactory}
2626

2727
trait AllNotificationsTestKit
28-
extends NotificationGrpcServer[Notification]
28+
extends NotificationGrpcServerTestKit[Notification]
2929
with NotificationTestKit[Notification]
3030
with ApnsToken { _: Suite =>
3131

testkit/src/main/scala/app/softnetwork/notification/scalatest/ApnsNotificationsTestKit.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package app.softnetwork.notification.scalatest
33
import akka.actor.typed.ActorSystem
44
import app.softnetwork.notification.api.{
55
ApnsNotificationsServer,
6-
NotificationGrpcServer,
6+
NotificationGrpcServerTestKit,
77
NotificationServer
88
}
99
import app.softnetwork.notification.config.InternalConfig
@@ -24,7 +24,7 @@ import app.softnetwork.notification.model.Push
2424
import org.slf4j.{Logger, LoggerFactory}
2525

2626
trait ApnsNotificationsTestKit
27-
extends NotificationGrpcServer[Push]
27+
extends NotificationGrpcServerTestKit[Push]
2828
with NotificationTestKit[Push]
2929
with ApnsToken { _: Suite =>
3030

0 commit comments

Comments
 (0)