How shivam-pathak9/carrot works
Carrot is a single-node, in-memory Redis-inspired server. A client sends RESP commands to either the goroutine-per-connection server or the Linux epoll reactor; requests are parsed, dispatched to command handlers, applied to typed storage, and answered in RESP. The README documents string and list operations, TTL expiration, and both networking models. Reactor internals are represented from the sampled excerpts and SOURCE INDEX; some event-loop-to-connection details are not directly shown, so that link is marked unverified.
Main entry points: server/server.go Goroutine server · reactor/server.go Reactor server · connection.go Socket connection cycle · executor.go Command dispatcher
Components 17
Server runtimes
- TCP server binary
cmd/server/main.go - Goroutine server
internal/server/server.go - Reactor binary
cmd/reactor-server/main.go - Reactor server
internal/reactor/server.go - Epoll event loop
internal/reactor/event_loop.go - Socket connection cycle
internal/reactor/connection.go - Epoll poller
internal/reactor/poller.go
Command handling
- Command parser
internal/command/parser.go - Command dispatcher
internal/command/executor.go - String and TTL commands
internal/command - List commands
internal/command/list.go
Protocol and storage
- Buffered client I/O
internal/client/client.go - RESP framing
internal/protocol/resp/decoder.go - In-memory key store
internal/storage/storage.go - List storage
internal/storage/list.go
Configuration and expiry
- Server configuration
internal/config/config.go
Other components
- Redis client
Connections 26
- Redis client → TCP server binary: connects to
README.md - Redis client → Reactor binary: connects to
README.md - TCP server binary → Goroutine server: starts
cmd/server/main.go - TCP server binary → Server configuration: loads
cmd/server/main.go - Goroutine server → Buffered client I/O: wraps connection
internal/server/server.go - Buffered client I/O → RESP framing: decodes and encodes
internal/client/client.go - Goroutine server → Command parser: parses requests
internal/server/server.go - Goroutine server → Command dispatcher: executes commands
internal/server/server.go - Command parser → RESP framing: reads values
internal/command/parser.go - Reactor binary → Reactor server: starts
cmd/reactor-server/main.go - Reactor binary → Server configuration: loads
cmd/reactor-server/main.go - Reactor server → Epoll poller: creates and registers
internal/reactor/server.go - Reactor server → Epoll event loop: runs
internal/reactor/server.go - Epoll event loop → Socket connection cycle: dispatches readiness
- Socket connection cycle → Command parser: parses requests
internal/reactor/connection.go - Socket connection cycle → Command dispatcher: executes commands
internal/reactor/connection.go - Socket connection cycle → RESP framing: decodes and encodes
internal/reactor/connection.go - Command dispatcher → String and TTL commands: dispatches
internal/command/executor.go - Command dispatcher → List commands: dispatches
internal/command/executor.go - String and TTL commands → In-memory key store: reads and writes
internal/command/set.go - List commands → List storage: reads and writes
internal/command/list.go - Goroutine server → In-memory key store: creates and expires
internal/server/server.go - Reactor server → In-memory key store: creates store
internal/reactor/server.go - Epoll event loop → In-memory key store: runs expiry sweep
README.md - Goroutine server → Server configuration: uses limits
internal/server/server.go - Reactor server → Server configuration: uses limits
internal/reactor/server.go