github.com/Cloud-Foundations/Dominator@v0.3.4/dom/lib/pushObjects.go (about) 1 package lib 2 3 import ( 4 "github.com/Cloud-Foundations/Dominator/lib/hash" 5 "github.com/Cloud-Foundations/Dominator/lib/log" 6 objectclient "github.com/Cloud-Foundations/Dominator/lib/objectserver/client" 7 ) 8 9 func (sub *Sub) pushObjects(objectsToPush map[hash.Hash]struct{}, 10 logger log.Logger) error { 11 objQ, err := objectclient.NewObjectAdderQueue(sub.Client) 12 if err != nil { 13 logger.Printf("Error creating object adder queue for: %s: %s\n", 14 sub, err) 15 return err 16 } 17 for hashVal := range objectsToPush { 18 length, reader, err := sub.ObjectGetter.GetObject(hashVal) 19 if err != nil { 20 logger.Printf("Error getting object: %x: %s\n", hashVal, err) 21 objQ.Close() 22 return ErrorFailedToGetObject 23 } 24 _, err = objQ.Add(reader, length) 25 reader.Close() 26 if err != nil { 27 logger.Printf("Error pushing: %x to: %s: %s\n", hashVal, sub, err) 28 objQ.Close() 29 return err 30 } 31 } 32 if err := objQ.Close(); err != nil { 33 logger.Printf("Error pushing objects to: %s: %s\n", sub, err) 34 return err 35 } 36 return nil 37 }