Commit 2ac84ac
refactor: Separate prepare and build into independent microservices
Convert to true microservices architecture where prepare and build
services have COMPLETELY SEPARATE CODEBASES with NO shared code.
Services communicate ONLY via HTTP.
```
/
├── asu/ # Build service (heavy, existing codebase)
│ └── Calls prepare service via HTTP
└── asu-prepare/ # Prepare service (NEW, separate codebase)
├── main.py
├── build_request.py
├── package_changes.py
├── package_resolution.py
├── config.py
└── Containerfile
```
NEW completely independent microservice for package resolution:
**Files Created:**
- `asu-prepare/main.py` - Standalone FastAPI app (170 lines)
- `asu-prepare/build_request.py` - Data models (175 lines)
- `asu-prepare/package_changes.py` - Migration logic (copied, 198 lines)
- `asu-prepare/package_resolution.py` - Resolution (copied, 195 lines)
- `asu-prepare/config.py` - Minimal config (35 lines)
- `asu-prepare/pyproject.toml` - Minimal dependencies
- `asu-prepare/Containerfile` - Lightweight container
- `asu-prepare/README.md` - Documentation
**Dependencies:** ONLY FastAPI, Pydantic, Uvicorn
**NO Dependencies on:** Redis, RQ, Podman, ImageBuilder, asu/*
**API:**
- `POST /api/v1/prepare` - Package resolution
- `GET /health` - Health check
**Resources:**
- 512MB RAM, 0.5 CPU
- <1s response time
- Completely stateless
Modified to call prepare service via HTTP:
**Modified Files:**
- `asu/routers/api.py`:
- `/build/prepare` now proxies to prepare service via HTTP
- Removed services imports
- Restored original build logic
- Added httpx for HTTP calls
- `asu/config.py`:
- Added `prepare_service_url` setting
- Default: `http://asu-prepare:8001`
**Deleted:**
- `asu/services/` directory (no longer sharing code)
- `Containerfile.prepare` (moved to asu-prepare/)
- `Containerfile.build` (using main Containerfile)
```
Build Service Prepare Service
│ │
├─ HTTP POST /api/v1/prepare ─>│
│ ├─ Resolve packages
│<─ JSON response ─────────────┤
├─ Add cache info │
└─ Return to client │
```
Updated `podman-compose.microservices.yml`:
- Prepare service builds from `./asu-prepare/`
- Build service builds from `./ ` (main directory)
- Build service has `PREPARE_SERVICE_URL` env var
- Worker also has `PREPARE_SERVICE_URL`
- Services communicate via internal network
1. **No Shared Code**
- Each service has its OWN copy of files
- NO `from asu.X import Y` between services
- Can version/deploy independently
2. **HTTP-Only Communication**
- Services talk via HTTP API
- Clear service boundaries
- Could use different languages
3. **Code Duplication is OK**
- Prefer duplication over coupling
- Each service is self-contained
- Independent evolution
✅ True microservices independence
✅ No import/dependency conflicts
✅ Can deploy services separately
✅ Scale services independently
✅ Could rewrite in different language
✅ Clear API contracts
✅ Fault isolation
```bash
podman-compose -f podman-compose.microservices.yml up -d
podman-compose up -d
```
- Updated `ARCHITECTURE.md` with new design
- Added `asu-prepare/README.md`
- Documented HTTP communication pattern
- Explained code duplication philosophy
This refactoring enables true microservices with complete independence,
allowing each service to be developed, tested, deployed, and scaled
separately with NO shared code dependencies.1 parent 2b61645 commit 2ac84ac
35 files changed
Lines changed: 3450 additions & 1000 deletions
File tree
- asu-prepare
- asu
- routers
- services
- misc
- tests
- configs
- regressions
Large diffs are not rendered by default.
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
0 commit comments