ngcp-project / progress-board-tracker

Empty repository only meant for tracking cards inside project boards in NGCP
0 stars 0 forks source link

feat(rabbitmq): GCS-side RabbitMQ integration #40

Open marked01one opened 8 months ago

marked01one commented 8 months ago

Issue Goal

The goal is to integrate a .NET RabbitMQ connection into the backend database server by database-api to allow it to receive, process, and send RabbitMQ messages to the vehicle-side library. This means working inside the database-api codebase and implement

Getting Stared

Create a separate branch of the database-api codebase on Github and try running it. To overcome the issue of Redis database causing potential errors, run this docker-compose.yml before starting the backend:

services:

  redis:
    image: redis:latest
    ports:
      - 6379:6379
    command: ["redis-server", "--appendonly", "yes"]
    volumes:
      - redis-data:/data

  redis-commander:
    image: rediscommander/redis-commander:latest
    environment:
      - REDIS_HOSTS=local:redis:6379
      - HTTP_USER=root
      - HTTP_PASSWORD=secret
    ports:
      - 8081:8081
    depends_on:
      - redis

volumes:
  redis-data:

How It Should Works

1. Telemetry

On GCS-side, telemetry is transmitted to the frontend via WebSocket. The way WebSocket works is that the frontend client will call an HTTP endpoint to access a WebSocket connection. Once a connection is accepted by the backend server, messages can then be sent to and from the backend freely. You will have access to SendAsync and ReceiveAsync methods to listen for and send messages.

For the purpose of integration, we want the WebSocket endpoint to act like an event handler: Once the frontend client established connection with the backend, it will continually listen for messages. If the designated vehicle sends a RabbitMQ message, the message will trigger an event handler and relay that message to the frontend by sending it with WebSocket.

You will need to heavily modify the sample WebSocket endpoint in the to fit this goal. If you have any questions, please let me know!

2. Commands

On GCS-side, commands are handled via RESTful HTTP endpoints, that act like functions that can be requested remotely via HTTP. For the purpose of integration, we want this to endpoint to publish a RabbitMQ message whenever it's requested. The content is of this RabbitMQ message is whatever the body of the HTTP request is.

Since these HTTP endpoints are not quite written in the database-api codebase yet, you might want to write some of your own endpoints just to test out your implementation. Good luck!

Also a quick reminder of how the Vehicle-to-GCS integration model looks like. Image