private def readOnlyCommandHandler()

in pekko-sample-persistence-dc-scala/src/main/scala/sample/persistence/res/auction/Auction.scala [53:71]


  private def readOnlyCommandHandler(state: AuctionState, command: Command): Effect[Event, AuctionState] =
    command match {
      case GetHighestBid(replyTo) =>
        replyTo ! state.highestBid.copy(offer = state.highestCounterOffer) // TODO this is not as described
        Effect.none
      case IsClosed(replyTo) =>
        replyTo ! (state.phase == Closed)
        Effect.none
      case Finish =>
        context.log.info("Finish")
        Effect.persist(AuctionFinished(replicationContext.replicaId))
      case Close =>
        context.log.info("Close")
        require(shouldClose(state))
        Effect.persist(WinnerDecided(replicationContext.replicaId, state.highestBid, state.highestCounterOffer))
      case _: OfferBid =>
        // auction finished, no more bids accepted
        Effect.unhandled
    }