Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 3 additions & 9 deletions internal/app/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ type registryAppConfig struct {
storageManager sources.StorageManager
statusPersistence status.StatusPersistence
syncManager pkgsync.Manager
registryProvider service.RegistryDataProvider
registryProvider inmemory.RegistryDataProvider

// HTTP server options
address string
Expand Down Expand Up @@ -260,7 +260,7 @@ func WithSyncManager(sm pkgsync.Manager) RegistryAppOptions {
}

// WithRegistryProvider allows injecting a custom registry provider (for testing)
func WithRegistryProvider(provider service.RegistryDataProvider) RegistryAppOptions {
func WithRegistryProvider(provider inmemory.RegistryDataProvider) RegistryAppOptions {
return func(cfg *registryAppConfig) error {
cfg.registryProvider = provider
return nil
Expand Down Expand Up @@ -358,13 +358,7 @@ func buildServiceComponents(
case config.StorageTypeFile:
// Build registry provider (reads from synced data via StorageManager)
if b.registryProvider == nil {
// StorageManager was already built in buildSyncComponents
factory := service.NewRegistryProviderFactory(b.storageManager)
provider, err := factory.CreateProvider(b.config)
if err != nil {
return nil, fmt.Errorf("failed to create registry provider: %w", err)
}
b.registryProvider = provider
b.registryProvider = inmemory.NewFileRegistryDataProvider(b.storageManager, b.config)
slog.Info("Created registry data provider using storage manager")
}

Expand Down
24 changes: 13 additions & 11 deletions internal/app/builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ import (
"github.com/stacklok/toolhive-registry-server/internal/config"
"github.com/stacklok/toolhive-registry-server/internal/kubernetes"
"github.com/stacklok/toolhive-registry-server/internal/service"
"github.com/stacklok/toolhive-registry-server/internal/service/mocks"
"github.com/stacklok/toolhive-registry-server/internal/service/inmemory"
"github.com/stacklok/toolhive-registry-server/internal/service/inmemory/mocks"
mocksvc "github.com/stacklok/toolhive-registry-server/internal/service/mocks"
"github.com/stacklok/toolhive-registry-server/internal/sources"
"github.com/stacklok/toolhive-registry-server/internal/status"
pkgsync "github.com/stacklok/toolhive-registry-server/internal/sync"
Expand Down Expand Up @@ -313,7 +315,7 @@ func TestWithRegistryProvider(t *testing.T) {
t.Parallel()
cfg := &registryAppConfig{}
// Use nil registry provider for testing - we're just verifying the field is set
var testRegistryProvider service.RegistryDataProvider
var testRegistryProvider inmemory.RegistryDataProvider

opt := WithRegistryProvider(testRegistryProvider)
err := opt(cfg)
Expand All @@ -329,7 +331,7 @@ func TestBuildHTTPServer(t *testing.T) {
tests := []struct {
name string
config *registryAppConfig
setupMock func(*mocks.MockRegistryService)
setupMock func(*mocksvc.MockRegistryService)
wantAddr string
wantReadTO time.Duration
wantWriteTO time.Duration
Expand All @@ -346,7 +348,7 @@ func TestBuildHTTPServer(t *testing.T) {
writeTimeout: 15 * time.Second,
idleTimeout: 60 * time.Second,
},
setupMock: func(_ *mocks.MockRegistryService) {},
setupMock: func(_ *mocksvc.MockRegistryService) {},
wantAddr: ":8080",
wantReadTO: 10 * time.Second,
wantWriteTO: 15 * time.Second,
Expand All @@ -365,7 +367,7 @@ func TestBuildHTTPServer(t *testing.T) {
writeTimeout: 10 * time.Second,
idleTimeout: 30 * time.Second,
},
setupMock: func(_ *mocks.MockRegistryService) {},
setupMock: func(_ *mocksvc.MockRegistryService) {},
wantAddr: ":9090",
wantReadTO: 5 * time.Second,
wantWriteTO: 10 * time.Second,
Expand All @@ -382,7 +384,7 @@ func TestBuildHTTPServer(t *testing.T) {
writeTimeout: 30 * time.Second,
idleTimeout: 120 * time.Second,
},
setupMock: func(_ *mocks.MockRegistryService) {},
setupMock: func(_ *mocksvc.MockRegistryService) {},
wantAddr: "127.0.0.1:3000",
wantReadTO: 20 * time.Second,
wantWriteTO: 30 * time.Second,
Expand All @@ -397,7 +399,7 @@ func TestBuildHTTPServer(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()

mockSvc := mocks.NewMockRegistryService(ctrl)
mockSvc := mocksvc.NewMockRegistryService(ctrl)
tt.setupMock(mockSvc)

// Set auth middleware in config for tests
Expand Down Expand Up @@ -441,7 +443,7 @@ func TestBuildServiceComponents(t *testing.T) {
*testing.T,
service.RegistryService,
*registryAppConfig,
service.RegistryDataProvider,
inmemory.RegistryDataProvider,
)
}{
{
Expand All @@ -463,7 +465,7 @@ func TestBuildServiceComponents(t *testing.T) {
t *testing.T,
_ service.RegistryService,
config *registryAppConfig,
originalProvider service.RegistryDataProvider,
originalProvider inmemory.RegistryDataProvider,
) {
assert.NotNil(
t,
Expand Down Expand Up @@ -501,7 +503,7 @@ func TestBuildServiceComponents(t *testing.T) {
t *testing.T,
_ service.RegistryService,
config *registryAppConfig,
originalProvider service.RegistryDataProvider,
originalProvider inmemory.RegistryDataProvider,
) {
assert.Equal(
t,
Expand Down Expand Up @@ -534,7 +536,7 @@ func TestBuildServiceComponents(t *testing.T) {
t *testing.T,
_ service.RegistryService,
config *registryAppConfig,
originalProvider service.RegistryDataProvider,
originalProvider inmemory.RegistryDataProvider,
) {
assert.Equal(
t,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Package service provides the business logic for the MCP registry API
package service
// Package inmemory provides the business logic for the MCP registry API
package inmemory

import (
"context"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package service
package inmemory

import (
"context"
Expand Down
4 changes: 2 additions & 2 deletions internal/service/inmemory/impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
// regSvc implements the RegistryService interface
type regSvc struct {
mu sync.RWMutex // Protects registryData, lastFetch
registryProvider service.RegistryDataProvider
registryProvider RegistryDataProvider
config *config.Config // Config for registry validation

// Map of registry name -> registry data
Expand Down Expand Up @@ -58,7 +58,7 @@ func WithConfig(cfg *config.Config) Option {
// deploymentProvider can be nil if deployed servers functionality is not needed.
func New(
ctx context.Context,
registryProvider service.RegistryDataProvider,
registryProvider RegistryDataProvider,
opts ...Option,
) (service.RegistryService, error) {
if registryProvider == nil {
Expand Down
2 changes: 1 addition & 1 deletion internal/service/inmemory/impl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (

"github.com/stacklok/toolhive-registry-server/internal/config"
"github.com/stacklok/toolhive-registry-server/internal/service"
"github.com/stacklok/toolhive-registry-server/internal/service/mocks"
"github.com/stacklok/toolhive-registry-server/internal/service/inmemory/mocks"
)

func TestValidateManagedRegistry(t *testing.T) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// Package service provides the business logic for the MCP registry API
package service
package inmemory

import (
"context"
Expand Down
2 changes: 1 addition & 1 deletion internal/service/inmemory/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
"github.com/stacklok/toolhive-registry-server/internal/registry"
"github.com/stacklok/toolhive-registry-server/internal/service"
"github.com/stacklok/toolhive-registry-server/internal/service/inmemory"
"github.com/stacklok/toolhive-registry-server/internal/service/mocks"
"github.com/stacklok/toolhive-registry-server/internal/service/inmemory/mocks"
)

// testManagedConfig creates a config with a managed registry for testing write operations
Expand Down
57 changes: 0 additions & 57 deletions internal/service/mocks/mock_provider_factory.go

This file was deleted.

53 changes: 0 additions & 53 deletions internal/service/provider_factory.go

This file was deleted.

Loading
Loading