components

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StateClosed   = "closed"
	StateHalfOpen = "half-open"
	StateOpen     = "open"
)

Circuit breaker states as string constants.

Variables

This section is empty.

Functions

func CreatePlugin

func CreatePlugin(wasmBytes []byte, versionInfo *registry.VersionInfo, config map[string]string) (*extism.Plugin, error)

Types

type CircuitBreaker

type CircuitBreaker interface {
	// Record a successful operation
	RecordSuccess()

	// Record a failed operation
	RecordFailure() bool

	// Check if the circuit is open
	IsOpen() bool

	// Reset the circuit breaker
	Reset()

	// Get the current state
	GetState() string

	// Get the current failure count
	GetFailureCount() int
}

CircuitBreaker defines the interface for a circuit breaker.

func NewCircuitBreakerWithOptions

func NewCircuitBreakerWithOptions(failureThreshold int, resetTimeout time.Duration) CircuitBreaker

NewCircuitBreakerWithOptions creates a new circuit breaker with custom settings.

type CircuitBreakerManager

type CircuitBreakerManager interface {
	// Get a circuit breaker for a function
	GetCircuitBreaker(key string) CircuitBreaker

	// Remove a circuit breaker
	RemoveCircuitBreaker(key string)

	// Reset all circuit breakers
	Reset()

	// Get state of a circuit breaker
	GetCircuitBreakerState(key string) string

	// Get all circuit breakers as a map
	GetAllCircuitBreakers() map[string]CircuitBreaker
}

CircuitBreakerManager manages circuit breakers for functions.

func NewCircuitBreakerManagerWithOptions

func NewCircuitBreakerManagerWithOptions(settings CircuitBreakerSettings) CircuitBreakerManager

NewCircuitBreakerManagerWithOptions creates a new circuit breaker manager with custom settings.

type CircuitBreakerSettings

type CircuitBreakerSettings struct {
	FailureThreshold int
	ResetTimeout     time.Duration
}

CircuitBreakerSettings holds configuration for circuit breakers.

type FunctionID

type FunctionID struct {
	Namespace string
	Name      string
}

FunctionID represents a unique function identifier.

type PluginManager

type PluginManager interface {
	// Plugin operations
	GetPlugin(key string) (*extism.Plugin, bool)
	StorePlugin(key string, plugin *extism.Plugin, digest string, config map[string]string)
	RemovePlugin(key string) bool

	// Plugin state management
	IsPluginLoaded(key string) bool
	WasPreviouslyLoaded(key string) (bool, map[string]string)
	HasConfigChanged(key string, newConfig map[string]string) bool
	HasDigestChanged(key string, newDigest string) bool
	GetPluginDigest(key string) (string, bool)
	GetPluginConfig(key string) (map[string]string, bool)

	// Function state control
	StopFunction(key string) bool
	IsFunctionStopped(key string) bool
	ClearStoppedStatus(key string)

	// Lifecycle management
	StartCleanup(ctx context.Context)
	Shutdown()

	// Information provider
	ListLoadedFunctions() []string
	GetLoadedFunctionCount() int
	GetPreviouslyLoadedFunctions() map[string]bool
	GetStoppedFunctions() map[string]bool
	GetLogStore() *logging.FunctionLogStore
}

PluginManager defines all plugin management capabilities

func NewPluginManager

func NewPluginManager(logger logging.Logger, options PluginManagerSettings) PluginManager

NewPluginManager creates a new plugin manager with the specified settings.

type PluginManagerSettings

type PluginManagerSettings struct {
	// How long to keep unused plugins loaded
	TTL time.Duration

	// How often to run the plugin cleanup routine
	CleanupInterval time.Duration
}

PluginManagerSettings defines configurable options for the plugin manager.

Jump to

Keyboard shortcuts

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