MCPcopy Create free account
hub / github.com/docker/docker-agent / WaitSessionAttached

Method WaitSessionAttached

pkg/server/session_manager.go:232–253  ·  view source on GitHub ↗

WaitSessionAttached blocks until a runtime is attached for sessionID (i.e. the session is ready to accept follow-ups and produce events), the timeout elapses, or ctx is cancelled. It returns true once the session is attached. Unlike WaitReady, which fires as soon as *any* session is ready, this is

(ctx context.Context, sessionID string, timeout time.Duration)

Source from the content-addressed store, hash-verified

230// session-scoped: a client that launched a specific run can wait for exactly
231// that session instead of racing the server's startup.
232func (sm *SessionManager) WaitSessionAttached(ctx context.Context, sessionID string, timeout time.Duration) bool {
233 if _, ok := sm.runtimeSessions.Load(sessionID); ok {
234 return true
235 }
236
237 ctx, cancel := context.WithTimeout(ctx, timeout)
238 defer cancel()
239
240 ticker := time.NewTicker(20 * time.Millisecond)
241 defer ticker.Stop()
242 for {
243 select {
244 case <-ctx.Done():
245 _, ok := sm.runtimeSessions.Load(sessionID)
246 return ok
247 case <-ticker.C:
248 if _, ok := sm.runtimeSessions.Load(sessionID); ok {
249 return true
250 }
251 }
252 }
253}
254
255// GetSessionStatus returns a lightweight snapshot of the session's current
256// runtime state. Designed for late-joining SSE consumers that need to know

Callers 1

getSessionStatusMethod · 0.80

Calls 2

LoadMethod · 0.80
StopMethod · 0.65

Tested by

no test coverage detected