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

Method getSessionStatus

pkg/server/server.go:300–316  ·  view source on GitHub ↗

getSessionStatus returns the session's current runtime state. With ?wait= it blocks until the session's runtime is attached (ready to accept follow-ups and produce events) before responding, so a client that just launched a run can wait for that exact session instead of polling.

(c echo.Context)

Source from the content-addressed store, hash-verified

298// to accept follow-ups and produce events) before responding, so a client
299// that just launched a run can wait for that exact session instead of polling.
300func (s *Server) getSessionStatus(c echo.Context) error {
301 if v := c.QueryParam("wait"); v != "" {
302 d, err := time.ParseDuration(v)
303 if err != nil {
304 return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("invalid wait: %v", err))
305 }
306 if !s.sm.WaitSessionAttached(c.Request().Context(), c.Param("id"), min(d, maxAPITimeout)) {
307 return echo.NewHTTPError(http.StatusServiceUnavailable, "session not ready within timeout")
308 }
309 }
310
311 status, err := s.sm.GetSessionStatus(c.Request().Context(), c.Param("id"))
312 if err != nil {
313 return echo.NewHTTPError(http.StatusNotFound, fmt.Sprintf("session not found: %v", err))
314 }
315 return c.JSON(http.StatusOK, status)
316}
317
318// getSessionSnapshot returns the full state of a session in one response
319// (stored fields + live runtime state + last event sequence number) so a

Callers

nothing calls this directly

Calls 3

WaitSessionAttachedMethod · 0.80
ContextMethod · 0.80
GetSessionStatusMethod · 0.80

Tested by

no test coverage detected