Code Monkey home page Code Monkey logo

golang-redis-websocket-chatserver's Introduction

Golang-Redis-WebSocket-ChatServer

Chat service using Redis, Golang and websockets

Design Decisions

  1. The chat service allows users to subscribe to multiple channels.
  2. Redis client opens a TCP connection per subscription which requires opening too many connections from the chat service to Redis if we open a connection for each channel as user subscribers to. To avoid this, whenever the user subscribes to a new channel, I have to cancel the old subscription and subscribe to all user channels at once. (Redis allow subscribe to multiple channels at once)
  3. The chat service registers all connected users in two channels by default “general” and “random” (following slack conventions). The user can subscribe to any arbitrary channel at any time, and only users subscribed to such channels can see the messages.
  4. I used WebSockets to handle the communication between the JavaScript client and the Golang Service.
  5. The javascript client sends messages in JSON to the Websocket API which uses the following structure {"command": <0, 1 or 2>, "channel": "channel name", "content": "content text"} (will know more later)
  6. Users and channels are saved on Redis, so we can horizontally scale the Golang Service without warring about using WebSocket the stateful protocol.
  7. The Service provides a couple of REST APIs to get the active users and the channels a particular user subscribed to. (would help if we will build a GUI on top of the service)

golang-redis-websocket-chatserver's People

Contributors

mhewedy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

golang-redis-websocket-chatserver's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.