This project demonstrates a client-server application in Go using RabbitMQ for message queuing. The server handles commands sent by clients to manipulate an in-memory ordered map and dump the values to a file if needed.
client/
: Contains client codeserver/
: Contains server codecommon/
: Contains common code shared between client and servercmd/
: Contains the main entry points for the server and clientbuild/
: Contains the binaries for the server and client
- The ordered map data structure provides O(1) complexity for add, delete, and get operations.
- The project is designed to scale by adding more clients and handling commands in parallel on the server.
- The server processes messages from the queue in parallel using goroutines to maximize throughput. Some tuning can be done using the GOMAXPROCS parameter.
- The ordered map is implemented using a combination of a map and a slice to maintain insertion order.
- The client reads commands from standard input and sends them to the server via RabbitMQ.
- The server creates files to store the output of the
getItem
andgetAllItems
commands if needed with theStandardCommandHandler
- The
NopCommandHandler
will only execute the commands without writing files. Useful for benchmarking.
- Docker
- Go 1.19
- RabbitMQ
-
Clone the repository and build the project. This will create binaries for
amd64
andarm64
architectures in thebuild
folder.git clone cd awesome-project make
The following binaries will be created in the
build
folder:client-amd64
,client-arm64
,server-amd64
, andserver-arm64
. Makefile targets are available to build the server and client binaries foramd64
andarm64
architectures. -
Start the RabbitMQ server:
-
Run AwesomeServer:
./build/server-amd64
-
Run AwesomeClient and send some commands to the server:
./build/client-amd64 addItem key1 value1 addItem key2 value2 addItem key3 value3 getItem key1 deleteItem key1 getAllItems
cd server
go test .
go test -bench .