1
0
Fork 0

More transparent writes

This commit is contained in:
Gregory Eremin 2014-07-12 17:42:04 +07:00
parent efc2a306ef
commit 51bc5b04e1
1 changed files with 10 additions and 8 deletions

View File

@ -26,14 +26,16 @@ func SetupStorage() {
func PersistMessages() {
for {
payload := <-saver
i := payload.Queue.Counter.Write + 1
key := NewKey(payload.Queue.Name, i)
p := <-saver
if err := storage.Set(key, payload.Message); err != nil {
rollbar.Error("error", err)
} else {
payload.Queue.Counter.Incr()
p.Queue.Counter.Write(func(i uint) bool {
key := NewKey(p.Queue.Name, i)
err := storage.Set(key, p.Message)
if err != nil {
Error(err, "Failed to write %d bytes to record '%s'", len(p.Message), key)
}
return (err != nil)
})
}
}