Database implementation cleanup (#335)
## Motivation and Context The database logic was getting a bit unwieldy and fragile - especially because business logic that should really have lived at the registry service level was being pushed into the persistence level. This PR tightens the interface, simplifies the code there, as well as rips out a bunch of mocks etc. we don't need. ## How Has This Been Tested? Locally everything works ## Breaking Changes The list endpoint was surprisingly always filtering for isLatest only, which seems like a bug? I have removed this filter.
This commit is contained in:
parent
07d353ba92
commit
9d9a02c57f
1 changed files with 669 additions and 1280 deletions
|
|
@ -14,9 +14,9 @@ import (
|
|||
"github.com/modelcontextprotocol/registry/internal/api"
|
||||
"github.com/modelcontextprotocol/registry/internal/config"
|
||||
"github.com/modelcontextprotocol/registry/internal/database"
|
||||
"github.com/modelcontextprotocol/registry/internal/importer"
|
||||
"github.com/modelcontextprotocol/registry/internal/service"
|
||||
"github.com/modelcontextprotocol/registry/internal/telemetry"
|
||||
apiv0 "github.com/modelcontextprotocol/registry/pkg/api/v0"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
|
@ -46,7 +46,7 @@ func main() {
|
|||
// Initialize services based on environment
|
||||
switch cfg.DatabaseType {
|
||||
case config.DatabaseTypeMemory:
|
||||
db = database.NewMemoryDB(map[string]*apiv0.ServerJSON{})
|
||||
db = database.NewMemoryDB()
|
||||
registryService = service.NewRegistryServiceWithDB(db)
|
||||
case config.DatabaseTypePostgreSQL:
|
||||
// Use PostgreSQL for real registry service
|
||||
|
|
@ -84,7 +84,8 @@ func main() {
|
|||
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)
|
||||
defer cancel()
|
||||
|
||||
if err := db.ImportSeed(ctx, cfg.SeedFrom); err != nil {
|
||||
importerService := importer.NewService(db)
|
||||
if err := importerService.ImportFromPath(ctx, cfg.SeedFrom); err != nil {
|
||||
log.Printf("Failed to import seed data: %v", err)
|
||||
} else {
|
||||
log.Println("Data import completed successfully")
|
||||
|
|
|
|||
Loading…
Reference in a new issue