Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add POI Monitor Service: Real-time POI Discrepancy Notification System #108

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: POI Monitor Tests

on:
push:
paths:
- 'services/poi_monitor/**'
branches: [ main ]
pull_request:
paths:
- 'services/poi_monitor/**'
branches: [ main ]

jobs:
poi-monitor-test:
runs-on: ubuntu-latest

services:
postgres:
image: postgres
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: password
POSTGRES_DB: graphix
ports:
- 5433:5433
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5

steps:
- uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.12'

- name: Install dependencies
run: |
cd services/poi_monitor
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -r requirements-dev.txt

- name: Run tests
run: |
cd services/poi_monitor
pip install -e .
pytest tests/ --cov=src --cov-report=term-missing
env:
POSTGRES_HOST: localhost
POSTGRES_PORT: 5433
POSTGRES_USER: postgres
POSTGRES_PASSWORD: password
POSTGRES_DB: graphix

- name: Upload coverage report
uses: codecov/codecov-action@v3
with:
file: ./services/poi_monitor/coverage.xml
66 changes: 60 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,65 @@
rustc-ice*
# Python
__pycache__/
*.py[cod]
*$py.class
*.so
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
venv/
.venv/
ENV/

### IDEs
.vscode/settings.json
# IDEs
.idea/
.vscode/
*.swp
*.swo

# Environment variables
.env
compose\.env

# Coverage
.coverage
coverage.xml
htmlcov/

# Logs
*.log

# Database
*.sqlite3

### OS
# Rust
/target/

# OS specific
.DS_Store
Thumbs.db

# Debug files
rustc-ice*

# Docker and Compose
compose/grafana/data/
compose/data/
compose/prometheus/data/
*.db

### Rust
/target
# Environment variables
compose/*.env
1 change: 0 additions & 1 deletion compose/.env

This file was deleted.

8 changes: 8 additions & 0 deletions compose/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
GRAPHIX_DB_URL=postgresql://postgres:password@localhost:5433/graphix
POSTGRES_DB=graphix
POSTGRES_USER=postgres
POSTGRES_PASSWORD=password
POSTGRES_PORT=5433
CHECK_INTERVAL=300
GRAPHIX_API_URL=http://host.docker.internal:8000/graphql
SLACK_WEBHOOK_URL=your_webhook_url_here
40 changes: 40 additions & 0 deletions compose/dev.dependencies.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
version: "3"

services:
postgres:
image: postgres
restart: unless-stopped
ports:
- "${POSTGRES_PORT:-5433}:${POSTGRES_PORT:-5433}"
environment:
POSTGRES_USER: ${POSTGRES_USER:-postgres}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-password}
POSTGRES_DB: ${POSTGRES_DB:-graphix}
PGDATA: "/var/lib/postgresql/data"
command: -p ${POSTGRES_PORT:-5433}
healthcheck:
test: ["CMD-SHELL", "pg_isready -h localhost -p ${POSTGRES_PORT:-5433} -U ${POSTGRES_USER:-postgres}"]
interval: 1s
timeout: 1s
retries: 1000
volumes:
- ./data/postgres:/var/lib/postgresql/data

poi-monitor:
build:
context: ../services/poi_monitor
dockerfile: Dockerfile
environment:
- POSTGRES_DB=${POSTGRES_DB:-graphix}
- POSTGRES_USER=${POSTGRES_USER:-postgres}
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-password}
- POSTGRES_HOST=postgres
- POSTGRES_PORT=${POSTGRES_PORT:-5433}
- GRAPHIX_API_URL=${GRAPHIX_API_URL:-http://host.docker.internal:8000/graphql}
- SLACK_WEBHOOK_URL=${SLACK_WEBHOOK_URL}
- CHECK_INTERVAL=${CHECK_INTERVAL:-300}
depends_on:
postgres:
condition: service_healthy
extra_hosts:
- "host.docker.internal:host-gateway"
19 changes: 19 additions & 0 deletions services/poi_monitor/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM python:3.12-slim

WORKDIR /app

# Install dependencies
COPY requirements.txt .
COPY requirements-dev.txt .
RUN pip install --no-cache-dir -r requirements.txt
RUN if [ "${ENVIRONMENT}" = "development" ]; then pip install --no-cache-dir -r requirements-dev.txt; fi

# Copy application code
COPY src/ src/
COPY migrations/ migrations/

# Set environment variables
ENV PYTHONUNBUFFERED=1

# Run the monitor
CMD ["python", "-m", "src.monitor"]
Loading
Loading