Skip to content

Commit f8b9aba

Browse files
release: v0.1.0 (#5)
* feat: Update submissions status in the database (#4) * feat: Connect to postgres and rabbitmq * feat: Implement submissions repository * feat: Listen for messages in the SSU queue and update entry in database * docs: Add Readme and contributing guidelines
1 parent a880879 commit f8b9aba

22 files changed

+467
-5
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Temp files
2+
tmp/
3+
4+
# Editor files
5+
.vscode/

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# 0.1.0 (2024-01-06)
2+
3+
4+
### Features
5+
6+
* Update submissions status in the database ([#4](https://github.com/upb-code-labs/submissions-status-updater-microservice/issues/4)) ([fa0df88](https://github.com/upb-code-labs/submissions-status-updater-microservice/commit/fa0df883043022d38787e1640989b0d24d8b967e))
7+
8+
9+

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Submissions Status Updater micro-service
2+
3+
Welcome to the Submissions Status Updater micro-service. This service is responsible for listening for messages in the `submission-status-updates` queue and updating the status of the submissions in the database and publishing the updated submissions to the `real-time-updates` queue.
4+
5+
Below is a diagram of the overall architecture of the system with the Submissions Status Updater micro-service highlighted in green.
6+
7+
![Submissions Status Updater microservice highlighted with a green rectangle in the overall architecture diagram](./docs/images/submissions-status-updater-microservice-highlighted.png)
8+
9+
## Documentation
10+
11+
Please, refer to the following documents for more information about the tests micro-service:
12+
13+
| Document | Description |
14+
| -------------------------------------- | --------------------------------------------------------------------------- |
15+
| [Contributing](./docs/contributing.md) | Contributing guidelines. |
16+
| [Environment](./docs/environment.md) | A description of the environment variables used by the tests micro-service. |

docs/contributing.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# General organization contribution guidelines
2+
3+
Please, read the [General Contribution Guidelines](https://github.com/upb-code-labs/docs/blob/main/CONTRIBUTING.md) before contributing.
4+
5+
# Submissions Status Updater micro-service contribution guidelines
6+
7+
## Project structure / architecture
8+
9+
The Submissions Status Updater micro-service's architecture is based on the Hexagonal Architecture in order to make it easier to maintain and extend.
10+
11+
The project structure is as follows:
12+
13+
- `domain`: Contains the business logic of the Submissions Status Updater micro-service.
14+
15+
- `definitions`: Contains the interfaces (contracts) of the Submissions Status Updater micro-service.
16+
- `entities`: Contains the entities of the Submissions Status Updater micro-service.
17+
- `dtos`: Contains the data transfer objects of the Submissions Status Updater micro-service.
18+
19+
- `application`: Contains the application logic (use cases) of the Submissions Status Updater micro-service.
20+
21+
- `infrastructure`: Contains the implementation of the Submissions Status Updater micro-service's interfaces (contracts) and the external dependencies of the Submissions Status Updater micro-service.
22+
23+
- `implementations`: Contains the implementations of the `domain` interfaces (contracts).
24+
25+
- `shared`: Contains the shared code of the Submissions Status Updater micro-service.
26+
27+
- `utils`: Contains the utility functions of the Submissions Status Updater micro-service.
28+
29+
## Local development
30+
31+
### Dependencies
32+
33+
The following dependencies are required to run the Submissions Status Updater micro-service locally:
34+
35+
- [Go 1.21.5](https://golang.org/doc/install)
36+
- [Podman](https://podman.io/getting-started/installation) (To build and test the container image)
37+
38+
Please, note that `Podman` is a drop-in replacement for `Docker`, so you can use `Docker` instead if you prefer.
39+
40+
Additionally, you may want to install the following dependencies to make your life easier:
41+
42+
- [Air](https://github.com/cosmtrek/air) (for live reloading)
43+
44+
### Running the Submissions Status Updater micro-service locally
45+
46+
As the role of the Submissions Status Updater micro-service is to listen for messages in the `submission-status-updates` queue and update the status of the submissions in the database and publish the updated submissions to the `real-time-updates` queue, you will need to run the [gateway](https://github.com/UPB-Code-Labs/main-api) project first in order to initialize the queue, database, RabbitMQ and the other micro-services and then you can send submissions by using the REST API.
47+
48+
After you have the gateway running, you can start the Submissions Status Updater micro-service by running the following command:
49+
50+
```bash
51+
air
52+
```
53+
54+
This will start the Submissions Status Updater micro-service and will watch for changes in the source code and restart the service automatically.

docs/environment.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Environment
2+
3+
This document describes the required environment variables to run the micro-service.
4+
5+
| Name | Description | Example | Mandatory |
6+
| ----------------------------- | ----------------------------------------------- | ------------------------------------------------------------------- | --------- |
7+
| `RABBIT_MQ_CONNECTION_STRING` | The connection string to the RabbitMQ instance. | `amqp://username:password@address:port/` | Yes |
8+
| `DB_CONNECTION_STRING` | The connection string to the postgres database | `postgres://username:password@domain:port/database?sslmode=disable` | Yes |
114 KB
Loading

go.mod

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ module github.com/upb-code-labs/submissions-status-updater-microservice
33
go 1.21.5
44

55
require (
6-
github.com/lib/pq v1.10.9 // indirect
7-
github.com/rabbitmq/amqp091-go v1.9.0 // indirect
6+
github.com/kelseyhightower/envconfig v1.4.0
7+
github.com/lib/pq v1.10.9
8+
github.com/rabbitmq/amqp091-go v1.9.0
89
)

go.sum

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
22
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
3+
github.com/kelseyhightower/envconfig v1.4.0 h1:Im6hONhd3pLkfDFsbRgu68RDNkGF1r3dvMUtDTo2cv8=
4+
github.com/kelseyhightower/envconfig v1.4.0/go.mod h1:cccZRl6mQpaq41TPp5QxidR+Sa3axMbJDNb//FQX6Gg=
35
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
46
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
57
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
@@ -12,6 +14,7 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+
1214
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
1315
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
1416
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
17+
go.uber.org/goleak v1.2.1 h1:NBol2c7O1ZokfZ0LEU9K6Whx/KnwvepVetCUhtKja4A=
1518
go.uber.org/goleak v1.2.1/go.mod h1:qlT2yGI9QafXHhZZLxlSuNsMw3FFLxBr+tBRlmO1xH4=
1619
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
1720
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=

main.go

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,24 @@
11
package main
22

3-
import "fmt"
3+
import (
4+
"github.com/upb-code-labs/submissions-status-updater-microservice/src/config"
5+
"github.com/upb-code-labs/submissions-status-updater-microservice/src/config/connections"
6+
"github.com/upb-code-labs/submissions-status-updater-microservice/src/infrastructure"
7+
)
48

59
func main() {
6-
fmt.Println("Implement me!")
10+
// Parse environment variables
11+
config.GetEnvironment()
12+
13+
// Connect to database
14+
connections.GetPostgresConnection()
15+
defer connections.ClosePostgresConnection()
16+
17+
// Connect to RabbitMQ
18+
connections.GetRabbitMQChannel()
19+
defer connections.CloseRabbitMQConnection()
20+
21+
// Listen for submission status updates
22+
submissionStatusUpdatesQueueMgr := infrastructure.GetSubmissionStatusUpdatesQueueMgr()
23+
submissionStatusUpdatesQueueMgr.ListenForSubmissionStatusUpdates()
724
}

src/application/.gitkeep

Whitespace-only changes.

0 commit comments

Comments
 (0)