Actor | Sent | Received | Send Rate | Receive Rate | Activity |
---|---|---|---|---|---|
actor1 | 15 | 15 | 10.0 msg/s | 10.0 msg/s | 30 total |
actor2 | 15 | 15 | 10.0 msg/s | 10.0 msg/s | 30 total |
actor0 | 15 | 15 | 10.0 msg/s | 10.0 msg/s | 30 total |
actor3 | 15 | 15 | 10.0 msg/s | 10.0 msg/s | 30 total |
actor4 | 15 | 15 | 10.0 msg/s | 10.0 msg/s | 30 total |
actor5 | 15 | 15 | 10.0 msg/s | 10.0 msg/s | 30 total |
actor6 | 15 | 15 | 10.0 msg/s | 10.0 msg/s | 30 total |
This is the Elixir code that defines the actor simulation model:
# Create a ring of 7 actors passing a token every 100ms
simulation =
ActorSimulation.new()
|> ActorSimulation.add_actor(:actor0,
send_pattern: {:periodic, 100, :token},
targets: [:actor1]
)
|> ActorSimulation.add_actor(:actor1,
on_match: [
{:token, fn state -> {:send, [{:actor2, :token}], state} end}
]
)
|> ActorSimulation.add_actor(:actor2,
on_match: [
{:token, fn state -> {:send, [{:actor3, :token}], state} end}
]
)
|> ActorSimulation.add_actor(:actor3,
on_match: [
{:token, fn state -> {:send, [{:actor4, :token}], state} end}
]
)
|> ActorSimulation.add_actor(:actor4,
on_match: [
{:token, fn state -> {:send, [{:actor5, :token}], state} end}
]
)
|> ActorSimulation.add_actor(:actor5,
on_match: [
{:token, fn state -> {:send, [{:actor6, :token}], state} end}
]
)
|> ActorSimulation.add_actor(:actor6,
on_match: [
{:token, fn state -> {:send, [{:actor0, :token}], state} end}
]
)
|> ActorSimulation.run(duration: 1500)
# Generate the report
html = MermaidReportGenerator.generate_report(simulation,
title: "Token Ring Network",
layout: "LR",
model_source: model_source
)