inmemory

package
v0.4.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 23, 2025 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package inmemory provides the business logic for the MCP registry API

Package inmemory provides an in-memory implementation of the RegistryService interface

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EncodeCursor added in v0.3.8

func EncodeCursor(index int) string

EncodeCursor encodes an index position to a base64-encoded cursor string. This can be used by callers to generate cursors for pagination. For example, after fetching a page of N items starting at index X, the next cursor would be EncodeCursor(X + N).

func New

func New(
	ctx context.Context,
	registryProvider RegistryDataProvider,
	opts ...Option,
) (service.RegistryService, error)

New creates a new registry regSvc with the given providers and options. registryProvider is required for registry data access. deploymentProvider can be nil if deployed servers functionality is not needed.

Types

type Option

type Option func(*regSvc)

Option is a functional option for configuring the regSvc

func WithCacheDuration

func WithCacheDuration(duration time.Duration) Option

WithCacheDuration sets a custom cache duration for registry data

func WithConfig added in v0.3.8

func WithConfig(cfg *config.Config) Option

WithConfig sets the config for registry validation

type RegistryDataProvider added in v0.4.4

type RegistryDataProvider interface {
	// GetRegistryData fetches the current registry data.
	// Returns the registry data and any error encountered.
	GetRegistryData(ctx context.Context) (*toolhivetypes.UpstreamRegistry, error)

	// GetSource returns a descriptive string about where the registry data comes from.
	// Examples: "file:/path/to/registry.json", "remote:https://example.com/registry"
	GetSource() string

	// GetRegistryName returns the registry name/identifier for this provider.
	// This name is used for business logic such as finding related Kubernetes resources.
	GetRegistryName() string
}

RegistryDataProvider abstracts the source of registry data. This interface follows the Go principle of small, focused interfaces and enables easy testing and multiple implementations.

func NewFileRegistryDataProvider added in v0.4.4

func NewFileRegistryDataProvider(storageManager sources.StorageManager, cfg *config.Config) RegistryDataProvider

NewFileRegistryDataProvider creates a new file-based registry data provider. It accepts a StorageManager to delegate file operations and a Config for registry metadata. This design eliminates code duplication and improves testability through dependency injection.

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL