Skip to content

Commit

Permalink
Merge pull request #22 from tribofustack/feat/saga
Browse files Browse the repository at this point in the history
Feat/saga
  • Loading branch information
LucasGomesSantos authored Jul 30, 2024
2 parents ce8373d + 23ad46e commit ee332de
Show file tree
Hide file tree
Showing 11 changed files with 126 additions and 92 deletions.
19 changes: 8 additions & 11 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ volumes:
ms_checkin_db:
ms_checkout_db:
ms_financial_db:
kong_data: {}
# kong_data: {}

services:
rabbitmq:
Expand All @@ -35,14 +35,8 @@ services:
environment:
KONG_DATABASE: "off"
KONG_DECLARATIVE_CONFIG: /tmp/kong-config.yml
KONG_PROXY_ACCESS_LOG: /dev/stdout
KONG_ADMIN_ACCESS_LOG: /dev/stdout
KONG_PROXY_ERROR_LOG: /dev/stderr
KONG_ADMIN_ERROR_LOG: /dev/stderr
KONG_ADMIN_LISTEN: 0.0.0.0:8001, 0.0.0.0:8444 ssl
KONG_LOG_LEVEL: debug
KONG_PLUGINS: bundled
restart: on-failure
restart: always
healthcheck:
test: [ "CMD", "kong", "health" ]
interval: 10s
Expand Down Expand Up @@ -99,9 +93,11 @@ services:
- orderly-net
depends_on:
- ms_checkin_db
- rabbitmq
restart: always
links:
- ms_checkin_db
- rabbitmq
env_file:
- ./ms-checkin/.env.production
healthcheck:
Expand Down Expand Up @@ -134,10 +130,10 @@ services:
- ./ms-checkout:/usr/checkout/api
networks:
- orderly-net
restart: on-failure
depends_on:
- ms_checkout_db
- rabbitmq
restart: on-failure
links:
- ms_checkout_db
- rabbitmq
Expand Down Expand Up @@ -194,14 +190,15 @@ services:
image: mongo
container_name: ms-auth-database
restart: always
ports:
- 27017:27017
environment:
MONGO_INITDB_ROOT_USERNAME: root
MONGO_INITDB_ROOT_PASSWORD: example
MONGO_INITDB_ROOT_PASSWORD: root_password
env_file:
- ./ms-auth/.env.production
networks:
- orderly-net

ms_auth:
build: ./ms-auth
container_name: ms-auth-api
Expand Down
3 changes: 2 additions & 1 deletion infra/kong/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
FROM kong:3.3.1-alpine
FROM kong:3.7.1-ubuntu
# 3.3.1-alpine

EXPOSE 8444
EXPOSE 8443
Expand Down
2 changes: 1 addition & 1 deletion infra/kong/k8s/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ metadata:
namespace: orderly
data:
kong-config.yml: |
_format_version: "1.1"
_format_version: "3.0"
services:
- name: ms_financial
url: http://ms-financial-service:3003
Expand Down
150 changes: 78 additions & 72 deletions infra/kong/kong-config.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,27 @@
_format_version: "1.1"
_format_version: "3.0"
_transform: true

services:
- name: ms_checkin_categories
- name: financial
url: http://ms_financial:3003
routes:
- name: payments_routes
methods: [GET, POST]
paths:
- /payments/order/(?<id>\d+)
- /payments/order/(?<id>\d+)/approve
- /payments/order/(?<id>\d+)/cancel
plugins:
- name: request-transformer
config:
add:
headers:
- "Content-Type: application/json"
strip_path: false
- name: checkin_categories
url: http://ms_checkin:3001/products/category
routes:
- name: get-categories
- name: get_categories_router
methods: [GET]
paths:
- /categories
Expand All @@ -16,10 +33,10 @@ services:
hour: 10
policy: local
strip_path: true
- name: ms_checkin
- name: checkin
url: http://ms_checkin:3001
routes:
- name: customers
- name: customers_routes
methods: [GET, POST]
paths:
- /customers
Expand All @@ -32,7 +49,7 @@ services:
headers:
- "Content-Type: application/json"
strip_path: false
- name: products
- name: products_routes
paths:
- /products
- /products/(?<id>\d+)
Expand All @@ -45,11 +62,10 @@ services:
- "Content-Type: application/json"
methods: [POST, PUT, DELETE, GET]
strip_path: false

