LoadFromLocal reads the work cache from local storage using sharding approach
(_ context.Context, localPath string)
| 158 | |
| 159 | // LoadFromLocal reads the work cache from local storage using sharding approach |
| 160 | func (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 |
| 187 | func (w *Work) StartJob(id string) { |
nothing calls this directly
no test coverage detected