为什么 PersistentActor 的方法 persist 不是 return Future?
Why method persist of PersistentActor doesn't return a Future?
我有一个理论问题。最近我写了这段代码:
class Account extends PersistentActor {
def receiveCommand = {
case Block(id, amount) => persist(Block(id, amount)){
case Block(id, amount) =>
persist(RevertBlock(id, s"Id ${id} already in processing",
balance + amount))(_.revert())
}
}
...
}
看起来很糟糕。为什么方法 persist
将回调作为第二个参数而不是 return 一个 Future?
在上下文中进行交易。回调中的 sender() 始终有效,但对于期货而言并非如此。
我有一个理论问题。最近我写了这段代码:
class Account extends PersistentActor {
def receiveCommand = {
case Block(id, amount) => persist(Block(id, amount)){
case Block(id, amount) =>
persist(RevertBlock(id, s"Id ${id} already in processing",
balance + amount))(_.revert())
}
}
...
}
看起来很糟糕。为什么方法 persist
将回调作为第二个参数而不是 return 一个 Future?
在上下文中进行交易。回调中的 sender() 始终有效,但对于期货而言并非如此。