Documentation
¶
Index ¶
- type EventBus
- func (eb *EventBus) Clear()
- func (eb *EventBus) Close()
- func (eb *EventBus) EmitControl(event any) types.AgentEventEnvelope
- func (eb *EventBus) EmitMonitor(event any) types.AgentEventEnvelope
- func (eb *EventBus) EmitProgress(event any) types.AgentEventEnvelope
- func (eb *EventBus) GetCursor() int64
- func (eb *EventBus) GetLastBookmark() *types.Bookmark
- func (eb *EventBus) GetTimeline() []types.AgentEventEnvelope
- func (eb *EventBus) GetTimelineCount() int
- func (eb *EventBus) GetTimelineFiltered(filter func(types.AgentEventEnvelope) bool) []types.AgentEventEnvelope
- func (eb *EventBus) GetTimelineRange(start, limit int) []types.AgentEventEnvelope
- func (eb *EventBus) GetTimelineSince(cursor int64) []types.AgentEventEnvelope
- func (eb *EventBus) OnControl(eventType string, handler EventHandler) func()
- func (eb *EventBus) OnMonitor(eventType string, handler EventHandler) func()
- func (eb *EventBus) Subscribe(channels []types.AgentChannel, opts *types.SubscribeOptions) <-chan types.AgentEventEnvelope
- func (eb *EventBus) Unsubscribe(ch <-chan types.AgentEventEnvelope)
- type EventBusConfig
- type EventHandler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EventBus ¶
type EventBus struct {
// contains filtered or unexported fields
}
EventBus 三通道事件总线
func NewEventBusWithConfig ¶ added in v0.25.0
func NewEventBusWithConfig(config *EventBusConfig) *EventBus
NewEventBusWithConfig 创建带配置的事件总线
func (*EventBus) EmitControl ¶
func (eb *EventBus) EmitControl(event any) types.AgentEventEnvelope
EmitControl 发送Control事件
func (*EventBus) EmitMonitor ¶
func (eb *EventBus) EmitMonitor(event any) types.AgentEventEnvelope
EmitMonitor 发送Monitor事件
func (*EventBus) EmitProgress ¶
func (eb *EventBus) EmitProgress(event any) types.AgentEventEnvelope
EmitProgress 发送Progress事件
func (*EventBus) GetLastBookmark ¶
GetLastBookmark 获取最后一个bookmark
func (*EventBus) GetTimeline ¶
func (eb *EventBus) GetTimeline() []types.AgentEventEnvelope
GetTimeline 获取完整时间线(不推荐用于大量事件,请使用 GetTimelineRange)
func (*EventBus) GetTimelineCount ¶ added in v0.25.0
GetTimelineCount 获取当前时间线事件数量
func (*EventBus) GetTimelineFiltered ¶ added in v0.25.0
func (eb *EventBus) GetTimelineFiltered(filter func(types.AgentEventEnvelope) bool) []types.AgentEventEnvelope
GetTimelineFiltered 获取过滤后的时间线
func (*EventBus) GetTimelineRange ¶ added in v0.25.0
func (eb *EventBus) GetTimelineRange(start, limit int) []types.AgentEventEnvelope
GetTimelineRange 获取指定范围的时间线(基于索引)
func (*EventBus) GetTimelineSince ¶ added in v0.25.0
func (eb *EventBus) GetTimelineSince(cursor int64) []types.AgentEventEnvelope
GetTimelineSince 获取指定 cursor 之后的所有事件
func (*EventBus) OnControl ¶
func (eb *EventBus) OnControl(eventType string, handler EventHandler) func()
OnControl 注册Control事件处理器
func (*EventBus) OnMonitor ¶
func (eb *EventBus) OnMonitor(eventType string, handler EventHandler) func()
OnMonitor 注册Monitor事件处理器
func (*EventBus) Subscribe ¶
func (eb *EventBus) Subscribe(channels []types.AgentChannel, opts *types.SubscribeOptions) <-chan types.AgentEventEnvelope
Subscribe 订阅指定通道的事件(返回channel)
func (*EventBus) Unsubscribe ¶
func (eb *EventBus) Unsubscribe(ch <-chan types.AgentEventEnvelope)
Unsubscribe 取消订阅
type EventBusConfig ¶ added in v0.25.0
type EventBusConfig struct {
MaxTimelineSize int // 最大事件数 (默认 10000)
MaxTimelineAge time.Duration // 最大事件年龄 (默认 1小时)
CleanupInterval time.Duration // 清理间隔 (默认 5分钟)
EnableArchive bool // 是否启用归档 (预留)
}
EventBusConfig 事件总线配置
func DefaultEventBusConfig ¶ added in v0.25.0
func DefaultEventBusConfig() *EventBusConfig
DefaultEventBusConfig 默认配置
Click to show internal directories.
Click to hide internal directories.