How retry33/mini-redis works
mini-redis is a small C++ TCP server, but the sampled entry point installs an echo handler rather than Redis command or storage behavior. Its runtime flow is: start the server with a listening endpoint and handler, poll for events, accept connections, process input through the handler, and queue responses for writing. The graph includes the socket and descriptor abstractions. Several implementation files are indexed but not excerpted, so uncertain lower-level wiring is omitted.
Main entry points: server.cpp Server Loop · main.cpp Echo Entry · connection.cpp Connection Buffers · poller.cpp Event Poller
Components 10
Application
- Echo Entry
src/main.cpp - Handler Contract
src/server/handler.hpp
Event Server
- Server Loop
src/server/server.cpp - Connection Acceptor
src/server/acceptor.cpp - Connection Buffers
src/server/connection.cpp - Event Poller
src/server/poller.cpp
Network Primitives
- Listen Endpoint
src/server/endpoint.cpp - Socket Wrapper
src/server/socket.cpp - Descriptor RAII
src/server/file_descriptor.cpp
Other components
- TCP Client
Connections 11
- Echo Entry → Listen Endpoint: creates
src/main.cpp - Echo Entry → Handler Contract: defines callback
src/main.cpp - Echo Entry → Server Loop: starts
src/main.cpp - TCP Client → Server Loop: exchanges TCP data
- Server Loop → Connection Acceptor: accepts connections
src/server/server.cpp - Server Loop → Event Poller: waits for events
src/server/server.cpp - Server Loop → Connection Buffers: handles socket events
src/server/server.cpp - Server Loop → Handler Contract: invokes callback
src/server/server.cpp - Connection Buffers → Socket Wrapper: reads and writes
src/server/connection.cpp - Event Poller → Descriptor RAII: owns epoll descriptor
- Socket Wrapper → Descriptor RAII: owns descriptor