orchestrator

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

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

View Source
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.

View Source
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 (a *Adapter) RestartService(name string) error

func (*Adapter) StartService

func (a *Adapter) StartService(name string) error

Service lifecycle management.

func (*Adapter) StopService

func (a *Adapter) StopService(name string) error

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 New

func New(cfg Config) *Orchestrator

New creates a new orchestrator.

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) Stop

func (o *Orchestrator) Stop() error

Stop gracefully stops all services.

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

type ServiceStatus struct {
	Name   string
	Type   string
	State  string
	Health string
	Error  error
}

ServiceStatus represents the status of a service.

type StopReason

type StopReason int

StopReason tracks why a service was stopped.

const (
	StopReasonManual StopReason = iota
	StopReasonDependency
)

Jump to

Keyboard shortcuts

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