MCPcopy Index your code
hub / github.com/dagger/dagger / WriteDebugCacheSnapshot

Method WriteDebugCacheSnapshot

dagql/cache_debug.go:1066–1586  ·  view source on GitHub ↗

nolint:gocyclo // intrinsically long state machine; refactoring would hurt clarity

(w io.Writer)

Source from the content-addressed store, hash-verified

1064
1065//nolint:gocyclo // intrinsically long state machine; refactoring would hurt clarity
1066func (c *Cache) WriteDebugCacheSnapshot(w io.Writer) error {
1067 sessionResults := c.debugSessionResultsSnapshot()
1068 c.callsMu.Lock()
1069 c.egraphMu.RLock()
1070 defer c.egraphMu.RUnlock()
1071 defer c.callsMu.Unlock()
1072
1073 bw := bufio.NewWriterSize(w, 128<<10)
1074
1075 writeValue := func(v any) error {
1076 bs, err := json.Marshal(v)
1077 if err != nil {
1078 return err
1079 }
1080 _, err = bw.Write(bs)
1081 return err
1082 }
1083
1084 topFieldCount := 0
1085 writeField := func(name string) error {
1086 if topFieldCount > 0 {
1087 if _, err := bw.WriteString(","); err != nil {
1088 return err
1089 }
1090 }
1091 topFieldCount++
1092 if err := writeValue(name); err != nil {
1093 return err
1094 }
1095 _, err := bw.WriteString(":")
1096 return err
1097 }
1098
1099 writeArrayField := func(name string, writeElems func(func(any) error) error) error {
1100 if err := writeField(name); err != nil {
1101 return err
1102 }
1103 if _, err := bw.WriteString("["); err != nil {
1104 return err
1105 }
1106 elemCount := 0
1107 if err := writeElems(func(v any) error {
1108 if elemCount > 0 {
1109 if _, err := bw.WriteString(","); err != nil {
1110 return err
1111 }
1112 }
1113 elemCount++
1114 return writeValue(v)
1115 }); err != nil {
1116 return err
1117 }
1118 _, err := bw.WriteString("]")
1119 return err
1120 }
1121
1122 if _, err := bw.WriteString("{"); err != nil {
1123 return err

Calls 15

findEqClassLockedMethod · 0.95
loadPayloadStateMethod · 0.80
loadResultCallMethod · 0.80
deriveRecipeDigestMethod · 0.80
MarshalMethod · 0.65
WriteMethod · 0.65