|
| 1 | +feat: Add Interceptor + Extension Guides (v0.9.2) |
| 2 | + |
| 3 | +## 🎯 Core Updates |
| 4 | + |
| 5 | +### 1. Interceptor (Infrastructure) |
| 6 | + |
| 7 | +New `interceptor/` package for global SQL build observation: |
| 8 | + |
| 9 | +- **Type-safe boundaries**: `BeforeBuild(meta *Metadata)` compile-time enforced |
| 10 | +- **Global**: Register once, apply to all queries |
| 11 | +- **Use for**: Logging, monitoring (Prometheus), auditing, distributed tracing |
| 12 | +- **NOT for**: Business logic (multi-tenancy, permissions should be explicit) |
| 13 | + |
| 14 | +**Design Highlight**: |
| 15 | +```go |
| 16 | +// ✅ Can only set metadata (compile-time constraint) |
| 17 | +func (i *MyInterceptor) BeforeBuild(meta *interceptor.Metadata) error { |
| 18 | + meta.UserID = 123 // ✅ OK |
| 19 | + meta.Eq("tenant_id", x) // ❌ Compilation Error |
| 20 | + return nil |
| 21 | +} |
| 22 | +``` |
| 23 | + |
| 24 | +**Files**: |
| 25 | +- `interceptor/metadata.go` - Strongly-typed metadata |
| 26 | +- `interceptor/interceptor.go` - Interceptor interface |
| 27 | +- `interceptor/registry.go` - Global registry |
| 28 | +- `interceptor_test.go` - 5 tests (tests as docs) |
| 29 | +- `builder_x.go` - Integrate Meta() and interceptor calls |
| 30 | +- `to_sql.go` - Built passes Meta |
| 31 | + |
| 32 | +--- |
| 33 | + |
| 34 | +### 2. Extension Guides |
| 35 | + |
| 36 | +New extension guides for users: |
| 37 | + |
| 38 | +- `doc/CUSTOM_VECTOR_DB_GUIDE.md` - How to support Milvus, Weaviate, etc. |
| 39 | +- `doc/CUSTOM_JOINS_GUIDE.md` - How to extend custom JOINs (ASOF, LATERAL, etc.) |
| 40 | + |
| 41 | +**Principles**: |
| 42 | +- ✅ Extend in your own package, don't modify sqlxb core |
| 43 | +- ✅ Keep method chaining |
| 44 | +- ✅ Follow sqlxb style |
| 45 | + |
| 46 | +--- |
| 47 | + |
| 48 | +### 3. Documentation Cleanup |
| 49 | + |
| 50 | +Removed 7 outdated design docs: |
| 51 | +- VECTOR_DATABASE_DESIGN.md |
| 52 | +- VECTOR_DIVERSITY_API_DESIGN.md |
| 53 | +- VECTOR_EXECUTIVE_SUMMARY.md |
| 54 | +- VECTOR_IMPLEMENTATION_COMPLETE.md |
| 55 | +- VECTOR_PAIN_POINTS_ANALYSIS.md |
| 56 | +- VECTOR_SUMMARY.md |
| 57 | +- VECTOR_RELEASE_NOTES.md |
| 58 | + |
| 59 | +Updated all API examples to match actual implementation. |
| 60 | + |
| 61 | +--- |
| 62 | + |
| 63 | +## 🎊 Philosophy |
| 64 | + |
| 65 | +### Grassroots Culture |
| 66 | + |
| 67 | +- **Interceptor**: No docs, no examples, tests as documentation |
| 68 | + - Don't use = Zero learning cost |
| 69 | + - Use = Learn from tests |
| 70 | + - Hit limit = Understand design |
| 71 | + |
| 72 | +- **Clear Boundaries**: |
| 73 | + - Interceptor for infrastructure only |
| 74 | + - Business logic must be explicit |
| 75 | + |
| 76 | +--- |
| 77 | + |
| 78 | +## ✅ Tests |
| 79 | + |
| 80 | +- 5 new Interceptor tests, all passing ✅ |
| 81 | +- All existing tests passing ✅ |
| 82 | +- 100% backward compatible ✅ |
| 83 | + |
| 84 | +--- |
| 85 | + |
| 86 | +**Co-authored-by**: AI Assistant (Claude) |
| 87 | +**Philosophy**: Grassroots culture, Explicit over implicit, Simple over complex |
| 88 | + |
0 commit comments