githubcheng2978 commented on issue #689:
URL:
https://github.com/apache/servicecomb-pack/issues/689#issuecomment-757147908
我看了akka-persistence-redis对应的源码,主要是以下:` def asyncWriteMessages(messages:
Seq[AtomicWrite]): Future[Seq[Try[Unit]]] =
Future.sequence(messages.map(asyncWriteBatch))
var redisClient: RedisClient = _
private def asyncWriteBatch(a: AtomicWrite): Future[Try[Unit]] = {
val batchOperations = Future
.sequence(a.payload.map(asyncWriteOperation(redis, _)))
.zip(redis.set(highestSequenceNrKey(a.persistenceId),
a.highestSequenceNr))
.zip(redis.sadd(identifiersKey, a.persistenceId))
.flatMap {
case ((_, _), n) =>
// notify about new persistence identifier if needed
if (n > 0)
redis.publish(identifiersChannel, a.persistenceId).map(_ => ())
else
Future.successful(())
}
batchOperations
.map(Success(_))
.recover {
case ex => Failure(ex)
}
}`
在存储状态机事件,这个地方用到了redis的事务机制的,但是cluster 默认是不支持事务的,但是scala
官方redis库支持了KeyTag,这个机制可以在cluster模式下支持事务
https://index.scala-lang.org/debasishg/scala-redis/redisclient/3.30?target=_2.13
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]