MCPcopy
hub / github.com/grafana/tempo / flushWorkCacheToBackend

Method flushWorkCacheToBackend

modules/backendscheduler/cache.go:17–36  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

15)
16
17func (s *BackendScheduler) flushWorkCacheToBackend(ctx context.Context) error {
18 _, span := tracer.Start(ctx, "flushWorkCacheToBackend")
19 defer span.End()
20
21 s.mtx.Lock()
22 defer s.mtx.Unlock()
23
24 b, err := s.work.Marshal()
25 if err != nil {
26 metricWorkFlushesFailed.Inc()
27 return fmt.Errorf("failed to marshal work cache: %w", err)
28 }
29
30 err = s.writer.Write(ctx, backend.WorkFileName, []string{}, bytes.NewReader(b), int64(len(b)), nil)
31 if err != nil {
32 return fmt.Errorf("failed to flush work cache: %w", err)
33 }
34
35 return nil
36}
37
38// loadWorkCache loads the work cache
39func (s *BackendScheduler) loadWorkCache(ctx context.Context) error {

Callers 3

runningMethod · 0.95
stoppingMethod · 0.95
TestCacheFunction · 0.80

Calls 4

StartMethod · 0.65
MarshalMethod · 0.65
IncMethod · 0.65
WriteMethod · 0.65

Tested by 1

TestCacheFunction · 0.64