Skip to content

Commit

Permalink
feat: changes docs for Nats support
Browse files Browse the repository at this point in the history
  • Loading branch information
ramank775 authored Jul 31, 2022
1 parent c966e5f commit 1282020
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 345 deletions.
18 changes: 14 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
[![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.1-4baaaa.svg)](code_of_conduct.md)
[![Gitpod Ready-to-Code](https://img.shields.io/badge/Gitpod-Ready--to--Code-blue?logo=gitpod)](https://gitpod.io/#https://github.com/ramank775/chat-server)

A chat server based on the microservice architecture to ensure high availability, high throughput, horizontal scalability using Kafka
A chat server based on the microservice architecture to ensure high availability, high throughput, horizontal scalability.

## Architecture
![Architecture](docs/Architecture.png)
Expand All @@ -17,7 +17,7 @@ A chat server based on the microservice architecture to ensure high availability
- Web Socket Gateway: It's handling client websocket connection and sending message to message broker
- Responsibility
- Maintaining Web Socket Connection
- Forwarding event like `onConnect`, `onDisconnect`, `new-message` to message broker (Kafka)
- Forwarding event like `onConnect`, `onDisconnect`, `new-message` to message broker
- Sending message back to client

- Rest Http Gateway: It handle rest call to send messages.
Expand Down Expand Up @@ -157,7 +157,7 @@ Click on the Gitpod badge it will start the fully setup development environment.
### Development environment on local machine

### Prerequisites
- Apache Kafka
- [Apache Kafka](https://kafka.apache.org/) / [Nats](https://nats.io/)
- Mongodb
- Nginx
- Firebase project
Expand All @@ -178,11 +178,21 @@ Click on the Gitpod badge it will start the fully setup development environment.
```
cp .env.tmpl .env
```
- Initialize Kafka
- Initialize Message Broker
```
cd deployment/scripts
```
Setup Kafka
```
./init-kafka.bash ${KAFKA_INSTALLATION_DIRECTORY} .env
```
OR
Setup Nats
```
./init-nats.bash .env
```
- Open project in vscode
- Start the required microservice from `RUN and DEBUG` option
- (Optional) Start nginx using the configuration [deployment/config/nginx.config](./deployment/config/nginx.dev.config)
Expand Down
337 changes: 1 addition & 336 deletions docs/Architecture.drawio

Large diffs are not rendered by default.

Binary file modified docs/Architecture.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion libs/event-store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const EVENT_STORE = [
* @returns {import('commander').Command}
*/
function addOptions(cmd) {
cmd = cmd.option('--event-store <event-source>', 'Which event store to use (Kafka)', 'kafka');
cmd = cmd.option('--event-store <event-source>', 'Which event store to use (kafka, nats)', 'nats');
EVENT_STORE.forEach((store) => {
if (store.initOptions) {
cmd = store.initOptions(cmd);
Expand Down
2 changes: 1 addition & 1 deletion libs/event-store/nats.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class NatsEventStore extends IEventStore {
}

/**
* Get kafka instance
* Get Nats Connection instance
* @param {Object} context
* @return {Promise<nats.NatsConnection>}
*/
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "chat-server",
"version": "2.7.0",
"description": "A chat server based on the microservice architecture to ensure high availability, high throughput, horizontal scalability using Kafka",
"description": "A chat server based on the microservice architecture to ensure high availability, high throughput, horizontal scalability.",
"main": "",
"repository": "https://github.com/ramank775/chat-server.git",
"author": "Raman <[email protected]>",
Expand Down
2 changes: 1 addition & 1 deletion services/connection-gateway/gateway.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function parseOptions(argv) {
cmd
.option(
'--gateway-name <app-name>',
'Used as gateway server idenitifer for the user connected to this server, as well as the kafka topic for send message'
'Used as gateway server idenitifer for the user connected to this server.'
)
.option(
'--user-connection-state-topic <user-connection-state-topic>',
Expand Down
2 changes: 1 addition & 1 deletion services/notification-ms/notification-ms.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function parseOptions(argv) {
'--offline-message-topic <offline-message-topic>',
'Used by producer to produce new message to send the push notification'
);
cmd.option('--new-login-topic <new-login-topic>', 'New login kafka topic');
cmd.option('--new-login-topic <new-login-topic>', 'New login topic');
cmd.option(
'--offline-msg-initial <offline-msg-initial>',
'Initial for saved messages',
Expand Down

0 comments on commit 1282020

Please sign in to comment.