Skip to content

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Avicii committed Dec 15, 2016
1 parent e674745 commit 3d35fde
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
10 changes: 6 additions & 4 deletions src/main/scala/poc/persistence/read/ReadApp.scala
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import scala.util.{Failure, Success}

object ReadApp extends App {

implicit val timeout = akka.util.Timeout(10 seconds)
implicit val timeout = akka.util.Timeout(15 seconds)

implicit val system = ActorSystem("example")
implicit val materializer = ActorMaterializer()
Expand Down Expand Up @@ -81,9 +81,11 @@ object ReadApp extends App {
val route = get {
path("users" / Segment) {
userId: String => {
onComplete(handlerForUsers ? GetHistoryFor(userId.toLong)) {
case Success(History(namedEvents)) => complete(namedEvents)
case Failure(_) | Success(_) => complete(InternalServerError -> Map("mesage" -> "internal server error"))
onComplete((handlerForUsers ? GetHistoryFor(userId.toLong)).mapTo[History]) {
case Success(history: History) => complete(history)
case Failure(ex) =>
logger.error("failed to get history for user with id {}", ex, userId)
complete(InternalServerError -> Map("mesage" -> "internal server error"))
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/poc/persistence/read/user/UserActor.scala
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class UserActor extends PersistentActor with ActorLogging {
}
}
case GetHistory =>
History ( myEvents.reverse.map {
sender ! History ( myEvents.reverse.map {
case event: UserInitializedOrder => "UserInitializedOrder" -> event
case event: UserCancelledOrder => "UserCancelledOrder" -> event
} )
Expand Down

0 comments on commit 3d35fde

Please sign in to comment.