Add queue to prevent writing too many files at once.
This commit is contained in:
parent
6c4db980c9
commit
fa7150cf2b
1 changed files with 7 additions and 5 deletions
|
@ -23,11 +23,13 @@ func init() {
|
|||
writeCh = make(chan writeRequest)
|
||||
for i := 0; i < runtime.NumCPU(); i++ {
|
||||
go func() {
|
||||
select {
|
||||
case r := <-writeCh:
|
||||
err := ioutil.WriteFile(r.filename, r.data, r.perm)
|
||||
if err != nil {
|
||||
log.Errorf("could not write file %s to disk, failed with error: %s", r.filename, err.Error())
|
||||
for {
|
||||
select {
|
||||
case r := <-writeCh:
|
||||
err := ioutil.WriteFile(r.filename, r.data, r.perm)
|
||||
if err != nil {
|
||||
log.Errorf("could not write file %s to disk, failed with error: %s", r.filename, err.Error())
|
||||
}
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
|
Loading…
Reference in a new issue