Actor follows Isolated mutability. How do we design usecases which need to work on the collective view?
For example, a Bank Account Actor which stores balance as its State. Thread based application would maintain a shared object say list of Bank Accounts, having details such as Account number, Account holder info, Balance, etc. With data readily available in such a list, we can easily develop usecases such as “display all the accounts having certain balance”, “Change minimum account balance for all accounts which meet the criteria …”, etc.
I could think of following approach to develop such usecases in Actor based application;
- Let parent Actor create child actors, one for each bank account. Let parent actor orchestrate by working with the child actors for getting or setting the data and give the final output.
Queries:n
- Lot of interaction is needed in above approach as parent actor need to communicate with all the child actors. What is your opinion?
- What are the relevant design patterns?