MCPcopy Create free account
hub / github.com/cortexproject/cortex / ReadVisitMarker

Method ReadVisitMarker

pkg/compactor/visit_marker.go:119–138  ·  view source on GitHub ↗
(ctx context.Context, visitMarker any)

Source from the content-addressed store, hash-verified

117}
118
119func (v *VisitMarkerManager) ReadVisitMarker(ctx context.Context, visitMarker any) error {
120 visitMarkerFile := v.visitMarker.GetVisitMarkerFilePath()
121 visitMarkerFileReader, err := v.bkt.ReaderWithExpectedErrs(v.bkt.IsObjNotFoundErr).Get(ctx, visitMarkerFile)
122 if err != nil {
123 if v.bkt.IsObjNotFoundErr(err) {
124 return errors.Wrapf(errorVisitMarkerNotFound, "visit marker file: %s", visitMarkerFile)
125 }
126 return errors.Wrapf(err, "get visit marker file: %s", visitMarkerFile)
127 }
128 defer runutil.CloseWithLogOnErr(v.getLogger(), visitMarkerFileReader, "close visit marker reader")
129 b, err := io.ReadAll(visitMarkerFileReader)
130 if err != nil {
131 return errors.Wrapf(err, "read visit marker file: %s", visitMarkerFile)
132 }
133 if err = json.Unmarshal(b, visitMarker); err != nil {
134 return errors.Wrapf(errorUnmarshalVisitMarker, "visit marker file: %s, content: %s, error: %v", visitMarkerFile, string(b), err.Error())
135 }
136 level.Debug(v.getLogger()).Log("msg", "visit marker read from file", "visit_marker_file", visitMarkerFile)
137 return nil
138}
139
140func (v *VisitMarkerManager) updateVisitMarker(ctx context.Context) error {
141 visitMarkerFileContent, err := json.Marshal(v.visitMarker)

Callers 9

TestMarkPendingFunction · 0.95
TestMarkInProgressFunction · 0.95
TestMarkCompletedFunction · 0.95
TestHeartBeatFunction · 0.95
PlanWithPartitionMethod · 0.95
isGroupVisitedMethod · 0.80

Calls 9

getLoggerMethod · 0.95
CloseWithLogOnErrFunction · 0.92
GetMethod · 0.65
IsObjNotFoundErrMethod · 0.45
UnmarshalMethod · 0.45
ErrorMethod · 0.45
LogMethod · 0.45

Tested by 5

TestMarkPendingFunction · 0.76
TestMarkInProgressFunction · 0.76
TestMarkCompletedFunction · 0.76
TestHeartBeatFunction · 0.76