↓ Ir para o conteúdo principal

← todas as notas

📎 Webclip

A Simple CEP Processor in Elixir

The post sketches a CEP processor in Elixir built from GenEvent servers, GenServer processes, and a timed window data structure from an earlier post. It simulates stock quotes, routes each tick by symbol, and has workers compute and emit hourly averages.

Reading notes
#

  • CEP is presented as systems that process streams of events.
  • The application simulates real-time stock feed data with random ticks instead of using a live feed.
  • One GenEvent server handles input ticks and another handles output average events.
  • The broker looks up the process registered for a stock symbol and forwards the tick to that worker when it exists.
  • If no worker is registered for a symbol, the broker sends the event to the worker factory.
  • The worker factory starts a new worker process for a tick event and registers it under the symbol.
  • Each worker keeps a timed window, updates it on every tick, and sends the 60 minute average to the output GenEvent server.
  • The source module sends a tick event after each interval period.
  • The sink module prints the symbol, timestamp, and average, and the post says a real sink could store data in a database or file.
  • The application module wires the processes together with two GenEvent servers, the factory, the broker, and three source processes.
  • The post says the setup lets producers and consumers be decoupled and makes it easier to add more tick consumers later.