Skip to content

Commit

Permalink
Merge pull request #3 from belajarqywok/development
Browse files Browse the repository at this point in the history
Update: Database pooling and CI/CD pipeline
  • Loading branch information
belajarqywok authored Nov 13, 2023
2 parents aae6118 + a3098fe commit 96b0920
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 10 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/development.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ jobs:
name: Performance and Load Testing
runs-on: ubuntu-latest
environment: testing
needs: unit_testing

steps:
- name: Checkout
Expand Down Expand Up @@ -109,7 +108,6 @@ jobs:
name: Vulnerability Scanning
runs-on: ubuntu-latest
environment: testing
needs: performance_and_load_testing

steps:
- name: Checkout
Expand Down
17 changes: 10 additions & 7 deletions .github/workflows/production.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
needs: testing

env:
version: '1.0'
version: latest
service: ml-service
region: asia-southeast2
project_id: ${{ secrets.GOOGLE_PROJECT }}
Expand Down Expand Up @@ -110,25 +110,25 @@ jobs:
id: deploy-cloud-run
with:
service: ml-service
image: gcr.io/${{ secrets.GOOGLE_PROJECT }}/ml-service:1.0
image: gcr.io/${{ secrets.GOOGLE_PROJECT }}/ml-service:latest
region: asia-southeast2
flags: |
--cpu=4
--port=80
--cpu-boost
--memory=4Gi
--timeout=800
--concurrency=80
--concurrency=80
--min-instances=0
--max-instances=13
--project=${{ secrets.GOOGLE_PROJECT }}
--allow-unauthenticated
--vpc-egress=private-ranges-only
--vpc-connector=projects/${{ secrets.GOOGLE_PROJECT }}/locations/asia-southeast2/connectors/ml-service-connector
--vpc-connector=projects/${{ secrets.GOOGLE_PROJECT }}/locations/asia-southeast2/connectors/ml-service-connector
--service-account=${{ secrets.CLOUD_RUN_SA }}
env_vars: |
VERSION=$version
VERSION=v1
JWT_ACCESS_TOKEN_SECRET=${{ secrets.JWT_ACCESS_TOKEN_SECRET }}
JWT_REFRESH_TOKEN_SECRET=${{ secrets.JWT_REFRESH_TOKEN_SECRET }}
JWT_ALGORITHM=${{ secrets.JWT_ALGORITHM }}
Expand All @@ -140,5 +140,8 @@ jobs:
POSTGRES_PASS=${{ secrets.POSTGRES_PASS }}
POSTGRES_DB=${{ secrets.POSTGRES_DB }}
- name: 'Cloud Run URL Output'
run: 'echo "${{ steps.deploy-cloud-run.outputs.url }}"'
- name: Cloud Run URL Output
run: echo "${{ steps.deploy-cloud-run.outputs.url }}"

- name: Send Discord Notification
run: echo "send notification"
10 changes: 9 additions & 1 deletion src/configurations/databases/postgresql.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ class Engines:
def __init__(self) -> None:
# IP Engine
self.ip_engine: Engine = create_engine(
pool_size = 10,
pool_timeout = 5,
max_overflow = 10,
pool_recycle = 3600,
url = (
f'postgresql+psycopg2://' +
f'{os.getenv("POSTGRES_USER")}:{os.getenv("POSTGRES_PASS")}' +
Expand All @@ -22,7 +26,11 @@ def __init__(self) -> None:

# UNIX Socket Engine
self.unix_sock_engine: Engine = create_engine(
engine.url.URL.create(
pool_size = 10,
pool_timeout = 5,
max_overflow = 10,
pool_recycle = 3600,
url = engine.url.URL.create(
drivername = 'postgresql+psycopg2',
username = f'{os.getenv("POSTGRES_USER")}',
password = f'{os.getenv("POSTGRES_PASS")}',
Expand Down
Binary file modified src/services/ml_services/__pycache__/nlp_service.cpython-39.pyc
Binary file not shown.
Binary file modified src/utilities/__pycache__/nlp_utils.cpython-39.pyc
Binary file not shown.

0 comments on commit 96b0920

Please sign in to comment.