Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unnecessary actor system termination in example apps #304

Merged
merged 1 commit into from
Feb 7, 2024
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
33 changes: 13 additions & 20 deletions example/src/main/scala/endless/example/app/akka/AkkaApp.scala
Original file line number Diff line number Diff line change
Expand Up @@ -40,28 +40,21 @@ object AkkaApp extends Bookings with Vehicles with Availabilities {
.flatMap(createAkkaApp(port))

private def actorSystem(executionContext: ExecutionContext): Resource[IO, ActorSystem[Nothing]] =
Resource.make(
IO(
ActorSystem.wrap(
akka.actor.ActorSystem(
name = "example-akka-as",
config = Some(
PersistenceTestKitPlugin.config
.withFallback(PersistenceTestKitDurableStateStorePlugin.config)
.withFallback(ConfigFactory.defaultApplication)
.resolve()
),
defaultExecutionContext = Some(executionContext),
classLoader = None
)
IO(
ActorSystem.wrap(
akka.actor.ActorSystem(
name = "example-akka-as",
config = Some(
PersistenceTestKitPlugin.config
.withFallback(PersistenceTestKitDurableStateStorePlugin.config)
.withFallback(ConfigFactory.defaultApplication)
.resolve()
),
defaultExecutionContext = Some(executionContext),
classLoader = None
)
)
)(system =>
IO.fromFuture(IO.blocking {
system.terminate()
system.whenTerminated
}).void
)
).toResource

// #main
private def createAkkaApp(port: Int)(actorSystem: ActorSystem[Nothing]): Resource[IO, Server] = {
Expand Down
33 changes: 13 additions & 20 deletions example/src/main/scala/endless/example/app/pekko/PekkoApp.scala
Original file line number Diff line number Diff line change
Expand Up @@ -39,28 +39,21 @@ object PekkoApp extends Bookings with Vehicles with Availabilities {
.flatMap(createPekkoApp(port))

private def actorSystem(executionContext: ExecutionContext): Resource[IO, ActorSystem[Nothing]] =
Resource.make(
IO(
ActorSystem.wrap(
org.apache.pekko.actor.ActorSystem(
name = "example-pekko-as",
config = Some(
PersistenceTestKitPlugin.config
.withFallback(PersistenceTestKitDurableStateStorePlugin.config)
.withFallback(ConfigFactory.defaultApplication)
.resolve()
),
defaultExecutionContext = Some(executionContext),
classLoader = None
)
IO(
ActorSystem.wrap(
org.apache.pekko.actor.ActorSystem(
name = "example-pekko-as",
config = Some(
PersistenceTestKitPlugin.config
.withFallback(PersistenceTestKitDurableStateStorePlugin.config)
.withFallback(ConfigFactory.defaultApplication)
.resolve()
),
defaultExecutionContext = Some(executionContext),
classLoader = None
)
)
)(system =>
IO.fromFuture(IO.blocking {
system.terminate()
system.whenTerminated
}).void
)
).toResource

private def createPekkoApp(port: Int)(actorSystem: ActorSystem[Nothing]): Resource[IO, Server] = {
implicit val askTimeout: Timeout = Timeout(10.seconds)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ object PekkoCluster {
"Timed out during cluster shutdown while waiting for actor system to terminate"
)
)
_ <- Logger[F].info("pekko cluster exited and actor system shutdown complete")
_ <- Logger[F].info("Pekko cluster exited and actor system shutdown complete")
} yield ()
(cluster, release)
})
Expand Down
Loading