| 34 | } |
| 35 | |
| 36 | func (tarQueue *TarBallQueue) StartQueue() error { |
| 37 | if tarQueue.started.Load() { |
| 38 | panic("Trying to start already started Queue") |
| 39 | } |
| 40 | var err error |
| 41 | tarQueue.parallelTarballs, err = conf.GetMaxUploadDiskConcurrency() |
| 42 | if err != nil { |
| 43 | return err |
| 44 | } |
| 45 | tarQueue.maxUploadQueue, err = conf.GetMaxUploadQueue() |
| 46 | if err != nil { |
| 47 | return err |
| 48 | } |
| 49 | |
| 50 | tarQueue.tarsToFillQueue = make(chan TarBall, tarQueue.parallelTarballs) |
| 51 | tarQueue.uploadQueue = make(chan TarBall, tarQueue.parallelTarballs+tarQueue.maxUploadQueue) |
| 52 | for i := 0; i < tarQueue.parallelTarballs; i++ { |
| 53 | tarQueue.NewTarBall(true) |
| 54 | tarQueue.tarsToFillQueue <- tarQueue.LastCreatedTarball |
| 55 | } |
| 56 | |
| 57 | tarQueue.started.Store(true) |
| 58 | return nil |
| 59 | } |
| 60 | |
| 61 | // DequeCtx returns a TarBall from the queue. If the context finishes before it |
| 62 | // can do so, it returns the result of ctx.Err(). |