MCPcopy Index your code
hub / github.com/docker/docker-agent / UpdateMessage

Method UpdateMessage

pkg/session/store.go:288–313  ·  view source on GitHub ↗

UpdateMessage updates an existing message by its ID.

(_ context.Context, messageID int64, msg *Message)

Source from the content-addressed store, hash-verified

286
287// UpdateMessage updates an existing message by its ID.
288func (s *InMemorySessionStore) UpdateMessage(_ context.Context, messageID int64, msg *Message) error {
289 // Create a deep copy of the message to avoid mutating the caller's pointer,
290 // which may be shared with another Session object.
291 updated := cloneMessage(msg)
292 updated.ID = messageID
293
294 // For in-memory store, we need to find the message across all sessions
295 var found bool
296 s.sessions.Range(func(_ string, session *Session) bool {
297 session.mu.Lock()
298 defer session.mu.Unlock()
299 for i := range session.Messages {
300 if session.Messages[i].Message == nil || session.Messages[i].Message.ID != messageID {
301 continue
302 }
303 session.Messages[i].Message = updated
304 found = true
305 return false
306 }
307 return true
308 })
309 if !found {
310 return ErrNotFound
311 }
312 return nil
313}
314
315// AddSubSession creates a sub-session and links it to the parent.
316func (s *InMemorySessionStore) AddSubSession(_ context.Context, parentSessionID string, subSession *Session) error {

Callers

nothing calls this directly

Calls 4

cloneMessageFunction · 0.85
RangeMethod · 0.45
LockMethod · 0.45
UnlockMethod · 0.45

Tested by

no test coverage detected