This service transform websocket messages to pub/sub communication via RMQ.
Our gateway - Margay like a small wild cat, consume minimum resources but provide flexible and scalable solution.
- Run RMQ bitnami image used in example:
docker compose up -d - Setup transport dsn via env
MARGAY_TRANSPORT_DSN - Run application
go run main.go - Login to RMQ dashboard via
http://127.0.0.1:15672/- user:
user - password:
bitnami
- user:
First request mast have Autorization header with JWT that represent user id
Example:
Autorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwidXNlciI6IkpvaG4gU25vdyIsImlhdCI6MTUxNjIzOTAyMn0.UrZ7NLiOUVVUerPuKouyr7NQz8XNb3jMrS_m0_07o8A
Token Decoded:
- Header:
{
"alg": "HS256",
"typ": "JWT"
} {
"aud": "localhost",
"exp": "1.675816912e+09",
"iat": "1.675730512e+09",
"iss": "IdentityServiceLocal",
"jti": "Jhohn Snow",
"sub": "client"
}Limitation: for now only one connection allowed for 1 user.
Auth module is under definition. But main concept is to perform auth request to the Identity Provider and get cleintId from the token
In RMQ transport represented as topic exchange by default name is MargayGatewayOutbox
On Client Connected
- Exchange:
MargayGatewayOutbox - Routing Key: ``
- Properties
- headers:
recipient:*sender:MargayGateway
- Payload
{ "meta":{ "object_id":"TestClient", "object_type":"client", "publisher":"MargayGateway", "event":"connected", "created":"2023-02-06T20:51:49+02:00" }, "data":{ } } - headers:
On Client Disconnected
- Exchange:
MargayGatewayOutbox - Routing Key: ``
- Properties
- headers:
recipient:*sender:MargayGateway
- Payload
{ "meta":{ "object_id":"TestClient", "object_type":"client", "publisher":"MargayGateway", "event":"disconnected", "created":"2023-02-06T20:51:49+02:00" }, "data":{ } } - headers:
In RMQ transport represented as direct exchange by default name is MargayGatewayInbox
Require that message headers to be set like:
- headers:
recipient:ClientIdsender:MyAwesomeMss
- Payload:
- Accept serialized aka
json,yamland plain text messages.
- Accept serialized aka

