getCachedDurableMessages returns cached durable messages with IDs greater than afterID. Returns nil when the cache has no relevant entries.
( chatID uuid.UUID, afterID int64, )
| 4602 | // greater than afterID. Returns nil when the cache has no relevant |
| 4603 | // entries. |
| 4604 | func (p *Server) getCachedDurableMessages( |
| 4605 | chatID uuid.UUID, |
| 4606 | afterID int64, |
| 4607 | ) []codersdk.ChatStreamEvent { |
| 4608 | state := p.getOrCreateStreamState(chatID) |
| 4609 | state.mu.Lock() |
| 4610 | defer state.mu.Unlock() |
| 4611 | |
| 4612 | if afterID < state.durableEvictedBefore { |
| 4613 | return nil |
| 4614 | } |
| 4615 | |
| 4616 | var result []codersdk.ChatStreamEvent |
| 4617 | for _, event := range state.durableMessages { |
| 4618 | if event.Message != nil && event.Message.ID > afterID { |
| 4619 | result = append(result, event) |
| 4620 | } |
| 4621 | } |
| 4622 | return result |
| 4623 | } |
| 4624 | |
| 4625 | // snapshotBufferLocked returns the buffered message_part events that |
| 4626 | // the caller should receive in their initial snapshot. |
no test coverage detected