Documentation
¶
Index ¶
- Constants
- Variables
- func DomainErrorToStatusCode(err *domainerrors.DomainError) int
- func GetFunctionKey(namespace, name string) string
- func IsNotFoundError(err error) bool
- func NewBadRequestError(message string) error
- func NewInternalServerError(message string, err ...error) error
- func NewNotFoundError(message string) error
- func WrapEngineError(message string, err error) error
- type BuildOperations
- type CircuitBreaker
- type CircuitBreakerManager
- type Engine
- func (e *Engine) BuildFunction(namespace, name, path, tag string, config manifest.FunctionManifest) (*types.BuildResult, error)
- func (e *Engine) CallFunctionWithContext(ctx context.Context, namespace, name, entrypoint string, payload []byte) ([]byte, error)
- func (e *Engine) GetConfig() *config.Config
- func (e *Engine) GetRegistry() registry.Registry
- func (e *Engine) IsFunctionStopped(namespace, name string) bool
- func (e *Engine) IsLoaded(namespace, name string) bool
- func (e *Engine) LoadFunctionWithContext(ctx context.Context, namespace, name, identifier string, ...) error
- func (e *Engine) LoadFunctionWithForce(ctx context.Context, namespace, name, identifier string, ...) error
- func (e *Engine) ReassignTag(namespace, name, tag, newDigest string) error
- func (e *Engine) Start() error
- func (e *Engine) StopFunction(namespace, name string) error
- func (e *Engine) UnloadFunction(namespace, name string) error
- func (e *Engine) WasPreviouslyLoaded(namespace, name string) (bool, map[string]string)
- type ExecutionStats
- type ExtendedBuildRequest
- type FunctionExecutor
- func (e *FunctionExecutor) CallFunction(ctx context.Context, namespace, name, entrypoint string, payload []byte) ([]byte, error)
- func (e *FunctionExecutor) DefaultTimeout() time.Duration
- func (e *FunctionExecutor) GetCircuitBreaker(namespace, name string) CircuitBreaker
- func (e *FunctionExecutor) GetStats(_, _ string) ExecutionStats
- type FunctionLoader
- func (l *FunctionLoader) GetDigest(namespace, name string) (string, bool)
- func (l *FunctionLoader) IsLoaded(namespace, name string) bool
- func (l *FunctionLoader) IsStopped(namespace, name string) bool
- func (l *FunctionLoader) LoadFunction(ctx context.Context, namespace, name, identifier string, ...) error
- func (l *FunctionLoader) LoadFunctionWithForce(ctx context.Context, namespace, name, identifier string, ...) error
- func (l *FunctionLoader) StopFunction(namespace, name string) error
- func (l *FunctionLoader) UnloadFunction(namespace, name string) error
- func (l *FunctionLoader) WasPreviouslyLoaded(namespace, name string) (bool, map[string]string)
- type FunctionManager
- type FunctionManagerImpl
- func (m *FunctionManagerImpl) BuildFunction(namespace, name, path, tag string, config manifest.FunctionManifest) (*types.BuildResult, error)
- func (m *FunctionManagerImpl) CallFunction(ctx context.Context, namespace, name, entrypoint string, payload []byte) ([]byte, error)
- func (m *FunctionManagerImpl) GetFunctionState(namespace, name string) FunctionState
- func (m *FunctionManagerImpl) LoadFunction(ctx context.Context, namespace, name, identifier string, ...) error
- func (m *FunctionManagerImpl) ReassignTag(namespace, name, tag, newDigest string) error
- func (m *FunctionManagerImpl) StopFunction(namespace, name string) error
- func (m *FunctionManagerImpl) UnloadFunction(namespace, name string) error
- type FunctionState
- type HandlerFunc
- type Handlers
- type Middleware
- type Options
- func (o *Options) WithCircuitBreakerSettings(settings components.CircuitBreakerSettings) *Options
- func (o *Options) WithDefaultTimeout(timeout time.Duration) *Options
- func (o *Options) WithLogStoreCapacity(capacity int) *Options
- func (o *Options) WithPluginManagerSettings(settings components.PluginManagerSettings) *Options
- type PluginManager
- type PluginManagerSettings
- type RequestError
- type RuntimeOperations
- type Server
- type StateOperations
Constants ¶
const ( LevelInfo = logging.LevelInfo LevelWarning = logging.LevelWarning LevelError = logging.LevelError LevelDebug = logging.LevelDebug )
Variables ¶
var ( ErrFunctionNotLoaded = errors.New("function not loaded") ErrEngineNotInitialized = errors.New("engine not initialized") )
EngineError base errors
Functions ¶
func DomainErrorToStatusCode ¶ added in v0.1.1
func DomainErrorToStatusCode(err *domainerrors.DomainError) int
func GetFunctionKey ¶ added in v0.1.1
func IsNotFoundError ¶
func NewBadRequestError ¶
NewBadRequestError is returned for invalid requests with the given message.
func NewInternalServerError ¶
func NewNotFoundError ¶
func WrapEngineError ¶
Types ¶
type BuildOperations ¶ added in v0.1.1
type BuildOperations interface { // BuildFunction builds a function from source and adds it to the registry. BuildFunction(namespace, name, path, tag string, config manifest.FunctionManifest) (*types.BuildResult, error) // ReassignTag changes a tag to point to a different digest. ReassignTag(namespace, name, tag, newDigest string) error }
type CircuitBreaker ¶
type CircuitBreaker = components.CircuitBreaker
type CircuitBreakerManager ¶
type CircuitBreakerManager = components.CircuitBreakerManager
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
func NewEngineWithConfig ¶
NewEngineWithConfig creates a new engine instance using a configuration object.
func NewEngineWithOptions ¶
func NewEngineWithOptions(socketPath, httpAddr string, registryDir string, logger logging.Logger, options *Options) (*Engine, error)
NewEngineWithOptions creates a new engine instance with custom settings. Accepts optional logger and options parameters (nil values use defaults).
func (*Engine) BuildFunction ¶
func (e *Engine) BuildFunction(namespace, name, path, tag string, config manifest.FunctionManifest) (*types.BuildResult, error)
BuildFunction builds a function and stores it in the registry.
func (*Engine) CallFunctionWithContext ¶
func (e *Engine) CallFunctionWithContext(ctx context.Context, namespace, name, entrypoint string, payload []byte) ([]byte, error)
CallFunctionWithContext calls a function with the specified parameters.
func (*Engine) GetRegistry ¶
GetRegistry returns the registry instance. This is a convenience method for direct access when needed.
func (*Engine) IsFunctionStopped ¶
IsFunctionStopped checks if a function is explicitly stopped.
func (*Engine) LoadFunctionWithContext ¶
func (e *Engine) LoadFunctionWithContext(ctx context.Context, namespace, name, identifier string, config map[string]string) error
LoadFunctionWithContext loads a function with the specified identifier and configuration.
func (*Engine) LoadFunctionWithForce ¶
func (e *Engine) LoadFunctionWithForce(ctx context.Context, namespace, name, identifier string, config map[string]string, force bool) error
LoadFunctionWithForce loads a function with the option to force loading even if stopped.
func (*Engine) ReassignTag ¶
ReassignTag reassigns a tag to a different function version.
func (*Engine) StopFunction ¶
StopFunction stops a function and marks it as explicitly stopped to prevent auto-reload.
func (*Engine) UnloadFunction ¶
UnloadFunction unloads a function, removing it from memory but preserving its configuration.
type ExecutionStats ¶ added in v0.1.1
type ExecutionStats struct { LastExecution time.Time TotalExecutions int64 SuccessfulExecutions int64 FailedExecutions int64 }
ExecutionStats contains statistics about function execution
type ExtendedBuildRequest ¶
type ExtendedBuildRequest struct { types.BuildRequest Manifest manifest.FunctionManifest `json:"manifest"` }
type FunctionExecutor ¶
type FunctionExecutor struct {
// contains filtered or unexported fields
}
func NewFunctionExecutor ¶
func NewFunctionExecutor(pluginManager PluginManager, circuitBreakers CircuitBreakerManager, logStore *logging.FunctionLogStore, logger logging.Logger, defaultTimeout time.Duration) *FunctionExecutor
func (*FunctionExecutor) CallFunction ¶
func (*FunctionExecutor) DefaultTimeout ¶
func (e *FunctionExecutor) DefaultTimeout() time.Duration
func (*FunctionExecutor) GetCircuitBreaker ¶ added in v0.1.1
func (e *FunctionExecutor) GetCircuitBreaker(namespace, name string) CircuitBreaker
func (*FunctionExecutor) GetStats ¶ added in v0.1.1
func (e *FunctionExecutor) GetStats(_, _ string) ExecutionStats
type FunctionLoader ¶
type FunctionLoader struct {
// contains filtered or unexported fields
}
func NewFunctionLoader ¶
func NewFunctionLoader(registry registry.Registry, pluginManager PluginManager, circuitBreakers CircuitBreakerManager, logStore *logging.FunctionLogStore, logger logging.Logger) *FunctionLoader
func (*FunctionLoader) GetDigest ¶ added in v0.1.1
func (l *FunctionLoader) GetDigest(namespace, name string) (string, bool)
GetDigest returns the current digest of a function
func (*FunctionLoader) IsLoaded ¶
func (l *FunctionLoader) IsLoaded(namespace, name string) bool
IsLoaded checks if a function is loaded.
func (*FunctionLoader) IsStopped ¶
func (l *FunctionLoader) IsStopped(namespace, name string) bool
IsStopped checks if a function is stopped.
func (*FunctionLoader) LoadFunction ¶
func (l *FunctionLoader) LoadFunction(ctx context.Context, namespace, name, identifier string, config map[string]string) error
LoadFunction loads a function with the specified identifier and configuration. This is a convenience method that calls LoadFunctionWithForce with force=false.
func (*FunctionLoader) LoadFunctionWithForce ¶
func (l *FunctionLoader) LoadFunctionWithForce(ctx context.Context, namespace, name, identifier string, config map[string]string, force bool) error
LoadFunctionWithForce loads a function with the specified identifier and configuration, with the option to force loading even if the function is marked as stopped.
func (*FunctionLoader) StopFunction ¶
func (l *FunctionLoader) StopFunction(namespace, name string) error
StopFunction stops a function and marks it as explicitly stopped, which prevents it from being automatically reloaded. It can only be reloaded with the force option.
Parameters:
- namespace: The function namespace
- name: The function name
Returns:
- error: Any error that occurred during stopping
func (*FunctionLoader) UnloadFunction ¶
func (l *FunctionLoader) UnloadFunction(namespace, name string) error
UnloadFunction unloads a function, removing it from memory but preserving its configuration for potential future reloading.
Parameters:
- namespace: The function namespace
- name: The function name
Returns:
- error: Any error that occurred during unloading
func (*FunctionLoader) WasPreviouslyLoaded ¶
func (l *FunctionLoader) WasPreviouslyLoaded(namespace, name string) (bool, map[string]string)
WasPreviouslyLoaded checks if a function was previously loaded.
type FunctionManager ¶
type FunctionManager interface { RuntimeOperations BuildOperations StateOperations }
type FunctionManagerImpl ¶ added in v0.1.1
type FunctionManagerImpl struct {
// contains filtered or unexported fields
}
func NewFunctionManager ¶
func NewFunctionManager(loader *FunctionLoader, executor *FunctionExecutor, registry registry.Registry, functionSvc services.FunctionService, defaultTimeout time.Duration) *FunctionManagerImpl
func (*FunctionManagerImpl) BuildFunction ¶ added in v0.1.1
func (m *FunctionManagerImpl) BuildFunction(namespace, name, path, tag string, config manifest.FunctionManifest) (*types.BuildResult, error)
BuildFunction builds a function and stores it in the registry
func (*FunctionManagerImpl) CallFunction ¶ added in v0.1.1
func (*FunctionManagerImpl) GetFunctionState ¶ added in v0.1.1
func (m *FunctionManagerImpl) GetFunctionState(namespace, name string) FunctionState
GetFunctionState returns the complete state information for a function
func (*FunctionManagerImpl) LoadFunction ¶ added in v0.1.1
func (m *FunctionManagerImpl) LoadFunction(ctx context.Context, namespace, name, identifier string, config map[string]string, force bool) error
LoadFunction loads a function with the specified identifier and configuration. If force is true, it will load even if the function is marked as stopped.
func (*FunctionManagerImpl) ReassignTag ¶ added in v0.1.1
func (m *FunctionManagerImpl) ReassignTag(namespace, name, tag, newDigest string) error
ReassignTag reassigns a tag to a different function version
func (*FunctionManagerImpl) StopFunction ¶ added in v0.1.1
func (m *FunctionManagerImpl) StopFunction(namespace, name string) error
func (*FunctionManagerImpl) UnloadFunction ¶ added in v0.1.1
func (m *FunctionManagerImpl) UnloadFunction(namespace, name string) error
type FunctionState ¶
type FunctionState struct { // Basic state Loaded bool // Whether the function is currently loaded Running bool // Whether the function is currently running Stopped bool // Whether the function has been explicitly stopped PreviouslyLoaded bool // Whether the function was previously loaded in this session // Configuration Config map[string]string // Current function configuration // Execution stats LastExecutionTime time.Time // When the function was last executed TotalExecutions int64 // Total number of executions SuccessfulExecutions int64 // Number of successful executions FailedExecutions int64 // Number of failed executions // Circuit breaker status CircuitBreakerOpen bool // Whether the circuit breaker is open // Registry info Digest string // Current function digest Tags []string // Tags associated with this function }
FunctionState contains the complete state information for a function.
type HandlerFunc ¶
type HandlerFunc func(http.ResponseWriter, *http.Request) error
type Handlers ¶
type Handlers struct {
// contains filtered or unexported fields
}
func (*Handlers) HTTPHandler ¶
func (*Handlers) UnixSocketHandler ¶
type Middleware ¶
type Middleware func(HandlerFunc) HandlerFunc
type Options ¶
type Options struct { // Default timeout for function operations DefaultTimeout time.Duration // Capacity of the log store LogStoreCapacity int CircuitBreakerSettings components.CircuitBreakerSettings PluginManagerSettings components.PluginManagerSettings }
func DefaultEngineOptions ¶
func DefaultEngineOptions() *Options
func OptionsFromConfig ¶
func (*Options) WithCircuitBreakerSettings ¶
func (o *Options) WithCircuitBreakerSettings(settings components.CircuitBreakerSettings) *Options
func (*Options) WithDefaultTimeout ¶
func (*Options) WithLogStoreCapacity ¶
func (*Options) WithPluginManagerSettings ¶
func (o *Options) WithPluginManagerSettings(settings components.PluginManagerSettings) *Options
type PluginManager ¶
type PluginManager = components.PluginManager
type PluginManagerSettings ¶
type PluginManagerSettings = components.PluginManagerSettings
type RequestError ¶
type RequestError struct { Message string StatusCode int // contains filtered or unexported fields }
func DomainErrorToRequestError ¶ added in v0.1.1
func DomainErrorToRequestError(err *domainerrors.DomainError) RequestError
func NewRequestError ¶
func NewRequestError(message string, statusCode int) RequestError
func NewRequestErrorWithCause ¶ added in v0.1.1
func NewRequestErrorWithCause(message string, statusCode int, cause error) RequestError
func (RequestError) Error ¶
func (e RequestError) Error() string
func (RequestError) Unwrap ¶
func (e RequestError) Unwrap() error
type RuntimeOperations ¶ added in v0.1.1
type RuntimeOperations interface { // LoadFunction loads a function with the specified identifier and configuration. // If force is true, it will load even if the function is marked as stopped. LoadFunction(ctx context.Context, namespace, name, identifier string, config map[string]string, force bool) error // CallFunction calls a function with the specified parameters. CallFunction(ctx context.Context, namespace, name, entrypoint string, payload []byte) ([]byte, error) // UnloadFunction unloads a function, removing it from memory. UnloadFunction(namespace, name string) error // StopFunction stops a function and marks it as stopped so it won't be auto-loaded. StopFunction(namespace, name string) error }
type StateOperations ¶ added in v0.1.1
type StateOperations interface { // GetFunctionState returns the current state of a function. GetFunctionState(namespace, name string) FunctionState }