From d8c1d63c95ed3e551c8af3902443a041b1366e14 Mon Sep 17 00:00:00 2001 From: Gregory Eremin Date: Thu, 11 Sep 2014 23:00:08 +0400 Subject: [PATCH] Storage info function --- storage/storage.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/storage/storage.go b/storage/storage.go index c593f9b..5c22623 100644 --- a/storage/storage.go +++ b/storage/storage.go @@ -78,6 +78,16 @@ func (s *Storage) Put(queue string, message []byte) (err error) { return } +func (s *Storage) Info() map[string]uint { + info := make(map[string]uint) + + for queue, c := range s.counters { + info[queue] = c.distance() + } + + return info +} + func (s *Storage) Close() (err error) { if err = s.kyoto.Sync(true); err != nil { return @@ -141,5 +151,6 @@ func (s *Storage) keepStatePersisted() { } func makeKey(queue string, index uint) []byte { + // TODO: There should be a faster way return []byte(strings.Join([]string{queue, strconv.FormatUint(uint64(index), 10)}, "_")) }