Skip to content

Commit

Permalink
Merge pull request #93 from Clariteia/0.0.1
Browse files Browse the repository at this point in the history
0.0.1
  • Loading branch information
Sergio García Prado authored Jul 7, 2021
2 parents e42d197 + 0a9240e commit d90807e
Show file tree
Hide file tree
Showing 102 changed files with 5,091 additions and 1,630 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
on: push

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Start System
run: make up

- name: Run Integration Tests
run: make integration-tests

- name: Stop System
run: make down
57 changes: 57 additions & 0 deletions .github/workflows/microservice-order-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
on:
push:
paths:
- 'microservices/order/**'

jobs:
build:
runs-on: ubuntu-latest
container: python:3.9-buster
services:
postgres:
image: postgres
env:
POSTGRES_DB: order_db
POSTGRES_USER: minos
POSTGRES_PASSWORD: min0s
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5

zookeeper:
image: wurstmeister/zookeeper:latest
ports:
- 2181:2181

kafka:
image: wurstmeister/kafka:latest
ports:
- 9092:9092
env:
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
KAFKA_ADVERTISED_HOST_NAME: kafka
defaults:
run:
working-directory: ./microservices/order

env:
MINOS_EVENTS_QUEUE_HOST: postgres
MINOS_EVENTS_BROKER: kafka
MINOS_COMMANDS_QUEUE_HOST: postgres
MINOS_COMMANDS_BROKER: kafka
MINOS_REPOSITORY_HOST: postgres
MINOS_SNAPSHOT_HOST: postgres
MINOS_SAGA_QUEUE_HOST: postgres

steps:
- name: Check out repository code
uses: actions/checkout@v2

- name: Install Poetry
uses: snok/[email protected]

- name: Install dependencies
run: poetry install

- name: Run tests
run: poetry run pytest
57 changes: 57 additions & 0 deletions .github/workflows/microservice-product-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
on:
push:
paths:
- 'microservices/product/**'

jobs:
build:
runs-on: ubuntu-latest
container: python:3.9-buster
services:
postgres:
image: postgres
env:
POSTGRES_DB: product_db
POSTGRES_USER: minos
POSTGRES_PASSWORD: min0s
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5

zookeeper:
image: wurstmeister/zookeeper:latest
ports:
- 2181:2181

kafka:
image: wurstmeister/kafka:latest
ports:
- 9092:9092
env:
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
KAFKA_ADVERTISED_HOST_NAME: kafka
defaults:
run:
working-directory: ./microservices/product

env:
MINOS_EVENTS_QUEUE_HOST: postgres
MINOS_EVENTS_BROKER: kafka
MINOS_COMMANDS_QUEUE_HOST: postgres
MINOS_COMMANDS_BROKER: kafka
MINOS_REPOSITORY_HOST: postgres
MINOS_SNAPSHOT_HOST: postgres
MINOS_SAGA_QUEUE_HOST: postgres

steps:
- name: Check out repository code
uses: actions/checkout@v2

- name: Install Poetry
uses: snok/[email protected]

- name: Install dependencies
run: poetry install

- name: Run tests
run: poetry run pytest
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ ENV/

# Intellij IDEa / PyCharm / etc.
.idea
.run

# lmdb database
*.mdb
Expand Down
21 changes: 21 additions & 0 deletions .restyled.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
enabled: true
restylers:
- name: black
image: restyled/restyler-black:v19.10b0
command:
- black
arguments: ["--line-length", "120"]
include:
- "**/*.py"
interpreters:
- python
- name: isort
image: restyled/restyler-isort:v5.8.0
command:
- isort
arguments: []
include:
- "**/*.py"
interpreters:
- python
18 changes: 18 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
build:
docker-compose build --parallel

up: build
echo "Starting containers..."
docker-compose up --detach

down:
echo "Stopping containers..."
docker-compose down --remove-orphans

logs:
echo "Showing logs..."
docker-compose logs --follow

integration-tests:
echo "Running Integration Tests..."
docker-compose run tavern
3 changes: 3 additions & 0 deletions api_gateway/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,6 @@ WORKDIR /api_gateway
COPY . .
RUN poetry config virtualenvs.create false \
&& poetry install --no-interaction --no-ansi


CMD ["api_gateway", "start"]
105 changes: 58 additions & 47 deletions api_gateway/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,61 +2,72 @@ rest:
host: 0.0.0.0
port: 5566
endpoints:
- name: GetOrder
route: /order/{id}
method: GET
controller: src.Order
action: get

- name: AddOrder
route: /order
route: /orders
method: POST
controller: src.Order
action: add
- name: History
route: /order/{id}/history
controller: minos.api_gateway.rest.DefaultController
action: default

- name: GetOrders
route: /orders
method: GET
controller: src.Order
action: history
- name: GetProduct
route: /product/{id}
controller: minos.api_gateway.rest.DefaultController
action: default

- name: AddPayment
route: /payments
method: POST
controller: minos.api_gateway.rest.DefaultController
action: default

- name: GetPayments
route: /payments
method: GET
controller: src.Product
action: get
- name: AddOrder
route: /product
controller: minos.api_gateway.rest.DefaultController
action: default

- name: AddProduct
route: /products
method: POST
controller: src.Product
action: add
- name: AllProducts
route: /products/all
controller: minos.api_gateway.rest.DefaultController
action: default

- name: GetProducts
route: /products
method: GET
controller: src.Product
action: all
controller: minos.api_gateway.rest.DefaultController
action: default

- name: DeleteProduct
route: /products/{id}
method: DELETE
controller: minos.api_gateway.rest.DefaultController
action: default

- name: UpdateInventory
route: /products/{product_id}/inventory
method: PUT
controller: minos.api_gateway.rest.DefaultController
action: default

- name: UpdateInventoryDiff
route: /products/{product_id}/inventory
method: PATCH
controller: minos.api_gateway.rest.DefaultController
action: default

- name: GetTickets
route: /tickets
method: GET
controller: minos.api_gateway.rest.DefaultController
action: default

discovery:
host: localhost
port: 55909
path: discover
endpoints:
- name: Discover
route: /discover
method: GET
controller: minos.api_gateway.discovery.handlers.DiscoveryHandlers
action: discover
- name: Subscribe
route: /subscribe
method: POST
controller: minos.api_gateway.discovery.handlers.DiscoveryHandlers
action: subscribe
- name: Unsubscribe
route: /unsubscribe
method: POST
controller: minos.api_gateway.discovery.handlers.DiscoveryHandlers
action: unsubscribe
- name: SystemHealth
route: /system/health
method: GET
controller: minos.api_gateway.discovery.handlers.DiscoveryHandlers
action: system_health
port: 5567
path: /discover
endpoints: []
db:
host: localhost
port: 6379
Expand Down
Loading

0 comments on commit d90807e

Please sign in to comment.