Skip to content

Commit

Permalink
Add customizeEntity hook in Deployer
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonas Chapuis authored and jchapuis committed Jan 31, 2022
1 parent d4526b0 commit 956254f
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions runtime/src/main/scala/endless/runtime/akka/Deployer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,11 @@ trait Deployer {
EventSourcedBehavior[Command, E, Option[S]]
) => Behavior[Command] =
(_: EntityContext[Command], behavior: EventSourcedBehavior[Command, E, Option[S]]) =>
behavior
behavior,
customizeEntity: akka.cluster.sharding.typed.scaladsl.Entity[Command, ShardingEnvelope[
Command
]] => akka.cluster.sharding.typed.scaladsl.Entity[Command, ShardingEnvelope[Command]] =
identity
)(implicit
sharding: ClusterSharding,
actorSystem: ActorSystem[_],
Expand All @@ -128,7 +132,8 @@ trait Deployer {
createEntity,
createRepository,
createEffector,
customizeBehavior
customizeBehavior,
customizeEntity
).apply

final class EventApplierException(error: String) extends RuntimeException(error)
Expand All @@ -145,7 +150,10 @@ trait Deployer {
customizeBehavior: (
EntityContext[Command],
EventSourcedBehavior[Command, E, Option[S]]
) => Behavior[Command]
) => Behavior[Command],
customizeEntity: akka.cluster.sharding.typed.scaladsl.Entity[Command, ShardingEnvelope[
Command
]] => akka.cluster.sharding.typed.scaladsl.Entity[Command, ShardingEnvelope[Command]]
)(implicit
sharding: ClusterSharding,
actorSystem: ActorSystem[_],
Expand Down Expand Up @@ -205,7 +213,7 @@ trait Deployer {
)
}
}
(repository, sharding.init(akkaEntity))
(repository, sharding.init(customizeEntity(akkaEntity)))
}

private def handleEvent(state: Option[S], event: E)(implicit
Expand Down

0 comments on commit 956254f

Please sign in to comment.