From 30453c1fb75f4690aa58b8759f80047f07714c52 Mon Sep 17 00:00:00 2001 From: Daniel Sockwell Date: Sun, 28 Apr 2019 17:44:59 -0400 Subject: [PATCH] Update README with notes on code architecture --- README.md | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 9967f01..d7d834c 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,15 @@ # RageQuit A blazingly fast drop-in replacement for the Mastodon streaming api server -## Usage -```shell -$ ragequit --port 4002 # Default port is 3666 -``` \ No newline at end of file +## Notes on data flow + +The current structure of the app is as follows: + +Client Request --> Warp + Warp filters for valid requests and parses request data. Based on that data, it repeatedly polls the StreamManager + +Warp --> StreamManager + The StreamManager consults a hash table to see if there is a currently open PubSub channel. If there is, it uses that channel; if not, it creates a new channel using the methods in `pubsub.rs`. Either way, it ends up with a Receiver to poll. The StreamManager polls the Receiver, providing info about which StreamManager it is that is doing the polling. The stream manager is also responsible for monitoring the hash table to see if it contains any Receivers that no longer have active clients; if it does, the StreamManager removes them from the hash table (which causes them to be dropped from memory and causes the PubSub connection to be closed). + +StreamManger --> Receiver + The Receiver receives data from Redis and stores it in a series of queues (one for each StreamManager). When polled by the StreamManager, it sends back the messages relevant to that StreamManager and removes them from the queue.