feat: add registry dual-map and engine factory for VectorStore

- Extend RetrieveEngineRegistry with byStoreID map for DB store engines
- Add StoreRegistry interface and EngineFactory function type
- Create engine factory with per-driver SDK client construction
- Load VectorStore records from DB into registry at startup
- Wire Create/Delete to dynamically register/unregister engines
- Add comprehensive unit tests for registry and service
This commit is contained in:
ochan.kwon
2026-04-15 12:44:52 +09:00
committed by lyingbug
parent 4f55994266
commit c5fc05f3d0
7 changed files with 868 additions and 32 deletions
+17
View File
@@ -6,6 +6,23 @@ import (
"github.com/Tencent/WeKnora/internal/types"
)
// StoreRegistry provides VectorStore-based engine registration/lookup.
// Separated from RetrieveEngineRegistry to avoid changing the existing interface
// used by 6 services (17 call sites). Phase 2 may merge into RetrieveEngineRegistry.
type StoreRegistry interface {
// RegisterWithStoreID registers an engine service by VectorStore ID.
// Upsert semantics: existing entry is overwritten silently.
RegisterWithStoreID(storeID string, svc RetrieveEngineService)
// GetByStoreID retrieves an engine service by VectorStore ID.
GetByStoreID(storeID string) (RetrieveEngineService, error)
// UnregisterByStoreID removes an engine service by VectorStore ID (idempotent).
UnregisterByStoreID(storeID string)
}
// EngineFactory creates a RetrieveEngineService from a VectorStore's config.
// Defined as a function type to avoid circular imports between container and service packages.
type EngineFactory func(ctx context.Context, store types.VectorStore) (RetrieveEngineService, error)
// VectorStoreService defines the service interface for vector store management.
// Tenant isolation is enforced by the handler layer (getOwnedStore pattern).
type VectorStoreService interface {