1
0
Fork 0

Storage returns errors instead of bool

This commit is contained in:
Gregory Eremin 2014-09-10 15:38:46 +04:00
parent 5d85154030
commit b2dbf856fa
1 changed files with 2 additions and 5 deletions

View File

@ -35,13 +35,12 @@ func New(path string) (s *Storage, err error) {
return
}
func (s *Storage) Get(queue string, abort <-chan struct{}) (message []byte, ok bool) {
func (s *Storage) Get(queue string, abort <-chan struct{}) (message []byte, err error) {
if _, ok := s.counters[queue]; !ok {
s.counters[queue] = newCounter(0, 0)
}
var index uint
select {
case index = <-s.counters[queue].stream:
case <-abort:
@ -49,15 +48,13 @@ func (s *Storage) Get(queue string, abort <-chan struct{}) (message []byte, ok b
}
key := makeKey(queue, index)
message, err := s.kyoto.Get(key)
if err != nil {
if message, err = s.kyoto.Get(key); err != nil {
return
}
if err = s.kyoto.Remove(key); err != nil {
return
}
ok = true
return
}