| 72 | } |
| 73 | |
| 74 | func New(cfg Config) Interface { |
| 75 | sw := &Work{ |
| 76 | cfg: cfg, |
| 77 | } |
| 78 | |
| 79 | // Initialize all shards |
| 80 | for i := range ShardCount { |
| 81 | sw.Shards[i] = &Shard{ |
| 82 | Jobs: make(map[string]*Job), |
| 83 | Pending: make(map[string]*Job), |
| 84 | } |
| 85 | } |
| 86 | sw.pendingBlocks = make(map[string]string) |
| 87 | sw.pendingByTenant = make(map[string]map[tempopb.JobType][]string) |
| 88 | sw.redactionInFlight = make(map[string]int) |
| 89 | sw.registeredJobs = make(map[string]*Job) |
| 90 | sw.runningBlocks = make(map[string]*Job) |
| 91 | sw.batches = newBatchStore() |
| 92 | |
| 93 | return sw |
| 94 | } |
| 95 | |
| 96 | // AddJob adds a job to the appropriate shard |
| 97 | func (w *Work) AddJob(j *Job) error { |