orchestrator

package
v1.8.4 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2026 License: Apache-2.0 Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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.

Variables

View Source
var RetryInterval = durationFromEnv("MUSTER_ORCHESTRATOR_RETRY_INTERVAL", 30*time.Second)

RetryInterval is the interval at which the orchestrator checks for failed servers to retry. Overridable via MUSTER_ORCHESTRATOR_RETRY_INTERVAL (a Go duration, e.g. "1s") so the integration test harness can pick up expired backoffs promptly instead of waiting for the next production-length tick.

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) RemoveService added in v1.4.15

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

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) RemoveService added in v1.4.15

func (o *Orchestrator) RemoveService(name string) error

RemoveService stops a service and removes it from the registry. This is used when a service definition is deleted, so that a later re-create with the same name is reconciled as a fresh service instead of matching the stale registry entry.

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