scala - How to share state between Akka actors? -
i have balancesheetactor
defined follows:
class balancesheetactor extends actor { val tradables = mutable.set[contract] }
and have simple depositcontract
defined follows:
case class depositcontract(facevalue: double)
each contract in model asset 1 balancesheetactor
, liability balancesheetactor
, state of contract
shared between actors (i.e., each contract member of @ least 2 sets of tradables
).
suppose want increment facevalue
of depositcontract
amount
. either need to...
- remove old contract both sets of
tradables
, replace newdepositcontract(facevalue + amount)
. - model each
contract
akka.agent
. - model each
contract
akka.actor
(and encapsulating state).
option 1 seems needlessly complicated (additionally contracts highly out of sync), option 2 seems ok need create on order of millions of contract agents , concerned memory usage. have similar concerns option 3 well. have no idea if these memory usage concerns founded. thoughts?
i hoping there option 4 scala/akka noob has not thought of...
Comments
Post a Comment