refactor: modular local provider interfaces
Move package-type-specific local repo logic into provider packages via optional interfaces, eliminating switch statements from handlers. - provider.LocalUploader: ValidateUpload + UploadResponse - provider.LocalIndexer: ServeLocalIndex + GenerateLocalIndex - provider.FileStore: interface for querying local files (implemented by database.DB) PyPI and Terraform providers now implement both interfaces. The local handler and v1 proxy use type assertions to dispatch — adding a new local repo type only requires implementing the interfaces in its provider package, no handler changes needed. local.go: 468 → 163 lines (removed all PyPI/Terraform specifics) proxy.go: 211 → 136 lines (removed switch + helper methods) engine.go: removed LocalIndexGenerator, uses provider.LocalIndexer
This commit is contained in:
@@ -63,7 +63,7 @@ func New(cfg *config.Config) (*Server, error) {
|
||||
|
||||
engine := proxy.NewEngine(db, redis, s3)
|
||||
localHandler := v2.NewLocalHandler(db, s3)
|
||||
virtEngine := virtual.NewEngine(db, engine, localHandler)
|
||||
virtEngine := virtual.NewEngine(db, engine)
|
||||
collector := gc.New(db, s3, 1*time.Hour)
|
||||
|
||||
s := &Server{
|
||||
|
||||
Reference in New Issue
Block a user