dwarlixir icon indicating copy to clipboard operation
dwarlixir copied to clipboard

Event system

Open Trevoke opened this issue 7 years ago • 1 comments

Controllers need to be notified of events like something giving birth or something dying or something leaving the loc or something entering the loc

Trevoke avatar Mar 12 '17 18:03 Trevoke

Idea from the MUD Coders Slack - might be slightly overkill, not sure.

You have a few layers in this setup: user input and ticks are event publishers, which broadcast to subscription managers, which select the interested subscribees and send them events, which then match on the specific event details to process them, and possibly publish new events of their own.

Number of messages isn’t the problem, it’s time spent processing them. There are about 3 places where backpressure could accrue.

You’re going to want to use Registry (https://hexdocs.pm/elixir/master/Registry.html) to implement pub/sub and GenStage (https://hexdocs.pm/gen_stage/GenStage.html) to manage the backpressure. This trades off the risk of the system getting overwhelmed and crashing under impossible load, for the still problematic introduction of lag under impossible load. So you probably want to make your tickers aware of backpressure to get EVE-online style time dilation, and set up some sort of throttling on user input event generation to prevent bad actors from clogging your event pipeline.

Trevoke avatar Mar 17 '17 00:03 Trevoke