Documentation
¶
Index ¶
- Variables
- func NewLogger() *logrus.Logger
- func NewRuntimeFactory(logger *logrus.Logger, sandboxConfig *entity.SandboxConfig) component.IRuntimeFactory
- func NewRuntimeManagerFromFactory(factory component.IRuntimeFactory, logger *logrus.Logger) component.IRuntimeManager
- func NewSandboxConfig() *entity.SandboxConfig
- type HTTPFaaSRequest
- type HTTPFaaSResponse
- type HTTPFaaSRuntimeAdapter
- func (adapter *HTTPFaaSRuntimeAdapter) Cleanup() error
- func (adapter *HTTPFaaSRuntimeAdapter) GetLanguageType() entity.LanguageType
- func (adapter *HTTPFaaSRuntimeAdapter) GetReturnValFunction() string
- func (adapter *HTTPFaaSRuntimeAdapter) RunCode(ctx context.Context, code string, language string, timeoutMS int64, ...) (*entity.ExecutionResult, error)
- type HTTPFaaSRuntimeConfig
- type JavaScriptRuntime
- func (jr *JavaScriptRuntime) GetHealthStatus() map[string]interface{}
- func (jr *JavaScriptRuntime) GetLanguageType() entity.LanguageType
- func (jr *JavaScriptRuntime) GetMetrics() map[string]interface{}
- func (jr *JavaScriptRuntime) GetReturnValFunction() string
- func (jr *JavaScriptRuntime) GetSupportedLanguages() []entity.LanguageType
- func (jr *JavaScriptRuntime) RunCode(ctx context.Context, code string, language string, timeoutMS int64, ...) (*entity.ExecutionResult, error)
- func (jr *JavaScriptRuntime) ValidateCode(ctx context.Context, code string, language string) bool
- type PythonRuntime
- func (pr *PythonRuntime) GetHealthStatus() map[string]interface{}
- func (pr *PythonRuntime) GetLanguageType() entity.LanguageType
- func (pr *PythonRuntime) GetMetrics() map[string]interface{}
- func (pr *PythonRuntime) GetReturnValFunction() string
- func (pr *PythonRuntime) GetSupportedLanguages() []entity.LanguageType
- func (pr *PythonRuntime) RunCode(ctx context.Context, code string, language string, timeoutMS int64, ...) (*entity.ExecutionResult, error)
- func (pr *PythonRuntime) ValidateCode(ctx context.Context, code string, language string) bool
- type RuntimeFactory
- type RuntimeManager
- func (m *RuntimeManager) ClearCache()
- func (m *RuntimeManager) GetHealthStatus() map[string]interface{}
- func (m *RuntimeManager) GetMetrics() map[string]interface{}
- func (m *RuntimeManager) GetRuntime(languageType entity.LanguageType) (component.IRuntime, error)
- func (m *RuntimeManager) GetSupportedLanguages() []entity.LanguageType
Constants ¶
This section is empty.
Variables ¶
var RuntimeSet = wire.NewSet( NewSandboxConfig, NewLogger, NewRuntimeFactory, NewRuntimeManagerFromFactory, )
Functions ¶
func NewRuntimeFactory ¶
func NewRuntimeFactory(logger *logrus.Logger, sandboxConfig *entity.SandboxConfig) component.IRuntimeFactory
NewRuntimeFactory 创建统一运行时工厂实例
func NewRuntimeManagerFromFactory ¶
func NewRuntimeManagerFromFactory(factory component.IRuntimeFactory, logger *logrus.Logger) component.IRuntimeManager
func NewSandboxConfig ¶
func NewSandboxConfig() *entity.SandboxConfig
Types ¶
type HTTPFaaSRequest ¶
type HTTPFaaSRequest struct {
Language string `json:"language"`
Code string `json:"code"`
Input interface{} `json:"input,omitempty"`
Timeout int64 `json:"timeout,omitempty"`
Priority string `json:"priority,omitempty"`
Ext map[string]string `json:"ext,omitempty"`
}
HTTPFaaSRequest HTTP FaaS请求结构
type HTTPFaaSResponse ¶
type HTTPFaaSResponse struct {
Output struct {
Stdout string `json:"stdout"`
Stderr string `json:"stderr"`
RetVal string `json:"ret_val"`
} `json:"output"`
Metadata *struct {
TaskID string `json:"task_id"`
InstanceID string `json:"instance_id"`
Duration int64 `json:"duration"`
PoolStats struct {
TotalInstances int `json:"totalInstances"`
IdleInstances int `json:"idleInstances"`
ActiveInstances int `json:"activeInstances"`
} `json:"pool_stats"`
} `json:"metadata,omitempty"`
Error string `json:"error,omitempty"`
Details string `json:"details,omitempty"`
}
HTTPFaaSResponse HTTP FaaS响应结构
type HTTPFaaSRuntimeAdapter ¶
type HTTPFaaSRuntimeAdapter struct {
// contains filtered or unexported fields
}
HTTPFaaSRuntimeAdapter 基于HTTP调用的FaaS运行时适配器
func NewHTTPFaaSRuntimeAdapter ¶
func NewHTTPFaaSRuntimeAdapter(languageType entity.LanguageType, config *HTTPFaaSRuntimeConfig, logger *logrus.Logger) (*HTTPFaaSRuntimeAdapter, error)
NewHTTPFaaSRuntimeAdapter 创建HTTP FaaS运行时适配器
func (*HTTPFaaSRuntimeAdapter) Cleanup ¶
func (adapter *HTTPFaaSRuntimeAdapter) Cleanup() error
Cleanup 清理资源
func (*HTTPFaaSRuntimeAdapter) GetLanguageType ¶
func (adapter *HTTPFaaSRuntimeAdapter) GetLanguageType() entity.LanguageType
GetLanguageType 获取支持的语言类型
func (*HTTPFaaSRuntimeAdapter) GetReturnValFunction ¶
func (adapter *HTTPFaaSRuntimeAdapter) GetReturnValFunction() string
GetReturnValFunction 获取return_val函数实现
type HTTPFaaSRuntimeConfig ¶
type HTTPFaaSRuntimeConfig struct {
BaseURL string `json:"base_url"` // FaaS服务基础URL
Timeout time.Duration `json:"timeout"` // HTTP请求超时
MaxRetries int `json:"max_retries"` // 最大重试次数
RetryInterval time.Duration `json:"retry_interval"` // 重试间隔
EnableEnhanced bool `json:"enable_enhanced"` // 是否启用增强版FaaS
}
HTTPFaaSRuntimeConfig HTTP FaaS运行时配置
type JavaScriptRuntime ¶
type JavaScriptRuntime struct {
// contains filtered or unexported fields
}
JavaScriptRuntime JavaScript运行时实现,专门处理JavaScript代码执行
func NewJavaScriptRuntime ¶
func NewJavaScriptRuntime(config *entity.SandboxConfig, logger *logrus.Logger) (*JavaScriptRuntime, error)
NewJavaScriptRuntime 创建JavaScript运行时实例
func (*JavaScriptRuntime) GetHealthStatus ¶
func (jr *JavaScriptRuntime) GetHealthStatus() map[string]interface{}
GetHealthStatus 获取健康状态
func (*JavaScriptRuntime) GetLanguageType ¶
func (jr *JavaScriptRuntime) GetLanguageType() entity.LanguageType
GetLanguageType 获取语言类型
func (*JavaScriptRuntime) GetMetrics ¶
func (jr *JavaScriptRuntime) GetMetrics() map[string]interface{}
GetMetrics 获取运行时指标
func (*JavaScriptRuntime) GetReturnValFunction ¶
func (jr *JavaScriptRuntime) GetReturnValFunction() string
GetReturnValFunction 获取JavaScript return_val函数实现
func (*JavaScriptRuntime) GetSupportedLanguages ¶
func (jr *JavaScriptRuntime) GetSupportedLanguages() []entity.LanguageType
GetSupportedLanguages 获取支持的语言类型列表
func (*JavaScriptRuntime) RunCode ¶
func (jr *JavaScriptRuntime) RunCode(ctx context.Context, code string, language string, timeoutMS int64, ext map[string]string) (*entity.ExecutionResult, error)
RunCode 执行JavaScript代码
func (*JavaScriptRuntime) ValidateCode ¶
ValidateCode 验证JavaScript代码语法
type PythonRuntime ¶
type PythonRuntime struct {
// contains filtered or unexported fields
}
PythonRuntime Python运行时实现,专门处理Python代码执行
func NewPythonRuntime ¶
func NewPythonRuntime(config *entity.SandboxConfig, logger *logrus.Logger) (*PythonRuntime, error)
NewPythonRuntime 创建Python运行时实例
func (*PythonRuntime) GetHealthStatus ¶
func (pr *PythonRuntime) GetHealthStatus() map[string]interface{}
GetHealthStatus 获取健康状态
func (*PythonRuntime) GetLanguageType ¶
func (pr *PythonRuntime) GetLanguageType() entity.LanguageType
GetLanguageType 获取语言类型
func (*PythonRuntime) GetMetrics ¶
func (pr *PythonRuntime) GetMetrics() map[string]interface{}
GetMetrics 获取运行时指标
func (*PythonRuntime) GetReturnValFunction ¶
func (pr *PythonRuntime) GetReturnValFunction() string
GetReturnValFunction 获取Python return_val函数实现
func (*PythonRuntime) GetSupportedLanguages ¶
func (pr *PythonRuntime) GetSupportedLanguages() []entity.LanguageType
GetSupportedLanguages 获取支持的语言类型列表
func (*PythonRuntime) RunCode ¶
func (pr *PythonRuntime) RunCode(ctx context.Context, code string, language string, timeoutMS int64, ext map[string]string) (*entity.ExecutionResult, error)
RunCode 执行Python代码
func (*PythonRuntime) ValidateCode ¶
ValidateCode 验证Python代码语法
type RuntimeFactory ¶
type RuntimeFactory struct {
// contains filtered or unexported fields
}
RuntimeFactory 统一的运行时工厂实现
func (*RuntimeFactory) CreateRuntime ¶
func (f *RuntimeFactory) CreateRuntime(languageType entity.LanguageType) (component.IRuntime, error)
CreateRuntime 根据语言类型创建Runtime实例
func (*RuntimeFactory) GetHealthStatus ¶
func (f *RuntimeFactory) GetHealthStatus() map[string]interface{}
GetHealthStatus 获取工厂健康状态
func (*RuntimeFactory) GetMetrics ¶
func (f *RuntimeFactory) GetMetrics() map[string]interface{}
GetMetrics 获取工厂指标
func (*RuntimeFactory) GetSupportedLanguages ¶
func (f *RuntimeFactory) GetSupportedLanguages() []entity.LanguageType
GetSupportedLanguages 获取支持的语言类型列表
type RuntimeManager ¶
type RuntimeManager struct {
// contains filtered or unexported fields
}
RuntimeManager 统一的运行时管理器,提供线程安全的Runtime实例缓存和管理
func NewRuntimeManager ¶
func NewRuntimeManager(factory component.IRuntimeFactory, logger *logrus.Logger) *RuntimeManager
NewRuntimeManager 创建统一运行时管理器实例
func (*RuntimeManager) ClearCache ¶
func (m *RuntimeManager) ClearCache()
ClearCache 清空缓存(主要用于测试和重置)
func (*RuntimeManager) GetHealthStatus ¶
func (m *RuntimeManager) GetHealthStatus() map[string]interface{}
GetHealthStatus 获取管理器健康状态
func (*RuntimeManager) GetMetrics ¶
func (m *RuntimeManager) GetMetrics() map[string]interface{}
GetMetrics 获取管理器指标
func (*RuntimeManager) GetRuntime ¶
func (m *RuntimeManager) GetRuntime(languageType entity.LanguageType) (component.IRuntime, error)
GetRuntime 获取指定语言类型的Runtime实例,支持缓存和线程安全
func (*RuntimeManager) GetSupportedLanguages ¶
func (m *RuntimeManager) GetSupportedLanguages() []entity.LanguageType
GetSupportedLanguages 获取支持的语言类型列表