Documentation
¶
Overview ¶
Package serviceregistry provides service registry functionality.
Index ¶
- type ServiceRegistry
- func (r *ServiceRegistry) AddServiceInfo(serviceID string, info *tool.ServiceInfo)
- func (r *ServiceRegistry) GetAllServices() ([]*config.UpstreamServiceConfig, error)
- func (r *ServiceRegistry) GetServiceConfig(serviceID string) (*config.UpstreamServiceConfig, bool)
- func (r *ServiceRegistry) GetServiceInfo(serviceID string) (*tool.ServiceInfo, bool)
- func (r *ServiceRegistry) RegisterService(ctx context.Context, serviceConfig *config.UpstreamServiceConfig) (string, []*config.ToolDefinition, []*config.ResourceDefinition, error)
- func (r *ServiceRegistry) UnregisterService(ctx context.Context, serviceName string) error
- type ServiceRegistryInterface
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ServiceRegistry ¶
type ServiceRegistry struct {
// contains filtered or unexported fields
}
ServiceRegistry is responsible for managing the lifecycle of upstream services. It orchestrates the creation of upstream service instances via a factory and registers their associated tools, prompts, and resources with the respective managers. It also handles the configuration of authentication for each service.
func New ¶
func New(factory factory.Factory, toolManager tool.ManagerInterface, promptManager prompt.ManagerInterface, resourceManager resource.ManagerInterface, authManager *auth.Manager) *ServiceRegistry
New creates a new ServiceRegistry instance, which is responsible for managing the lifecycle of upstream services.
Parameters:
- factory: The factory used to create upstream service instances.
- toolManager: The manager for registering discovered tools.
- promptManager: The manager for registering discovered prompts.
- resourceManager: The manager for registering discovered resources.
- authManager: The manager for registering service-specific authenticators.
Returns a new instance of `ServiceRegistry`.
func (*ServiceRegistry) AddServiceInfo ¶
func (r *ServiceRegistry) AddServiceInfo(serviceID string, info *tool.ServiceInfo)
AddServiceInfo stores metadata about a service, indexed by its ID.
serviceID is the unique identifier for the service. info is the ServiceInfo struct containing the service's metadata.
func (*ServiceRegistry) GetAllServices ¶
func (r *ServiceRegistry) GetAllServices() ([]*config.UpstreamServiceConfig, error)
GetAllServices returns a list of all registered services.
func (*ServiceRegistry) GetServiceConfig ¶
func (r *ServiceRegistry) GetServiceConfig(serviceID string) (*config.UpstreamServiceConfig, bool)
GetServiceConfig returns the configuration for a given service key.
Parameters:
- serviceID: The unique identifier for the service.
Returns the service configuration and a boolean indicating whether the service was found.
func (*ServiceRegistry) GetServiceInfo ¶
func (r *ServiceRegistry) GetServiceInfo(serviceID string) (*tool.ServiceInfo, bool)
GetServiceInfo retrieves the metadata for a service by its ID.
serviceID is the unique identifier for the service. It returns the ServiceInfo and a boolean indicating whether the service was found.
func (*ServiceRegistry) RegisterService ¶
func (r *ServiceRegistry) RegisterService(ctx context.Context, serviceConfig *config.UpstreamServiceConfig) (string, []*config.ToolDefinition, []*config.ResourceDefinition, error)
RegisterService handles the registration of a new upstream service. It uses the factory to create an upstream instance, discovers its capabilities (tools, prompts, resources), and registers them with the appropriate managers. It also sets up any required authenticators for the service.
If a service with the same name is already registered, the registration will fail.
Parameters:
- ctx: The context for the registration process.
- serviceConfig: The configuration for the service to be registered.
Returns the unique service key, a slice of discovered tool definitions, and an error if the registration fails.
func (*ServiceRegistry) UnregisterService ¶
func (r *ServiceRegistry) UnregisterService(ctx context.Context, serviceName string) error
UnregisterService removes a service from the registry.
type ServiceRegistryInterface ¶
type ServiceRegistryInterface interface {
// RegisterService registers a new upstream service based on the provided
// configuration. It returns the generated service key, a list of any tools
// discovered during registration, and an error if the registration fails.
RegisterService(ctx context.Context, serviceConfig *config.UpstreamServiceConfig) (string, []*config.ToolDefinition, []*config.ResourceDefinition, error)
// UnregisterService removes a service from the registry.
UnregisterService(ctx context.Context, serviceName string) error
// GetAllServices returns a list of all registered services.
GetAllServices() ([]*config.UpstreamServiceConfig, error)
// GetServiceInfo retrieves the metadata for a service by its ID.
GetServiceInfo(serviceID string) (*tool.ServiceInfo, bool)
}
ServiceRegistryInterface defines the interface for a service registry. It provides a method for registering new upstream services.