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

Method ready

pkg/server/server.go:821–866  ·  view source on GitHub ↗
(c echo.Context)

Source from the content-addressed store, hash-verified

819}
820
821func (s *Server) ready(c echo.Context) error {
822 // Check if session store is accessible (quick connectivity check)
823 ctx, cancel := context.WithTimeout(c.Request().Context(), 100*time.Millisecond)
824 defer cancel()
825
826 sessions, err := s.sm.GetSessions(ctx)
827 var storeConnected bool
828 if err == nil || errors.Is(err, context.DeadlineExceeded) {
829 // We assume store is connected if we can query it or we hit a timeout
830 // (timeout is still better than a hard connection failure)
831 storeConnected = true
832 }
833
834 activeSessions := 0
835 if sessions != nil {
836 activeSessions = len(sessions)
837 }
838
839 var toolsetHealth string
840 var latestError string
841
842 // Determine overall readiness
843 ready := storeConnected
844 if !ready {
845 latestError = "store disconnected"
846 }
847
848 status := http.StatusOK
849 if !ready {
850 status = http.StatusServiceUnavailable
851 }
852
853 if !ready {
854 toolsetHealth = "unavailable"
855 } else {
856 toolsetHealth = "ok"
857 }
858
859 return c.JSON(status, api.ReadyResponse{
860 Ready: ready,
861 ActiveSessions: activeSessions,
862 StoreConnected: storeConnected,
863 ToolsetHealth: toolsetHealth,
864 LatestError: latestError,
865 })
866}
867
868func (s *Server) getSessionRecoveryData(c echo.Context) error {
869 sessionID := c.Param("id")

Callers

nothing calls this directly

Calls 2

ContextMethod · 0.80
GetSessionsMethod · 0.65

Tested by

no test coverage detected