This is the Elixir code that defines the actor simulation model:
simulation =
ActorSimulation.new(trace: true)
|> ActorSimulation.add_actor(:requester,
send_pattern: {:periodic, 100, {:call, :get_data}},
targets: [:responder]
)
|> ActorSimulation.add_actor(:notifier,
send_pattern: {:periodic, 150, {:cast, :notify}},
targets: [:listener]
)
|> ActorSimulation.add_actor(:responder,
on_match: [
{:get_data, fn state -> {:reply, {:data, 42}, state} end}
]
)
|> ActorSimulation.add_actor(:listener)
|> ActorSimulation.run(duration: 300)