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

Method GetTimelineRange

pkg/events/bus.go:498–517  ·  view source on GitHub ↗

GetTimelineRange 获取指定范围的时间线(基于索引)

(start, limit int)

Source from the content-addressed store, hash-verified

496
497// GetTimelineRange 获取指定范围的时间线(基于索引)
498func (eb *EventBus) GetTimelineRange(start, limit int) []types.AgentEventEnvelope {
499 eb.mu.RLock()
500 defer eb.mu.RUnlock()
501
502 if start < 0 {
503 start = 0
504 }
505 if start >= len(eb.timeline) {
506 return []types.AgentEventEnvelope{}
507 }
508
509 end := start + limit
510 if limit <= 0 || end > len(eb.timeline) {
511 end = len(eb.timeline)
512 }
513
514 result := make([]types.AgentEventEnvelope, end-start)
515 copy(result, eb.timeline[start:end])
516 return result
517}
518
519// GetTimelineSince 获取指定 cursor 之后的所有事件
520func (eb *EventBus) GetTimelineSince(cursor int64) []types.AgentEventEnvelope {

Callers 2

TestGetTimelineRangeFunction · 0.95
GetRecentEventsMethod · 0.80

Calls 1

copyFunction · 0.85

Tested by 1

TestGetTimelineRangeFunction · 0.76