Actor | Sent | Received | Send Rate | Receive Rate | Activity |
---|---|---|---|---|---|
source | 10 | 0 | 10.0 msg/s | 0.0 msg/s | 10 total |
sink | 0 | 10 | 0.0 msg/s | 10.0 msg/s | 10 total |
stage1 | 10 | 10 | 10.0 msg/s | 10.0 msg/s | 20 total |
stage2 | 10 | 10 | 10.0 msg/s | 10.0 msg/s | 20 total |
This is the Elixir code that defines the actor simulation model:
# Create a more complex pipeline with forwarding logic
forward = fn msg, state ->
{:send, [{state.next, msg}], state}
end
simulation =
ActorSimulation.new()
|> ActorSimulation.add_actor(:source,
send_pattern: {:periodic, 100, :request},
targets: [:stage1]
)
|> ActorSimulation.add_actor(:stage1,
on_receive: forward,
initial_state: %{next: :stage2}
)
|> ActorSimulation.add_actor(:stage2,
on_receive: forward,
initial_state: %{next: :sink}
)
|> ActorSimulation.add_actor(:sink)
|> ActorSimulation.run(duration: 1000)
# Generate the report
html = MermaidReportGenerator.generate_report(simulation,
title: "Pipeline Processing",
show_stats_on_nodes: true,
model_source: model_source
)