| 203 | } |
| 204 | |
| 205 | func (u *S3) Stop() { |
| 206 | // Stop may be called by the Topology in case of early exit (i.e CTRL-C), |
| 207 | // in that case u.quit would be closed twice since Stop() is also called |
| 208 | // by S3Upload.Run(). Both paths are necessary for a graceful exit; to the |
| 209 | // upload that means making sure all files have been uploaded. |
| 210 | u.stopOnce.Do(func() { |
| 211 | // Signal the upload goroutine to not go further the currently |
| 212 | // initiated call and wait for it to have terminated. |
| 213 | close(u.quit) |
| 214 | u.wgUpload.Wait() |
| 215 | }) |
| 216 | } |
| 217 | |
| 218 | func (u *S3) Stats() baker.UploadStats { |
| 219 | bag := make(baker.MetricsBag) |