- name: ms_checkout
- name: checkout
url: http://ms_checkout:3002
routes:
- name: orders
- name: orders_routes
methods: [GET, POST]
paths:
- /orders
Expand All @@ -65,69 +81,59 @@ services:
- "Content-Type: application/json"
strip_path: false

- name: ms_financial
url: http://ms_financial:3003
routes:
- name: payments
methods: [GET, POST, DELETE]
paths:
- /payments/order/(?<id>\d+)
- /payments/order/(?<id>\d+)/approve
- /payments/order/(?<id>\d+)/cancel
plugins:
- name: request-transformer
config:
add:
headers:
- "Content-Type: application/json"
strip_path: false

- name: ms_auth
url: http://ms_auth:3000
routes:
- name: auth
methods: [POST]
paths:
- /customer/auth
plugins:
- name: rate-limiting
config:
second: 3
minute: 5
hour: 10
policy: local
- name: http-log
config:
http_endpoint: https://webhook.site/ad3a0bcc-25f8-491e-8c18-fae253167580
method: POST
strip_path: false
# - name: ms_auth
# url: http://ms_auth:3000
# routes:
# - name: auth
# methods: [POST]
# paths:
# - /customer/auth
# plugins:
# - name: rate-limiting
# config:
# second: 3
# minute: 5
# hour: 10
# policy: local
# - name: http-log
# config:
# http_endpoint: https://webhook.site/ad3a0bcc-25f8-491e-8c18-fae253167580
# method: POST
# strip_path: false

consumers:
- username: orderly
jwt_secrets:
- algorithm: HS256
secret: this_is_a_super_secret
# consumers:
# - username: orderly
# jwt_secrets:
# - algorithm: HS256
# secret: this_is_a_super_secret

plugins:
- name: jwt
service: ms_financial
enabled: true
config:
key_claim_name: kid
claims_to_verify:
- exp
- name: jwt
service: ms_checkout
enabled: true
config:
key_claim_name: kid
claims_to_verify:
- exp
- name: jwt
service: ms_checkin
enabled: true
config:
key_claim_name: kid
claims_to_verify:
- exp
# plugins:
# - name: jwt
# service: orch_saga
# enabled: true
# config:
# key_claim_name: kid
# claims_to_verify:
# - exp
# - name: jwt
# service: ms_financial
# enabled: true
# config:
# key_claim_name: kid
# claims_to_verify:
# - exp
# - name: jwt
# service: ms_checkout
# enabled: true
# config:
# key_claim_name: kid
# claims_to_verify:
# - exp
# - name: jwt
# service: ms_checkin
# enabled: true
# config:
# key_claim_name: kid
# claims_to_verify:
# - exp

21 changes: 20 additions & 1 deletion infra/nginx/k8s/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,16 @@ data:
}
http {
default_type application/octet-stream;
upstream kong-api-gateway {
server kong-service:8000;
}
upstream rabbitmq {
least_conn;
server broker-service-controlpanel:15672 weight=10 max_fails=3 fail_timeout=30s;
}
upstream financial-api {
server ms-financial-service:3003;
}
server {
listen 80;
Expand All @@ -36,7 +42,20 @@ data:
proxy_set_header X-Forwarded-Proto $scheme;
}
location /api/ {
proxy_pass http://kong-service:8000/;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_hide_header X-Powered-By;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://kong-api-gateway/;
}
location /financial/ {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_hide_header X-Powered-By;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://financial-api/;
}
location /kong/config/ {
proxy_pass http://kong-service:8001/;
Expand Down
13 changes: 12 additions & 1 deletion infra/nginx/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ http {
upstream kong-api-gateway {
server kong:8000;
}
upstream financial-api {
server ms_financial:3003;
}
upstream kong-config {
server kong:8001;
}
Expand Down Expand Up @@ -43,21 +46,29 @@ http {
}

location /api/ {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_hide_header X-Powered-By;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://kong-api-gateway/;
}
location /financial/ {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_hide_header X-Powered-By;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://financial-api/;
}

location /kong/config/ {
proxy_pass http://kong-config/;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_hide_header X-Powered-By;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://kong-config/;
}

error_page 404 /404.html;
Expand Down
2 changes: 1 addition & 1 deletion infra/rabbitmq/Dockerfile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
FROM rabbitmq:3.12.14-management
FROM rabbitmq:3.13.6-management

0 comments on commit ee332de

Please sign in to comment.