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

Method AttachRuntime

pkg/server/session_manager.go:205–214  ·  view source on GitHub ↗

AttachRuntime registers a pre-built runtime + session under sessionID so that subsequent calls (RunSession, Steer, Resume...) reuse it instead of building one from agentFilename. This is what lets a single in-process runtime be shared between the TUI and an HTTP control plane. The internal cancella

(ctx context.Context, sessionID string, rt runtime.Runtime, sess *session.Session)

Source from the content-addressed store, hash-verified

203// SSE streams and other lifetime-bound consumers use it (via
204// [SessionManager.StreamEvents]) to terminate when the session is detached.
205func (sm *SessionManager) AttachRuntime(ctx context.Context, sessionID string, rt runtime.Runtime, sess *session.Session) {
206 ctx, cancel := context.WithCancel(context.WithoutCancel(ctx))
207 sm.runtimeSessions.Store(sessionID, &activeRuntimes{
208 runtime: rt,
209 done: ctx.Done(),
210 cancel: cancel,
211 session: sess,
212 })
213 sm.markReady()
214}
215
216// GetSession retrieves a session by ID.
217func (sm *SessionManager) GetSession(ctx context.Context, id string) (*session.Session, error) {

Calls 2

markReadyMethod · 0.95
StoreMethod · 0.45