Categorygithub.com/renantarouco/ics-message-server
modulepackage
1.0.1-lw
Repository: https://github.com/renantarouco/ics-message-server.git
Documentation: pkg.go.dev

# README

ics-message-server

This repository refers to one of the modules of a chat system: the message server. This service will provide an HTTP and WebSockets API to be used by a browser client and a gRPC for andministration. It also communicates with another service, the name server, that will hold information about the message server nodes state.

Usage

Build

git clone https://github.com/renantarouco/ics-message-server.git
cd ics-message-server
go test -v ./...
go build

Run

After building you can run the executable.

./ics-message-server

If you chose to run go install command than you can head directly to your GOPATH directory and run the executable, or if you have it in your system's PATH then you just have to run ics-message-server.

API

  • HTTP
RoutesMethodsResponseDescription
/auth?nickname=stringPOST201 (Created) - {"token": "string"}Authenticates a new user in the message server.
/wsGETOpens a websocket connection to send commands and receive messages.

Once the websocket connection is opened commands must be sent in order to perform actions within the server. The commands are JSON encoded and must follow the form:

  • Commands

    • SendMessage

      { "type": "message", "args": { "from": "string", "body": "message body" } }
      
    • SetNickname

      { "type": "setnick", "args": { "nickname": "string" } }
      
    • SwitchRoom

      { "type": "switchroom", "args": { "room": "string" } }
      
    • CreateRoom

      { "type": "createroom", "args": { "name": "string" } }
      
    • ListUsers

      { "type": "listusers" }
      
    • ListRooms

      { "type": "listrooms" }
      
    • Exit

      { "type": "exit" }
      
  • gRPC

    TODO

Intergalactic Chat System

This the implementation for a Distributed System class project. The goal is to implement a basic distributed chat system to explore recent technologies in the field.

The whole project aims to use containerization with Docker, orchestration with Kubernetes and service mesh with Istio.

# Packages

No description provided by the author

# Functions

AuthHandler - The authentication handler.
EnableCORS - Necessary headers to allow CORS.
ValidateTokenMiddleware - Checks validity and extracts a token in the Authorization header.
WsHandler - The endpoint to connect via Websockets and start sending and receiving messages.

# Variables

Router - The router instance serving the whole application for HTTP Requests.
Routes - Routes definition to be instantiated by the API.

# Structs

Route - Struct used to define main aspects of an API route.