Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create a new session on 404 when refreshing (closes #5) #27

Merged
merged 1 commit into from
Sep 17, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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