Skip to content

Commit

Permalink
Bugfix: mismatched states after lagom-pb upgrade (#87)
Browse files Browse the repository at this point in the history
  • Loading branch information
Zen Yui authored Sep 4, 2020
1 parent 4867014 commit 2df2938
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ object Dependencies {
// Package versions
object Versions {
val Scala213 = "2.13.1"
val LagomPbVersion = "0.8.0+2-85bd967e-SNAPSHOT"
val LagomPbVersion = "0.8.1+2-53b385f0-SNAPSHOT"
val AkkaVersion: String = "2.6.8"
val KanelaAgentVersion = "1.0.6"
val SilencerVersion = "1.6.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import com.namely.chiefofstate.config.SendCommandSettings
import scala.concurrent.{ExecutionContext, Future}
import scala.util.{Try, Success, Failure}
import io.superflat.lagompb.GlobalException
import io.superflat.lagompb.protobuf.v1.core.StateWrapper

class GrpcServiceImpl(sys: ActorSystem,
clusterSharding: ClusterSharding,
Expand Down Expand Up @@ -84,11 +85,11 @@ class GrpcServiceImpl(sys: ActorSystem,
.withCommand(in.getCommand)
.withHeaders(propagatedHeaders)

sendCommand[RemoteCommand, Any](clusterSharding, in.entityId, remoteCommand, metaData)
.map((namelyState: StateAndMeta[Any]) => {
sendCommand(clusterSharding, in.entityId, remoteCommand, metaData)
.map((stateWrapper: StateWrapper) => {
ProcessCommandResponse(
state = Some(namelyState.state),
meta = Some(Util.toCosMetaData(namelyState.metaData))
state = stateWrapper.state,
meta = stateWrapper.meta.map(Util.toCosMetaData)
)
})
}
Expand All @@ -108,14 +109,14 @@ class GrpcServiceImpl(sys: ActorSystem,
Failure(new GrpcServiceException(status = Status.INVALID_ARGUMENT.withDescription("empty entity ID")))
)
} else {
sendCommand[GetStateRequest, Any](clusterSharding, in.entityId, in, Map.empty[String, String])
sendCommand(clusterSharding, in.entityId, in, Map.empty[String, String])
.transform({
// transform success to a GetStateResponse
case Success(namelyState) =>
case Success(stateWrapper: StateWrapper) =>
Success(
GetStateResponse(
state = Some(namelyState.state),
meta = Some(Util.toCosMetaData(namelyState.metaData))
state = stateWrapper.state,
meta = stateWrapper.meta.map(Util.toCosMetaData)
)
)

Expand Down

0 comments on commit 2df2938

Please sign in to comment.