-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample_DDD.exs
More file actions
124 lines (91 loc) · 2.99 KB
/
example_DDD.exs
File metadata and controls
124 lines (91 loc) · 2.99 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# > iex --sname ws2019 -S mix
alias Ws2019.Aggregates.Account
{:ok, _pid} = Ws2019.Aggregates.Account.start_link(42, 5000)
Account.current_value(42)
Process.whereis(:"42")
Process.whereis(:anti_fraud_42)
Process.whereis(Ws2019.Projections.Payments)
Process.whereis(Ws2019.Projections.Recharges)
{:ok, _pid} = Ws2019.Aggregates.Account.start_link(666, 5000)
Account.current_value(666)
Process.whereis(:"666")
Process.whereis(:anti_fraud_666)
Process.whereis(Ws2019.Projections.Payments)
Process.whereis(Ws2019.Projections.Recharges)
Ws2019.Projections.Payments.payments()
Ws2019.Projections.Recharges.recharges()
Account.consume(42, 200)
Account.consume(666, 200)
Account.consume(666, 200)
Account.consume(42, 200)
Account.recharge(42, 100)
Account.recharge(666, 100)
Account.current_value(42)
Account.current_value(666)
Ws2019.Projections.Payments.payments()
Ws2019.Projections.Recharges.recharges()
id = 42
Account.consume(id, 200)
Account.consume(id, 200)
Account.consume(id, 200)
Ws2019.Projections.Payments.payments()
Account.current_value(id)
Account.recharge(id, 100)
Account.recharge(id, 100)
Account.recharge(id, 100)
Ws2019.Projections.Recharges.recharges()
Account.current_value(id)
Process.whereis(:"42")
Process.whereis(:anti_fraud_42)
Account.consume(id, 20_000)
Account.consume(id, 200)
Process.whereis(:"42")
Process.whereis(:anti_fraud_42)
Account.consume(id, 20_000)
Process.whereis(:"42")
Process.whereis(:anti_fraud_42)
# ###
# Show the CODE, also the simulation
# ###
@doc """
- Account
- anti_fraud
- projects
- simulations
"""
# restart Account
alias Ws2019.Aggregates.Account
{:ok, _pid} = Ws2019.Aggregates.Account.start_link(42, 5000)
id = 42
Account.current_value(id)
Account.recharge(id, 100)
Ws2019.Projections.Payments.payments()
Ws2019.Projections.Recharges.recharges()
Ws2019.Projections.Payments.log_event(true)
Ws2019.Simulations.Supervisor.start_consumer(42, {100, 300}, :timer.seconds(3))
Ws2019.Simulations.Supervisor.start_recharger(42, {100, 300}, :timer.seconds(5))
Ws2019.Simulations.Supervisor.how_many_children()
Ws2019.Simulations.Supervisor.how_many_consumer()
Ws2019.Simulations.Supervisor.how_many_recharger()
Ws2019.Projections.Recharges.log_event(true)
Ws2019.Projections.Payments.log_event(false)
Process.list |> length
(1..100) |> Enum.each(fn _ ->
Ws2019.Simulations.Supervisor.start_consumer(42, {100, 300}, :timer.seconds(3))
Ws2019.Simulations.Supervisor.start_recharger(42, {100, 300}, :timer.seconds(5))
end)
Ws2019.Simulations.Supervisor.how_many_children()
Ws2019.Simulations.Supervisor.stop_all_children()
Ws2019.Simulations.Supervisor.how_many_children()
# Connect to a remote node
# > iex --sname gpad --remsh ws2019@tardis --hidden
Logger.configure level: :warn
Logger.configure level: :info
Ws2019.Simulations.Supervisor.how_many_children()
Logger.configure level: :info
Ws2019.Simulations.Supervisor.stop_all_children()
Ws2019.Simulations.Supervisor.how_many_children()
# on ws2019
Ws2019.Simulations.Supervisor.how_many_children()
Node.list
Node.list(:hidden)