Repository navigation
Architecture Overview
This is an overview of the Chaskis architecture.
There are several threads that run during an IRC connection.
This thread's sole job is to read an IRC line from the server, and enqueue the line to the parsing thread's event queue. It will also handle reconnecting if we lose connection.
This is the main event queue thread. Each time a line is read from the server, the line is enqueued to the parsing thread's event queue. The line will then be send through EVERY handler that is registered with Chaskis, one at a time. Handlers will then add events to the writer thread's queue if the line it received a line it was looking for.
The parsing thread is its own synchronization context. This means that if your handler is going to do a "heavy" workload (e.g. writing to a file, doing an HTTP request, accessing a database, etc), it is recommend to use async/await. Calling await on a Task will run the task in a worker thread, and when the worker thread is completed, the code that comes after the await will be enqueued to the parsing thread's event queue.
This thread is an event queue. When the bot needs to write a line to the IRC server, the line is enqueued to the writer thread's event queue. The event queue will then write the line to the server, and then wait for the specified rate limit time before dequeuing another event and sending it out to the server.
Every minute, the watchdog thread sends a PING to the IRC server. If the IRC server does not respond with a PONG within a certain amount of time, the watchdog thread tells the reader thread to disconnect and reconnect.
It is possible to schedule events that happen once or are recurring. When your event is scheduled to run, it gets added to the parsing event queue where it will later execute. Therefore, it is able to use the parsing thread's synchronization context is needed.