forked from OrleansContrib/Orleankka
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathShop.fs
More file actions
36 lines (27 loc) · 833 Bytes
/
Shop.fs
File metadata and controls
36 lines (27 loc) · 833 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
module Shop
open Orleankka
open Orleankka.FSharp
open Account
type ShopMessage =
| Sell of Account : ActorRef * Count : int
| CheckIn of Count : int
| Cash
| Stock
type Shop() =
inherit Actor<ShopMessage>()
let price = 10
let mutable cash = 0
let mutable stock = 0
override this.Receive message = task {
match message with
| CheckIn count -> stock <- stock + count
return response()
| Sell (account, count) ->
let amount = count * price
do! account <! Withdraw(amount)
cash <- cash + amount
stock <- stock - count
return response()
| Cash -> return response(cash)
| Stock -> return response(stock)
}