Msg is gRPC-based backend for messaging written in golang.

  • By Artyom Artamonov
  • Last update: Jun 8, 2022
  • Comments: 3

Msg

ci

Msg is gRPC-based backend for messaging written in golang.

Goals

Future goals:

  • Implement message service which will allow users to send messages to chat rooms
  • Unit tests and github workflow

Already achieved:

  • Authentication and authorization with JWT and refresh tokens
  • PostgreSQL as persistance storage
  • gRPC and protobuf service creation with help of Makefile and well-prepared code organization

Compiling proto messages

Run

$ make proto-c

For that to work you need to install

$ go install google.golang.org/protobuf/cmd/[email protected]
$ go install google.golang.org/grpc/cmd/[email protected]

Env variables

Create .env file and put it in a project root

.env file has to contain

API_HOST=":50051"
MESSAGE_HOST=":50052"

JWT_SECRET="s3cr3t"
JWT_DURATION_MIN=15
REFRESH_DURATION_DAYS=90


POSTGRES_DB="dbname"
POSTGRES_USER="dbuser"
POSTGRES_PASSWORD="dbuserpassword"

PGADMIN_DEFAULT_EMAIL="[email protected]"
PGADMIN_DEFAULT_PASSWORD="password"
PGADMIN_CONFIG_SERVER_MODE="False"

RABBITMQ_DEFAULT_USER="user"
RABBITMQ_DEFAULT_PASS="password"

Run

$ docker-compose up -d

Download

msg.zip

Comments(3)

  • 1

    Unable to test requests via Postman-like software

    Hi, there's a problem with BloomRPC, Insomnia and other Postman-like software with grpc support

    Main problem is that such soft doesn't know how to resolve external imports, as a result of which it swears at the lack of models from the model.proto file

    Error message:

    Error while importing protos
    no such Type or Enum 'model.Message' in Type .message.MessageDelivery
    
  • 2

    [Question] Fate of this project

    Hi, thanks for such a cool example, it really helps to learn a lot

    I see that the maintainer responds to issues fairly quickly

    Unfortunately, there have been no commits to the project for three months and I am interested in the fate of this project - is it frozen or completely abandoned?

    I really hope that the development hasn't been abandoned, cuz it really cool project

    Thank you for your reply!

  • 3

    [Question] Expired JWT on active GetMessages stream

    Hi, what we should do if our message.MessageService.GetMessage stream returned 16 UNAUTHENTICATED: JWT is expired

    I mean, if we need reconnect to stream every ${JWT_DURATION_MIN} minutes, then that means that we will lose one message every 15 minutes when our stream will signal us that our token has expired? And we will send auth.AuthService.Refresh request, and then reconnect to stream?

    Doesn't this's overhead solution? I mean, i can't understand this algorithm well, cuz that means we will have a lot of requests to our server

    Will be glad to hear your opinion to that question.