Skip to content

Commit

Permalink
chore(docs): remove webhooks docs and add pub/sub docs (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
Extheoisah authored Oct 3, 2024
1 parent 938634c commit fd6646b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 42 deletions.
3 changes: 2 additions & 1 deletion .env.sample
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
DATABASE_URL=postgres://postgres:postgres@localhost:5432/postgres
GIT_SERVICE_URL=http://localhost:8080
RABBITMQ_URL=amqp://guest:guest@localhost:5672
RABBITMQ_QUEUE_NAME=backend_core_queue
RABBITMQ_QUEUE_NAME=backend_core_queue
CONNECTION_URL=127.0.0.1:4925
43 changes: 2 additions & 41 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,48 +90,9 @@ Connected (press CTRL+C to quit)

You can now send and receive messages to and from the server. You can also use Postman to test the websocket server.

### Webhooks
## Pub / Sub

The server also has a webhook server running on [http://localhost:4925/webhook](http://localhost:4925/webhook). This webhook server is used to receive webhook events from the [git-service](https://github.com/extheoisah/hxckr-infra/tree/main/git-service) which is responsible for managing the git repositories and the [test runners](https://github.com/Extheoisah/hxckr-test-runners).

The webhook server currently supports two event types:

- `push`: This event is triggered when a push is made to a repository.
- `test_result`: This event is triggered when a test runner has finished running the tests for an exercise submission.

The webhook server expects the following payload:

- `event_type`: The type of event.
- `payload`: The payload of the event.

For `push` event:

```json
{
"event_type": "push",
"payload": {
"repoUrl": "https://github.com/extheoisah/hxckr-core.git",
"commitHash": "abc123",
"branchUrl": "https://github.com/extheoisah/hxckr-core/tree/feature/add-test-runner"
}
}
```

For `test_result` event:

```json
{
"event_type": "test_result",
"payload": {
"exerciseId": "1",
"testName": "test_name",
"outcome": "pass" | "fail",
"error": "error message",
"message": "test output",
"duration": "10s"
}
}
```
The server has a pub/sub system that is used to receive real time events from the git service and test runners, and send real-time messages to the clients. The pub/sub system is built using the [Rabbimq](https://www.rabbitmq.com/) message broker. The pub/sub system is used to send real-time messages to the clients such as the challenge results, the leaderboard, etc. Only the git service and test runners will publish messages to the queue, while the clients and the server will subscribe to the queue to receive messages.

## Contributing

Expand Down

0 comments on commit fd6646b

Please sign in to comment.