Skip to content

Commit

Permalink
Merge pull request #27 from berardino/5-create-new-session-on-404
Browse files Browse the repository at this point in the history
Create a new session on 404 when refreshing (closes #5)
  • Loading branch information
Juan José Vázquez committed Sep 17, 2016
2 parents b3f3258 + 18ae928 commit 0cb7d4c
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,11 @@ final class ConsulCoordination(
val sessionId = stateSession.getOrElse(throw new IllegalStateException("It wasn't possible to get a valid Consul `sessionId` for refreshing"))
val uri = sessionUri.withPath(sessionUri.path / "renew" / sessionId)
send(Put(uri)).flatMap {
case HttpResponse(OK, _, entity, _) => ignore(entity).map(_ => Done)
case HttpResponse(OK, _, entity, _) => ignore(entity).map(_ => Done)
case HttpResponse(NotFound, _, entity, _) => ignore(entity).flatMap { _ =>
logger.warning("Unable to refresh, session {} not found. Creating a new one", sessionId)
createIfNotExist(self, ttl)
}.map(_ => Done)
case HttpResponse(other, _, entity, _) => ignore(entity).map(_ => throw UnexpectedStatusCode(uri, other))
}
}
Expand Down

0 comments on commit 0cb7d4c

Please sign in to comment.