- The following commands are supported
CONNECT
PING
SUB
PUB
UNSUB
- First clone the project
https://github.com/melsonic/gNats-Server.git && cd gNats-Server
- Run the project
make
- If you have Docker installed, you can also run it as a Docker container.
docker compose up
- After the Application is up and running, it's time to test the application
- Run
telnet localhost 4222
to connect a client to the server
- Run
conn.Read()
returnsio.EOF
when client signals graceful end of input i.e no more reading. Not closing the connection onio.EOF
will result into infinite loop(infinite zero byte reading from the pipe)INFO{}
should sendpayload
, else by default it sends 0 & results inmaximum payload exceeded error
.zero allocation byte parser
parsing method- It can be used to optimize storage. Normally, storage is required to store
the parsed tokens. But in this method the parser changes
state
and based on current state and next byte, it takes relevant actions.
- It can be used to optimize storage. Normally, storage is required to store
the parsed tokens. But in this method the parser changes
nats bench
sendsCONNECT {"verbose":false,...}
, so the application needs to parse this verbose arg in order to determine weather to send+OK
response or not. If the application sends+OK
withnats bench
, it will result into the following errorExpected PONG, got +OK
.- While dockerizing the application, I faced an error
$GOPATH/go.mod exist but should not
, which was due to the fact that ingolang
image, the default workdir($HOME/go
) is same as$GO_PATH($HOME/go)
. So, it is required to change theWORKDIR
in the first place while building the image.
- Write Tests
- Support string subjectId (currently supports only integer subject id)
- Optimize Unsub Handler (change
[]chan string
tomap[chan]
insubSubscribers map[int][]chan string
for easier removal)