MCPcopy Index your code
hub / github.com/coder/coder / getCachedDurableMessages

Method getCachedDurableMessages

coderd/x/chatd/chatd.go:4604–4623  ·  view source on GitHub ↗

getCachedDurableMessages returns cached durable messages with IDs greater than afterID. Returns nil when the cache has no relevant entries.

(
	chatID uuid.UUID,
	afterID int64,
)

Source from the content-addressed store, hash-verified

4602// greater than afterID. Returns nil when the cache has no relevant
4603// entries.
4604func (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.

Callers 1

SubscribeAuthorizedMethod · 0.95

Calls 3

LockMethod · 0.45
UnlockMethod · 0.45

Tested by

no test coverage detected