examples/stream/README.md
Example project demonstrating real-time top-K stream processing.
git clone https://github.com/rivet-dev/rivet.git
cd rivet/examples/stream
npm install
npm run dev
This stream processor uses a Top-K algorithm to efficiently maintain the top 3 values using insertion sort. Updates are instantly sent to all connected clients via event broadcasting. The actor maintains persistent state tracking values and statistics, and multiple users can add values simultaneously.
src/backend/registry.ts): Implements the streamProcessor actor with insertion-based Top-K maintenance with O(k) complexity for efficiently maintaining the highest valuesRead more about state management, actions, and events.
MIT