-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Open
Description
Orleans - BankAccount sample should use AtmGrain for transaction coordination
The Orleans BankAccount sample (located at orleans/BankAccount/) includes an AtmGrain implementation but doesn't use it in the client code. Instead, the client directly coordinates transactions using ITransactionClient.RunTransaction().
Issues with this approach:
- Client is responsible for orchestrating business logic
- Confuses learners about when to use orchestrator grains vs client-side coordination
- The
AtmGrainclass exists but is never used, making its purpose unclear
Preferred Modern Approach
var atm = client.GetGrain<IAtmGrain>(0); await atm.Transfer(fromAccount, toAccount, transferAmount);
Benefits:
- Separation of concerns: Business logic stays in grains, not in client code
- Orleans best practices: Demonstrates proper use of orchestrator/coordinator grains
- Simpler client code: One method call instead of explicit transaction management
- Utilizes existing code: Makes use of the already-implemented
AtmGrain
Proposed Changes
Location: orleans/BankAccount/BankClient/Program.cs
- Remove
ITransactionClientdependency - Add
IAtmGrainusage - Replace transaction coordination block with
atm.Transfer()call
Optional: Add a comment explaining the pattern
Issue metadata
- Issue type: sample-update
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels