Actor | Sent | Received | Send Rate | Receive Rate | Activity |
---|---|---|---|---|---|
receiver | 0 | 10 | 0.0 msg/s | 10.0 msg/s | 10 total |
sender | 10 | 0 | 10.0 msg/s | 0.0 msg/s | 10 total |
This is the Elixir code that defines the actor simulation model:
simulation =
ActorSimulation.new()
|> ActorSimulation.add_actor(:sender,
send_pattern: {:periodic, 100, :msg},
targets: [:receiver]
)
|> ActorSimulation.add_actor(:receiver)
|> ActorSimulation.run(
max_duration: 10_000,
terminate_when: fn sim ->
stats = ActorSimulation.collect_current_stats(sim)
sender_stats = Map.get(stats.actors, :sender)
sender_stats && sender_stats.sent_count >= 10
end
)