Documentation
¶
Overview ¶
Package orchestrator manages the lifecycle of services registered in the shared service registry. It starts and stops services, retries failed MCPServer connections with bounded concurrency, and publishes service state-change events to subscribers.
Service implementations live in subpackages of internal/services. The orchestrator drives them through the services.Service interface and the services.ServiceRegistry; it has no service-specific logic of its own.
Index ¶
- Constants
- type Adapter
- func (a *Adapter) ExecuteTool(ctx context.Context, toolName string, args map[string]interface{}) (*api.CallToolResult, error)
- func (a *Adapter) GetAllServices() []api.ServiceStatus
- func (a *Adapter) GetServiceStatus(name string) (*api.ServiceStatus, error)
- func (a *Adapter) GetTools() []api.ToolMetadata
- func (a *Adapter) Register()
- func (a *Adapter) RestartService(name string) error
- func (a *Adapter) StartService(name string) error
- func (a *Adapter) StopService(name string) error
- func (a *Adapter) SubscribeToStateChanges() <-chan api.ServiceStateChangedEvent
- type Config
- type Orchestrator
- func (o *Orchestrator) GetAllServices() []ServiceStatus
- func (o *Orchestrator) GetServiceRegistry() services.ServiceRegistry
- func (o *Orchestrator) GetServiceStatus(name string) (*ServiceStatus, error)
- func (o *Orchestrator) RestartService(name string) error
- func (o *Orchestrator) Start(ctx context.Context) error
- func (o *Orchestrator) StartService(name string) error
- func (o *Orchestrator) Stop() error
- func (o *Orchestrator) StopService(name string) error
- func (o *Orchestrator) SubscribeToStateChanges() <-chan ServiceStateChangedEvent
- type ServiceStateChangedEvent
- type ServiceStatus
- type StopReason
Constants ¶
const MaxConcurrentRetries = 5
MaxConcurrentRetries limits the number of MCPServers that can be retried simultaneously. This prevents a "thundering herd" scenario where many failed servers retry at once, potentially overwhelming the system or upstream services.
const RetryInterval = 30 * time.Second
RetryInterval is the interval at which the orchestrator checks for failed servers to retry.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Adapter ¶
type Adapter struct {
// contains filtered or unexported fields
}
Adapter adapts the orchestrator to implement api.ServiceManagerHandler.
func NewAPIAdapter ¶
func NewAPIAdapter(orchestrator *Orchestrator) *Adapter
NewAPIAdapter creates a new orchestrator adapter.
func (*Adapter) ExecuteTool ¶
func (a *Adapter) ExecuteTool(ctx context.Context, toolName string, args map[string]interface{}) (*api.CallToolResult, error)
ExecuteTool executes a tool by name.
func (*Adapter) GetAllServices ¶
func (a *Adapter) GetAllServices() []api.ServiceStatus
GetAllServices returns the status of all services.
func (*Adapter) GetServiceStatus ¶
func (a *Adapter) GetServiceStatus(name string) (*api.ServiceStatus, error)
GetServiceStatus returns the current status of a service.
func (*Adapter) GetTools ¶
func (a *Adapter) GetTools() []api.ToolMetadata
GetTools returns all tools this provider offers.
func (*Adapter) Register ¶
func (a *Adapter) Register()
Register registers the adapter with the API.
func (*Adapter) RestartService ¶
func (*Adapter) StartService ¶
Service lifecycle management.
func (*Adapter) StopService ¶
func (*Adapter) SubscribeToStateChanges ¶
func (a *Adapter) SubscribeToStateChanges() <-chan api.ServiceStateChangedEvent
type Config ¶
type Config struct {
Aggregator config.AggregatorConfig
Yolo bool
}
Config holds the configuration for the orchestrator.
type Orchestrator ¶
type Orchestrator struct {
// contains filtered or unexported fields
}
Orchestrator manages the lifecycle of static services registered in the service registry (MCPServer services and the aggregator service).
func (*Orchestrator) GetAllServices ¶
func (o *Orchestrator) GetAllServices() []ServiceStatus
GetAllServices returns status for all services.
func (*Orchestrator) GetServiceRegistry ¶
func (o *Orchestrator) GetServiceRegistry() services.ServiceRegistry
GetServiceRegistry returns the service registry.
func (*Orchestrator) GetServiceStatus ¶
func (o *Orchestrator) GetServiceStatus(name string) (*ServiceStatus, error)
GetServiceStatus returns the status of a specific service.
func (*Orchestrator) RestartService ¶
func (o *Orchestrator) RestartService(name string) error
RestartService restarts a specific service by name.
func (*Orchestrator) Start ¶
func (o *Orchestrator) Start(ctx context.Context) error
Start initializes and starts all registered static services and creates auto-start MCPServer services from MCPServer definitions.
func (*Orchestrator) StartService ¶
func (o *Orchestrator) StartService(name string) error
StartService starts a specific service by name. For MCP servers, this method waits for the server to be fully registered with the aggregator before returning, ensuring that tools are available.
func (*Orchestrator) StopService ¶
func (o *Orchestrator) StopService(name string) error
StopService stops a specific service by name.
func (*Orchestrator) SubscribeToStateChanges ¶
func (o *Orchestrator) SubscribeToStateChanges() <-chan ServiceStateChangedEvent
SubscribeToStateChanges returns a channel for state change events.
type ServiceStateChangedEvent ¶
type ServiceStateChangedEvent struct {
Name string
ServiceType string
OldState string
NewState string
Health string
Error error
Timestamp int64
}
ServiceStateChangedEvent represents a service state change event.
type ServiceStatus ¶
ServiceStatus represents the status of a service.
type StopReason ¶
type StopReason int
StopReason tracks why a service was stopped.
const ( StopReasonManual StopReason = iota StopReasonDependency )