Permalink
Browse files

Merge pull request #14 from nimajalali/master

Added get message with timeout function to mq
  • Loading branch information...
2 parents 1d55a83 + 89cfb02 commit 25dda308fab619c9353dc1af4801374089d06b68 @treeder treeder committed Feb 24, 2014
Showing with 7 additions and 0 deletions.
  1. +7 −0 mq/mq.go
View
@@ -186,12 +186,19 @@ func (q Queue) Get() (msg *Message, err error) {
// get N messages
func (q Queue) GetN(n int) (msgs []*Message, err error) {
+ msgs, err = q.GetNWithTimeout(n, 0)
+
+ return
+}
+
+func (q Queue) GetNWithTimeout(n, timeout int) (msgs []*Message, err error) {
out := struct {
Messages []*Message `json:"messages"`
}{}
err = q.queues(q.Name, "messages").
QueryAdd("n", "%d", n).
+ QueryAdd("timeout", "%d", timeout).
Req("GET", nil, &out)
if err != nil {
return

0 comments on commit 25dda30

Please sign in to comment.