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

Method LoadFromLocal

modules/backendscheduler/work/work.go:160–184  ·  view source on GitHub ↗

LoadFromLocal reads the work cache from local storage using sharding approach

(_ context.Context, localPath string)

Source from the content-addressed store, hash-verified

158
159// LoadFromLocal reads the work cache from local storage using sharding approach
160func (w *Work) LoadFromLocal(_ context.Context, localPath string) error {
161 w.mtx.Lock()
162 defer w.mtx.Unlock()
163
164 // Load from shard files - BackendScheduler already determined this is the right approach
165 for i := range ShardCount {
166 shardPath := filepath.Join(localPath, FileNameForShard(uint8(i)))
167
168 data, err := os.ReadFile(shardPath)
169 if err != nil {
170 if os.IsNotExist(err) {
171 continue // Empty shard is OK
172 }
173 return err
174 }
175
176 err = w.UnmarshalShard(i, data)
177 if err != nil {
178 return err
179 }
180 }
181
182 w.rebuildPendingIndexes()
183 return nil
184}
185
186// StartJob starts a job in the appropriate shard
187func (w *Work) StartJob(id string) {

Callers

nothing calls this directly

Calls 4

UnmarshalShardMethod · 0.95
rebuildPendingIndexesMethod · 0.95
FileNameForShardFunction · 0.85
JoinMethod · 0.65

Tested by

no test coverage detected