MCPcopy Create free account
hub / github.com/astercloud/aster / NewEventBusWithConfig

Function NewEventBusWithConfig

pkg/events/bus.go:66–87  ·  view source on GitHub ↗

NewEventBusWithConfig 创建带配置的事件总线

(config *EventBusConfig)

Source from the content-addressed store, hash-verified

64
65// NewEventBusWithConfig 创建带配置的事件总线
66func NewEventBusWithConfig(config *EventBusConfig) *EventBus {
67 if config == nil {
68 config = DefaultEventBusConfig()
69 }
70
71 eb := &EventBus{
72 config: config,
73 timeline: make([]types.AgentEventEnvelope, 0, 1000),
74 bookmarks: make(map[int64]types.Bookmark),
75 progressSubs: make(map[string]chan types.AgentEventEnvelope),
76 controlSubs: make(map[string]chan types.AgentEventEnvelope),
77 monitorSubs: make(map[string]chan types.AgentEventEnvelope),
78 controlHandlers: make(map[string][]EventHandler),
79 monitorHandlers: make(map[string][]EventHandler),
80 cleanupDone: make(chan struct{}),
81 }
82
83 // 启动清理 worker
84 eb.startCleanupWorker()
85
86 return eb
87}
88
89// startCleanupWorker 启动后台清理协程
90func (eb *EventBus) startCleanupWorker() {

Callers 6

NewEventBusFunction · 0.85
TestCleanupBySizeFunction · 0.85
TestCleanupByAgeFunction · 0.85
TestAutoCleanupWorkerFunction · 0.85
TestMemoryStabilityFunction · 0.85

Calls 2

startCleanupWorkerMethod · 0.95
DefaultEventBusConfigFunction · 0.85

Tested by 5

TestCleanupBySizeFunction · 0.68
TestCleanupByAgeFunction · 0.68
TestAutoCleanupWorkerFunction · 0.68
TestMemoryStabilityFunction · 0.68