rough framework
[lemu] / README.md
1 # LEMU
2
3 This is a (work-in-progress) text-based multi-user server engine, utilizing lua, libevent, and a concurrent work queue.
4 The intent is for client interaction to be primarily driven by lua scripting, with the server code itself only handling the heavy-lifting of IO, DB, et cetera.
5
6 Nota bene: this is currently a toy implementation, as an architecture for the lua-side has yet to be fleshed out, and is being developed by feel, trial, and error.
7
8 ## Overview
9
10 The main thread runs the event loop, which primarily accepts new connections and feeds their line-based inputs into the thread pool for processing. Connection hostname resolution and signal handling are also in the main thread.
11
12 Each connection has its own queue of input. When a new line of input is added to a connection's queue and there were no other lines already queued, a new job is added to the workqueue to process that connection's input.
13
14 The main unresolved issue here is consistent server state-keeping between each worker-thread's lua processor. The current stopgap solution is that each worker is totally independent and any global changes to the lua state will be queued as a task to update the common state. The imagined ideal is a lock-enable native lua environment/table which would be shared by all workers.
15
16 ## File Tour
17
18 bsd_queue.h - BSD's sys/queue.h, included here because Linux's version is dreadful
19 command.c - processes user input
20 common.c - utility functions
21 connections.c - manage and interact with active clients
22 db.c - persistent data storage
23 lua_interface.c - lua bindings to server and connections
24 main.c - cli
25 notify.c - logging abstraction
26 server.c - event loop, network stuff, glues everything together
27 workqueue.c - concurrent task runner
28