Skip to content

Commit

Permalink
Rename Entity suffix to EntityBehavior in example app
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonas Chapuis committed Dec 11, 2023
1 parent f9f41be commit a79872c
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 13 deletions.
4 changes: 2 additions & 2 deletions documentation/src/main/paradox/example.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Implementation of the repository algebra is trivial using `Sharding` instance (i

Implementation of behavior algebra is done using the `Entity` typeclass instance (also injected by `deployRepository`):

@@snip [BookingEntity](/example/src/main/scala/endless/example/logic/BookingEntity.scala) { #definition }
@@snip [BookingEntityBehavior](/example/src/main/scala/endless/example/logic/BookingEntityBehavior.scala) { #definition }

## Event handling

Expand Down Expand Up @@ -67,7 +67,7 @@ We describe the *availability* process as well as entity passivation using `Effe

Unit testing for entity algebra implementation, event handling and effector benefits from to the parametric nature of `F`:

@@snip [BookingEntitySuite](/example/src/test/scala/endless/example/logic/BookingEntitySuite.scala) { #example }
@@snip [BookingEntityBehaviorSuite](/example/src/test/scala/endless/example/logic/BookingEntityBehaviorSuite.scala) { #example }

@@snip [BookingEventApplierSuite](/example/src/test/scala/endless/example/logic/BookingEventApplierSuite.scala) { #example }

Expand Down
4 changes: 2 additions & 2 deletions example/src/main/scala/endless/example/app/akka/AkkaApp.scala
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,12 @@ object AkkaApp extends Bookings with Vehicles with Availabilities {
BookingsAlg
](
RepositoryInterpreter.lift(ShardedBookings(_)),
BehaviorInterpreter.lift(BookingEntity(_)),
BehaviorInterpreter.lift(BookingEntityBehavior(_)),
SideEffectInterpreter.lift((_, _) => new BookingSideEffect())
),
deployDurableRepository[IO, VehicleID, Vehicle, VehicleAlg, VehiclesAlg](
RepositoryInterpreter.lift(ShardedVehicles(_)),
DurableBehaviorInterpreter.lift(VehicleEntity(_)),
DurableBehaviorInterpreter.lift(VehicleEntityBehavior(_)),
(_, _) => VehicleSideEffect()
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,12 @@ object PekkoApp extends Bookings with Vehicles with Availabilities {
BookingsAlg
](
RepositoryInterpreter.lift(ShardedBookings(_)),
BehaviorInterpreter.lift(BookingEntity(_)),
BehaviorInterpreter.lift(BookingEntityBehavior(_)),
SideEffectInterpreter.lift { case (_, _) => new BookingSideEffect() }
),
deployDurableRepository[IO, VehicleID, Vehicle, VehicleAlg, VehiclesAlg](
RepositoryInterpreter.lift(ShardedVehicles(_)),
DurableBehaviorInterpreter.lift(VehicleEntity(_)),
DurableBehaviorInterpreter.lift(VehicleEntityBehavior(_)),
(_, _) => VehicleSideEffect()
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ import org.typelevel.log4cats.Logger
import java.time.Instant

//#definition
final case class BookingEntity[F[_]: Logger: Clock](entity: Entity[F, Booking, BookingEvent])
extends BookingAlg[F] {
final case class BookingEntityBehavior[F[_]: Logger: Clock](
entity: Entity[F, Booking, BookingEvent]
) extends BookingAlg[F] {
import entity.*

def place(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import endless.example.algebra.VehicleAlg
import endless.example.data.{LatLon, Speed, Vehicle}
import org.typelevel.log4cats.Logger

final case class VehicleEntity[F[_]: Logger](entity: DurableEntity[F, Vehicle])
final case class VehicleEntityBehavior[F[_]: Logger](entity: DurableEntity[F, Vehicle])
extends VehicleAlg[F] {
import entity.*

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ import org.scalacheck.effect.PropF.*
import org.typelevel.log4cats.testing.TestingLogger

//#example
class BookingEntitySuite
class BookingEntityBehaviorSuite
extends munit.CatsEffectSuite
with munit.ScalaCheckEffectSuite
with Generators {
implicit private val logger: TestingLogger[IO] = TestingLogger.impl[IO]()
private val bookingAlg = BookingEntity(EntityT.instance[IO, Booking, BookingEvent])
private val bookingAlg = BookingEntityBehavior(EntityT.instance[IO, Booking, BookingEvent])
private implicit val eventApplier: BookingEventApplier = new BookingEventApplier

test("place booking") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import endless.example.data.{LatLon, Speed, Vehicle}
import org.scalacheck.effect.PropF.*
import org.typelevel.log4cats.testing.TestingLogger

class VehicleEntitySuite
class VehicleEntityBehaviorSuite
extends munit.CatsEffectSuite
with munit.ScalaCheckEffectSuite
with Generators {
implicit private val logger: TestingLogger[IO] = TestingLogger.impl[IO]()
private val vehicleAlg = VehicleEntity(DurableEntityT.instance[IO, Vehicle])
private val vehicleAlg = VehicleEntityBehavior(DurableEntityT.instance[IO, Vehicle])

test("set position") {
forAllF { (latLon: LatLon) =>
Expand Down

0 comments on commit a79872c

Please sign in to comment.