Documentation
¶
Index ¶
- Variables
- func BestPractices()
- func FeatureComparison()
- func Frame(pc uintptr) runtime.Frame
- func GradualMigrationExample()
- func NewSystemExample()
- func OldSystemExample()
- func PerformanceComparison()
- func RegisterFactory(name string, factory ModuleFactory) error
- func RegisterGlobalPlugin(plugin Plugin, pluginType PluginType) error
- func RegisterModule(module Module) error
- func SourceLabel(f runtime.Frame) string
- func UpdateModuleConfig(name string, config Config) error
- type BaseComponent
- type BaseModule
- func (m *BaseModule) Configure(config Config) error
- func (m *BaseModule) Enabled() bool
- func (m *BaseModule) Handler() slog.Handler
- func (m *BaseModule) Name() string
- func (m *BaseModule) Priority() int
- func (m *BaseModule) SetEnabled(enabled bool)
- func (m *BaseModule) SetHandler(handler slog.Handler)
- func (m *BaseModule) Type() ModuleType
- type BasePlugin
- type ComponentInterface
- type Config
- type Configurable
- type ConfigurableComponent
- type ConfigurableModule
- type ConfigurablePlugin
- type Disposable
- type Enableable
- type ExampleFormatterPlugin
- type Formatter
- type FormatterModule
- type FormatterProvider
- type FullModule
- type HandlerComponent
- type HandlerModule
- type HandlerPlugin
- type HandlerProvider
- type Healthable
- type Initializable
- type InterfaceChecker
- func (ic *InterfaceChecker) CheckConfigurable(obj interface{}) (Configurable, bool)
- func (ic *InterfaceChecker) CheckEnableable(obj interface{}) (Enableable, bool)
- func (ic *InterfaceChecker) CheckFullModule(obj interface{}) (FullModule, bool)
- func (ic *InterfaceChecker) CheckHandlerProvider(obj interface{}) (HandlerProvider, bool)
- func (ic *InterfaceChecker) CheckNamed(obj interface{}) (Named, bool)
- func (ic *InterfaceChecker) CheckTyped(obj interface{}) (Typed, bool)
- func (ic *InterfaceChecker) GetImplementedInterfaces(obj interface{}) []string
- type LegacyModuleWrapper
- func (lmw *LegacyModuleWrapper) Configure(config Config) error
- func (lmw *LegacyModuleWrapper) Disable()
- func (lmw *LegacyModuleWrapper) Enable()
- func (lmw *LegacyModuleWrapper) Enabled() bool
- func (lmw *LegacyModuleWrapper) GetConfig() Config
- func (lmw *LegacyModuleWrapper) Handler() slog.Handler
- func (lmw *LegacyModuleWrapper) Name() string
- func (lmw *LegacyModuleWrapper) Priority() int
- func (lmw *LegacyModuleWrapper) SetHandler(handler slog.Handler)
- func (lmw *LegacyModuleWrapper) SetPriority(priority int)
- func (lmw *LegacyModuleWrapper) Type() ModuleType
- type LifecycleComponent
- func (lc *LifecycleComponent) Dispose() error
- func (lc *LifecycleComponent) Initialize() error
- func (lc *LifecycleComponent) IsDisposed() bool
- func (lc *LifecycleComponent) IsInitialized() bool
- func (lc *LifecycleComponent) IsRunning() bool
- func (lc *LifecycleComponent) Start() error
- func (lc *LifecycleComponent) Stop() error
- type ManagedModule
- type Measurable
- type Middleware
- type MiddlewareModule
- type MigrationAdapter
- type MigrationExample
- type Module
- type ModuleAdapter
- func (ma *ModuleAdapter) AsConfigurable() Configurable
- func (ma *ModuleAdapter) AsEnableable() Enableable
- func (ma *ModuleAdapter) AsHandlerProvider() HandlerProvider
- func (ma *ModuleAdapter) AsNamed() Named
- func (ma *ModuleAdapter) AsPrioritized() Prioritized
- func (ma *ModuleAdapter) AsTyped() Typed
- type ModuleConfig
- type ModuleFactory
- type ModuleType
- type MonitoredComponent
- type MonitoredModule
- type Named
- type OldModuleWrapper
- type Plugin
- type PluginInfo
- type PluginManager
- func (pm *PluginManager) Disable()
- func (pm *PluginManager) DisableAll()
- func (pm *PluginManager) DisablePlugin(name string) error
- func (pm *PluginManager) Enable()
- func (pm *PluginManager) EnableAll()
- func (pm *PluginManager) EnablePlugin(name string) error
- func (pm *PluginManager) GetPlugin(name string) (Plugin, bool)
- func (pm *PluginManager) GetPluginsByType(pluginType PluginType) []Plugin
- func (pm *PluginManager) GetStats() PluginStats
- func (pm *PluginManager) IsEnabled() bool
- func (pm *PluginManager) ListPlugins() []string
- func (pm *PluginManager) RegisterPlugin(plugin Plugin, pluginType PluginType) error
- func (pm *PluginManager) UnregisterPlugin(name string) error
- type PluginStats
- type PluginType
- type Prioritized
- type PrioritizedModule
- type PrioritizedPlugin
- type Processor
- type ProcessorModule
- type Registry
- func (r *Registry) Create(name string, config Config) (Module, error)
- func (r *Registry) Get(name string) (Module, bool)
- func (r *Registry) GetByType(moduleType ModuleType) []Module
- func (r *Registry) List() []Module
- func (r *Registry) ListFactories() []string
- func (r *Registry) Register(module Module) error
- func (r *Registry) RegisterFactory(name string, factory ModuleFactory) error
- func (r *Registry) Remove(name string) error
- func (r *Registry) Update(name string, config Config) error
- type SimpleFormatter
- type SimpleProcessor
- type Sink
- type SinkModule
- type Startable
- type Typed
- type WriteSyncer
Constants ¶
This section is empty.
Variables ¶
var GlobalInterfaceChecker = &InterfaceChecker{}
全局接口检查器实例
Functions ¶
func RegisterFactory ¶
func RegisterFactory(name string, factory ModuleFactory) error
RegisterFactory 全局注册工厂
func RegisterGlobalPlugin ¶
func RegisterGlobalPlugin(plugin Plugin, pluginType PluginType) error
RegisterGlobalPlugin 全局注册插件
func SourceLabel ¶ added in v0.1.3
SourceLabel 将 frame 转为短路径标签。
func UpdateModuleConfig ¶ added in v0.1.2
UpdateModuleConfig 重新配置现有模块
Types ¶
type BaseComponent ¶
type BaseComponent struct {
// contains filtered or unexported fields
}
BaseComponent 基础组件实现
func NewBaseComponent ¶
func NewBaseComponent(name string, moduleType ModuleType) *BaseComponent
NewBaseComponent 创建基础组件
func (*BaseComponent) SetPriority ¶
func (bc *BaseComponent) SetPriority(priority int)
SetPriority 实现Prioritized接口
type BaseModule ¶
type BaseModule struct {
// contains filtered or unexported fields
}
BaseModule 基础模块实现
func NewBaseModule ¶
func NewBaseModule(name string, typ ModuleType, priority int) *BaseModule
NewBaseModule 创建基础模块
func (*BaseModule) Configure ¶
func (m *BaseModule) Configure(config Config) error
func (*BaseModule) Enabled ¶
func (m *BaseModule) Enabled() bool
func (*BaseModule) Handler ¶
func (m *BaseModule) Handler() slog.Handler
func (*BaseModule) Name ¶
func (m *BaseModule) Name() string
func (*BaseModule) Priority ¶
func (m *BaseModule) Priority() int
func (*BaseModule) SetEnabled ¶
func (m *BaseModule) SetEnabled(enabled bool)
func (*BaseModule) SetHandler ¶
func (m *BaseModule) SetHandler(handler slog.Handler)
func (*BaseModule) Type ¶
func (m *BaseModule) Type() ModuleType
type BasePlugin ¶
type BasePlugin struct {
// contains filtered or unexported fields
}
BasePlugin 基础插件实现
func (*BasePlugin) Configure ¶
func (bp *BasePlugin) Configure(config map[string]interface{}) error
Configure 配置插件
func (*BasePlugin) GetConfig ¶
func (bp *BasePlugin) GetConfig(key string) (interface{}, bool)
GetConfig 获取配置项
type ComponentInterface ¶
type ComponentInterface interface {
Named
Typed
Enableable
}
ComponentInterface 组件基础接口 - 组合核心基础功能
type Config ¶
Config 通用配置接口
func (Config) Bind ¶ added in v0.1.1
Bind 将通用 Config 映射到强类型结构体或其他合法的 JSON 目标对象。
它通过标准库的 JSON 编解码器完成类型转换,避免在业务代码中散布显式的类型断言。 使用示例:
var opts struct {
Endpoint string `json:"endpoint"`
Timeout time.Duration `json:"timeout"`
}
if err := cfg.Bind(&opts); err != nil { ... }
任何实现了 json.Unmarshaler / encoding.TextUnmarshaler 的类型,都会被透明支持。
type Configurable ¶
type Configurable interface {
// Configure 配置组件
Configure(config Config) error
// GetConfig 获取当前配置(可选实现)
GetConfig() Config
}
Configurable 可配置接口 - 只负责配置管理
type ConfigurableComponent ¶
type ConfigurableComponent struct {
*BaseComponent
// contains filtered or unexported fields
}
ConfigurableComponent 可配置组件
func NewConfigurableComponent ¶
func NewConfigurableComponent(name string, moduleType ModuleType) *ConfigurableComponent
NewConfigurableComponent 创建可配置组件
func (*ConfigurableComponent) Configure ¶
func (cc *ConfigurableComponent) Configure(config Config) error
Configure 实现Configurable接口
func (*ConfigurableComponent) GetConfig ¶
func (cc *ConfigurableComponent) GetConfig() Config
GetConfig 实现Configurable接口
type ConfigurableModule ¶
type ConfigurableModule interface {
ComponentInterface
Configurable
}
ConfigurableModule 可配置模块接口
type ConfigurablePlugin ¶
type ConfigurablePlugin interface {
Plugin
// Configure 配置插件
Configure(config map[string]interface{}) error
// GetConfig 获取配置项
GetConfig(key string) (interface{}, bool)
}
ConfigurablePlugin 可配置插件接口
type Disposable ¶
type Disposable interface {
// Dispose 释放资源
Dispose() error
// IsDisposed 检查是否已释放
IsDisposed() bool
}
Disposable 可释放接口 - 只负责资源清理
type Enableable ¶
type Enableable interface {
// Enabled 返回组件是否启用
Enabled() bool
// Enable 启用组件
Enable()
// Disable 禁用组件
Disable()
}
Enableable 可启用接口 - 只负责启用状态管理
type ExampleFormatterPlugin ¶
type ExampleFormatterPlugin struct {
*BasePlugin
// contains filtered or unexported fields
}
ExampleFormatterPlugin 示例格式化器插件 演示如何将旧的Module转换为新的Plugin
func NewExampleFormatterPlugin ¶
func NewExampleFormatterPlugin(name string, priority int) *ExampleFormatterPlugin
NewExampleFormatterPlugin 创建示例格式化器插件
func (*ExampleFormatterPlugin) Handler ¶
func (efp *ExampleFormatterPlugin) Handler() slog.Handler
Handler 实现HandlerPlugin接口
func (*ExampleFormatterPlugin) Priority ¶
func (efp *ExampleFormatterPlugin) Priority() int
Priority 实现PrioritizedPlugin接口
func (*ExampleFormatterPlugin) SetHandler ¶
func (efp *ExampleFormatterPlugin) SetHandler(handler slog.Handler)
SetHandler 设置处理器
type Formatter ¶
type Formatter interface {
// Format 格式化数据
Format(data interface{}) ([]byte, error)
// MimeType 返回格式化后的MIME类型
MimeType() string
}
Formatter 格式化器接口 - 只负责数据格式化
type FormatterModule ¶
type FormatterModule interface {
ComponentInterface
Formatter
}
FormatterModule 格式化器模块接口
type FormatterProvider ¶ added in v0.1.2
type FormatterProvider interface {
// FormatterFunctions 返回一组与 slog.Handler ReplaceAttr 兼容的格式化函数。
FormatterFunctions() []func([]string, slog.Attr) (slog.Value, bool)
}
FormatterProvider 提供格式化函数,避免使用反射适配。
type FullModule ¶
type FullModule interface {
ComponentInterface
Configurable
Prioritized
HandlerProvider
}
FullModule 完整模块接口 - 包含所有基础功能
type HandlerComponent ¶
type HandlerComponent struct {
*ConfigurableComponent
// contains filtered or unexported fields
}
HandlerComponent 处理器组件
func NewHandlerComponent ¶
func NewHandlerComponent(name string, moduleType ModuleType, handler slog.Handler) *HandlerComponent
NewHandlerComponent 创建处理器组件
func (*HandlerComponent) Handler ¶
func (hc *HandlerComponent) Handler() slog.Handler
Handler 实现HandlerProvider接口
func (*HandlerComponent) SetHandler ¶
func (hc *HandlerComponent) SetHandler(handler slog.Handler)
SetHandler 实现HandlerProvider接口
type HandlerModule ¶
type HandlerModule interface {
ComponentInterface
HandlerProvider
}
HandlerModule 处理器模块接口
type HandlerPlugin ¶
HandlerPlugin 处理器插件接口
type HandlerProvider ¶
type HandlerProvider interface {
// Handler 返回slog处理器
Handler() slog.Handler
// SetHandler 设置slog处理器
SetHandler(handler slog.Handler)
}
HandlerProvider 处理器提供者接口 - 只负责提供slog处理器
type Healthable ¶
type Healthable interface {
// HealthCheck 执行健康检查
HealthCheck() error
// IsHealthy 检查是否健康
IsHealthy() bool
}
Healthable 健康检查接口 - 只负责健康状态
type Initializable ¶
type Initializable interface {
// Initialize 初始化组件
Initialize() error
// IsInitialized 检查是否已初始化
IsInitialized() bool
}
Initializable 可初始化接口 - 只负责初始化
type InterfaceChecker ¶
type InterfaceChecker struct{}
InterfaceChecker 接口检查工具
func (*InterfaceChecker) CheckConfigurable ¶
func (ic *InterfaceChecker) CheckConfigurable(obj interface{}) (Configurable, bool)
CheckConfigurable 检查是否实现Configurable接口
func (*InterfaceChecker) CheckEnableable ¶
func (ic *InterfaceChecker) CheckEnableable(obj interface{}) (Enableable, bool)
CheckEnableable 检查是否实现Enableable接口
func (*InterfaceChecker) CheckFullModule ¶
func (ic *InterfaceChecker) CheckFullModule(obj interface{}) (FullModule, bool)
CheckFullModule 检查是否实现FullModule接口
func (*InterfaceChecker) CheckHandlerProvider ¶
func (ic *InterfaceChecker) CheckHandlerProvider(obj interface{}) (HandlerProvider, bool)
CheckHandlerProvider 检查是否实现HandlerProvider接口
func (*InterfaceChecker) CheckNamed ¶
func (ic *InterfaceChecker) CheckNamed(obj interface{}) (Named, bool)
CheckNamed 检查是否实现Named接口
func (*InterfaceChecker) CheckTyped ¶
func (ic *InterfaceChecker) CheckTyped(obj interface{}) (Typed, bool)
CheckTyped 检查是否实现Typed接口
func (*InterfaceChecker) GetImplementedInterfaces ¶
func (ic *InterfaceChecker) GetImplementedInterfaces(obj interface{}) []string
GetImplementedInterfaces 获取对象实现的所有接口列表
type LegacyModuleWrapper ¶
type LegacyModuleWrapper struct {
// contains filtered or unexported fields
}
LegacyModuleWrapper 旧模块包装器 将旧的Module接口适配到新的接口系统
func NewLegacyModuleWrapper ¶
func NewLegacyModuleWrapper(module Module) *LegacyModuleWrapper
NewLegacyModuleWrapper 创建旧模块包装器
func (*LegacyModuleWrapper) Configure ¶
func (lmw *LegacyModuleWrapper) Configure(config Config) error
Configure 实现Configurable接口
func (*LegacyModuleWrapper) Disable ¶
func (lmw *LegacyModuleWrapper) Disable()
Disable 实现Enableable接口
func (*LegacyModuleWrapper) Enabled ¶
func (lmw *LegacyModuleWrapper) Enabled() bool
Enabled 实现Enableable接口
func (*LegacyModuleWrapper) GetConfig ¶
func (lmw *LegacyModuleWrapper) GetConfig() Config
GetConfig 实现Configurable接口
func (*LegacyModuleWrapper) Handler ¶
func (lmw *LegacyModuleWrapper) Handler() slog.Handler
Handler 实现HandlerProvider接口
func (*LegacyModuleWrapper) Priority ¶
func (lmw *LegacyModuleWrapper) Priority() int
Priority 实现Prioritized接口
func (*LegacyModuleWrapper) SetHandler ¶
func (lmw *LegacyModuleWrapper) SetHandler(handler slog.Handler)
SetHandler 实现HandlerProvider接口
func (*LegacyModuleWrapper) SetPriority ¶
func (lmw *LegacyModuleWrapper) SetPriority(priority int)
SetPriority 实现Prioritized接口
type LifecycleComponent ¶
type LifecycleComponent struct {
*HandlerComponent
// contains filtered or unexported fields
}
LifecycleComponent 生命周期组件
func NewLifecycleComponent ¶
func NewLifecycleComponent(name string, moduleType ModuleType, handler slog.Handler) *LifecycleComponent
NewLifecycleComponent 创建生命周期组件
func (*LifecycleComponent) Dispose ¶
func (lc *LifecycleComponent) Dispose() error
Dispose 实现Disposable接口
func (*LifecycleComponent) Initialize ¶
func (lc *LifecycleComponent) Initialize() error
Initialize 实现Initializable接口
func (*LifecycleComponent) IsDisposed ¶
func (lc *LifecycleComponent) IsDisposed() bool
IsDisposed 实现Disposable接口
func (*LifecycleComponent) IsInitialized ¶
func (lc *LifecycleComponent) IsInitialized() bool
IsInitialized 实现Initializable接口
func (*LifecycleComponent) IsRunning ¶
func (lc *LifecycleComponent) IsRunning() bool
IsRunning 实现Startable接口
type ManagedModule ¶
type ManagedModule interface {
FullModule
Initializable
Startable
Disposable
}
ManagedModule 托管模块接口 - 包含生命周期管理
type Measurable ¶
type Measurable interface {
// GetMetrics 获取性能指标
GetMetrics() map[string]interface{}
// ResetMetrics 重置性能指标
ResetMetrics()
}
Measurable 可度量接口 - 只负责性能指标
type Middleware ¶
type Middleware interface {
// Handle 中间件处理函数
Handle(next func()) func()
// Order 中间件执行顺序
Order() int
}
Middleware 中间件接口 - 只负责中间件逻辑
type MiddlewareModule ¶
type MiddlewareModule interface {
ComponentInterface
Middleware
}
MiddlewareModule 中间件模块接口
type MigrationAdapter ¶
type MigrationAdapter struct {
// contains filtered or unexported fields
}
MigrationAdapter 迁移适配器:帮助平滑迁移
func (*MigrationAdapter) WrapOldModule ¶
func (ma *MigrationAdapter) WrapOldModule(module Module) Plugin
WrapOldModule 将旧的Module包装为Plugin
type MigrationExample ¶
type MigrationExample struct{}
MigrationExample 展示如何从旧的Module系统迁移到新的Plugin系统
type Module ¶
type Module interface {
// Name 返回模块名称
Name() string
// Type 返回模块类型
Type() ModuleType
// Configure 配置模块
Configure(config Config) error
// Handler 返回slog处理器
Handler() slog.Handler
// Priority 返回优先级,数字越小优先级越高
Priority() int
// Enabled 返回模块是否启用
Enabled() bool
}
Module 定义模块接口
func CreateModule ¶
CreateModule 全局创建模块
type ModuleAdapter ¶
type ModuleAdapter struct {
// contains filtered or unexported fields
}
ModuleAdapter 模块适配器,帮助将旧接口转换为新接口
func NewModuleAdapter ¶
func NewModuleAdapter(module Module) *ModuleAdapter
NewModuleAdapter 创建模块适配器
func (*ModuleAdapter) AsConfigurable ¶
func (ma *ModuleAdapter) AsConfigurable() Configurable
AsConfigurable 转换为Configurable接口
func (*ModuleAdapter) AsEnableable ¶
func (ma *ModuleAdapter) AsEnableable() Enableable
AsEnableable 转换为Enableable接口
func (*ModuleAdapter) AsHandlerProvider ¶
func (ma *ModuleAdapter) AsHandlerProvider() HandlerProvider
AsHandlerProvider 转换为HandlerProvider接口
func (*ModuleAdapter) AsPrioritized ¶
func (ma *ModuleAdapter) AsPrioritized() Prioritized
AsPrioritized 转换为Prioritized接口
type ModuleConfig ¶
type ModuleConfig struct {
Type string `json:"type"`
Name string `json:"name"`
Enabled bool `json:"enabled"`
Priority int `json:"priority"`
Config Config `json:"config"`
}
ModuleConfig 模块配置
type ModuleType ¶
type ModuleType int
ModuleType 定义模块类型
const ( TypeFormatter ModuleType = iota // 格式化器 TypeHandler // 处理器 TypeMiddleware // 中间件 TypeSink // 日志接收器 )
func (ModuleType) String ¶
func (mt ModuleType) String() string
type MonitoredComponent ¶
type MonitoredComponent struct {
*LifecycleComponent
// contains filtered or unexported fields
}
MonitoredComponent 被监控的组件
func NewMonitoredComponent ¶
func NewMonitoredComponent(name string, moduleType ModuleType, handler slog.Handler) *MonitoredComponent
NewMonitoredComponent 创建被监控的组件
func (*MonitoredComponent) AddMetric ¶
func (mc *MonitoredComponent) AddMetric(key string, value interface{})
AddMetric 添加自定义指标
func (*MonitoredComponent) GetMetrics ¶
func (mc *MonitoredComponent) GetMetrics() map[string]interface{}
GetMetrics 实现Measurable接口
func (*MonitoredComponent) HealthCheck ¶
func (mc *MonitoredComponent) HealthCheck() error
HealthCheck 实现Healthable接口
func (*MonitoredComponent) IsHealthy ¶
func (mc *MonitoredComponent) IsHealthy() bool
IsHealthy 实现Healthable接口
func (*MonitoredComponent) ResetMetrics ¶
func (mc *MonitoredComponent) ResetMetrics()
ResetMetrics 实现Measurable接口
type MonitoredModule ¶
type MonitoredModule interface {
FullModule
Healthable
Measurable
}
MonitoredModule 被监控的模块接口 - 包含监控功能
type OldModuleWrapper ¶
type OldModuleWrapper struct {
*BasePlugin
// contains filtered or unexported fields
}
OldModuleWrapper 旧模块包装器
func (*OldModuleWrapper) Configure ¶
func (omw *OldModuleWrapper) Configure(config map[string]interface{}) error
Configure 配置包装器
func (*OldModuleWrapper) Handler ¶
func (omw *OldModuleWrapper) Handler() slog.Handler
Handler 获取处理器
type Plugin ¶
type Plugin interface {
// Name 返回插件名称
Name() string
// Enabled 检查插件是否启用
Enabled() bool
// Enable 启用插件
Enable()
// Disable 禁用插件
Disable()
}
Plugin 简化的插件接口 - 单一职责原则
func GetGlobalPluginsByType ¶
func GetGlobalPluginsByType(pluginType PluginType) []Plugin
GetGlobalPluginsByType 全局获取指定类型的插件
type PluginInfo ¶
type PluginInfo struct {
Name string `json:"name"`
Type PluginType `json:"type"`
Enabled bool `json:"enabled"`
Priority int `json:"priority"`
Config map[string]interface{} `json:"config,omitempty"`
}
PluginInfo 插件信息
type PluginManager ¶
type PluginManager struct {
// contains filtered or unexported fields
}
PluginManager 简化的插件管理器
func GetGlobalPluginManager ¶
func GetGlobalPluginManager() *PluginManager
GetGlobalPluginManager 获取全局插件管理器
func (*PluginManager) DisablePlugin ¶
func (pm *PluginManager) DisablePlugin(name string) error
DisablePlugin 禁用指定插件
func (*PluginManager) EnablePlugin ¶
func (pm *PluginManager) EnablePlugin(name string) error
EnablePlugin 启用指定插件
func (*PluginManager) GetPlugin ¶
func (pm *PluginManager) GetPlugin(name string) (Plugin, bool)
GetPlugin 获取指定名称的插件
func (*PluginManager) GetPluginsByType ¶
func (pm *PluginManager) GetPluginsByType(pluginType PluginType) []Plugin
GetPluginsByType 获取指定类型的所有插件(按优先级排序)
func (*PluginManager) ListPlugins ¶
func (pm *PluginManager) ListPlugins() []string
ListPlugins 列出所有插件名称
func (*PluginManager) RegisterPlugin ¶
func (pm *PluginManager) RegisterPlugin(plugin Plugin, pluginType PluginType) error
RegisterPlugin 注册插件
func (*PluginManager) UnregisterPlugin ¶
func (pm *PluginManager) UnregisterPlugin(name string) error
UnregisterPlugin 注销插件
type PluginStats ¶
type PluginStats struct {
TotalPlugins int `json:"total_plugins"`
EnabledPlugins int `json:"enabled_plugins"`
TypeCounts map[PluginType]int `json:"type_counts"`
PluginInfo map[string]PluginInfo `json:"plugin_info"`
}
PluginStats 插件统计信息
type PluginType ¶
type PluginType string
PluginType 插件类型枚举
const ( PluginFormatter PluginType = "formatter" PluginHandler PluginType = "handler" PluginMiddleware PluginType = "middleware" PluginSink PluginType = "sink" )
type Prioritized ¶
type Prioritized interface {
// Priority 返回优先级,数字越小优先级越高
Priority() int
// SetPriority 设置优先级
SetPriority(priority int)
}
Prioritized 优先级接口 - 只负责优先级管理
type PrioritizedModule ¶
type PrioritizedModule interface {
ComponentInterface
Prioritized
}
PrioritizedModule 有优先级的模块接口
type PrioritizedPlugin ¶
PrioritizedPlugin 有优先级的插件接口
type Processor ¶
type Processor interface {
// Process 处理数据
Process(data interface{}) (interface{}, error)
}
Processor 处理器接口 - 只负责数据处理
type ProcessorModule ¶
type ProcessorModule interface {
ComponentInterface
Processor
}
ProcessorModule 处理器模块接口
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry 模块注册中心
func (*Registry) GetByType ¶
func (r *Registry) GetByType(moduleType ModuleType) []Module
GetByType 按类型获取模块列表
func (*Registry) ListFactories ¶
ListFactories 列出所有已注册的工厂名称
func (*Registry) RegisterFactory ¶
func (r *Registry) RegisterFactory(name string, factory ModuleFactory) error
RegisterFactory 注册模块工厂
type SimpleFormatter ¶
type SimpleFormatter struct {
*BaseComponent
}
SimpleFormatter 简单格式化器实现
func NewSimpleFormatter ¶
func NewSimpleFormatter(name string) *SimpleFormatter
NewSimpleFormatter 创建简单格式化器
func (*SimpleFormatter) Format ¶
func (sf *SimpleFormatter) Format(data interface{}) ([]byte, error)
Format 实现Formatter接口
func (*SimpleFormatter) MimeType ¶
func (sf *SimpleFormatter) MimeType() string
MimeType 实现Formatter接口
type SimpleProcessor ¶
type SimpleProcessor struct {
*BaseComponent
}
SimpleProcessor 简单处理器实现
func NewSimpleProcessor ¶
func NewSimpleProcessor(name string) *SimpleProcessor
NewSimpleProcessor 创建简单处理器
func (*SimpleProcessor) Process ¶
func (sp *SimpleProcessor) Process(data interface{}) (interface{}, error)
Process 实现Processor接口
type Sink ¶
type Sink interface {
// Write 写入数据
Write(data []byte) (int, error)
// Flush 刷新缓冲区
Flush() error
// Close 关闭接收器
Close() error
}
Sink 数据接收器接口 - 只负责数据输出
type Startable ¶
type Startable interface {
// Start 启动组件
Start() error
// Stop 停止组件
Stop() error
// IsRunning 检查是否正在运行
IsRunning() bool
}
Startable 可启动接口 - 只负责启动/停止
type WriteSyncer ¶ added in v0.1.3
WriteSyncer 兼容 io.Writer,用于输出 handler。