serviceclass

package
v0.0.235 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package serviceclass provides Kubernetes CRD-based ServiceClass management with full lifecycle operations and status tracking.

Overview

This package implements ServiceClass management using Kubernetes Custom Resource Definitions (CRDs). ServiceClasses define templates for creating and managing service instances with standardized lifecycle operations, health monitoring, and dependency management.

Architecture

The package follows the muster API Service Locator Pattern:

  • Adapter: Implements the ServiceClassManager interface from internal/api
  • Client Integration: Uses the unified MusterClient interface for data access
  • CRD Management: Handles Kubernetes ServiceClass resources with proper validation
  • Status Tracking: Dynamically calculates tool availability and service readiness

Key Features

  • Complete CRUD operations for ServiceClass resources
  • Dynamic tool availability checking and status population
  • Kubernetes-native storage with CRD support
  • Fallback to filesystem mode when CRDs are unavailable
  • Comprehensive argument validation and templating support
  • Health check configuration and monitoring
  • Dependency resolution between ServiceClasses

Usage Example

// Create and register the adapter
adapter, err := serviceclass.NewAdapter()
if err != nil {
    log.Fatal("Failed to create ServiceClass adapter:", err)
}
defer adapter.Close()

// Register with the API layer (required by Service Locator Pattern)
adapter.Register()

// Access via API layer (recommended)
manager := api.GetServiceClassManager()
serviceClass, err := manager.GetServiceClass("my-service")

Type Conversions

The package handles conversion between:

  • Kubernetes CRD types (pkg/apis/muster/v1alpha1)
  • Internal API types (internal/api)
  • Raw YAML/JSON representations

Error Handling

All operations return structured errors with proper context:

  • ServiceClassNotFoundError: When a ServiceClass doesn't exist
  • ValidationError: When ServiceClass definition is invalid
  • KubernetesError: When underlying Kubernetes operations fail

Thread Safety

The Adapter is thread-safe and can be used concurrently across multiple goroutines. The underlying Kubernetes client handles connection pooling and request management.

Performance Considerations

- Status population happens on every read operation for accuracy - Tool availability is checked dynamically via the aggregator - Large ServiceClass lists are processed in batches where possible - Client connections are reused and properly managed

Package serviceclass provides ServiceClass management functionality.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Adapter

type Adapter struct {
	// contains filtered or unexported fields
}

Adapter provides ServiceClass management functionality using the unified client

func NewAdapterWithClient

func NewAdapterWithClient(musterClient client.MusterClient, namespace string) *Adapter

NewAdapterWithClient creates a new adapter with a specific client (for testing)

func (*Adapter) Close

func (a *Adapter) Close() error

Close performs cleanup for the 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) GetHealthCheckConfig

func (a *Adapter) GetHealthCheckConfig(name string) (enabled bool, interval time.Duration, failureThreshold, successThreshold int, err error)

func (*Adapter) GetHealthCheckTool

func (a *Adapter) GetHealthCheckTool(name string) (toolName string, args map[string]interface{}, expectation *api.HealthCheckExpectation, err error)

func (*Adapter) GetRestartTool

func (a *Adapter) GetRestartTool(name string) (toolName string, args map[string]interface{}, outputs map[string]string, err error)

func (*Adapter) GetServiceClass

func (a *Adapter) GetServiceClass(name string) (*api.ServiceClass, error)

GetServiceClass retrieves a specific ServiceClass by name

func (*Adapter) GetServiceDependencies

func (a *Adapter) GetServiceDependencies(name string) ([]string, error)

func (*Adapter) GetStartTool

func (a *Adapter) GetStartTool(name string) (toolName string, args map[string]interface{}, outputs map[string]string, err error)

Tool-specific getter methods for orchestrator compatibility

func (*Adapter) GetStopTool

func (a *Adapter) GetStopTool(name string) (toolName string, args map[string]interface{}, outputs map[string]string, err error)

func (*Adapter) GetTools

func (a *Adapter) GetTools() []api.ToolMetadata

GetTools returns all tools this provider offers

func (*Adapter) IsServiceClassAvailable

func (a *Adapter) IsServiceClassAvailable(name string) bool

IsServiceClassAvailable checks if a ServiceClass is available

func (*Adapter) ListServiceClasses

func (a *Adapter) ListServiceClasses() []api.ServiceClass

ListServiceClasses returns all ServiceClasses with their status populated

func (*Adapter) Register

func (a *Adapter) Register()

Register registers this adapter with the central API layer This method follows the project's API Service Locator Pattern

Jump to

Keyboard shortcuts

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