Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New APIs for getting messages and message count #22

Closed
wants to merge 3 commits into from

Conversation

mahendra
Copy link
Collaborator

Introduces two APIs

  • get_messages(count=1) - returns an array with max count messages
  • pending() - returns the number of pending messages

This will be easier to use in some cases where we have to get
only a specified set of messages. This API uses the __iter__
API internally, but maintains the state to give back only the
required set of messages

API is - get_messages(count=1)
@mumrah mumrah closed this in f4a326f May 28, 2013
@mahendra
Copy link
Collaborator Author

mahendra commented Jun 4, 2013

@mumrah I just noticed your comment on get_messages API.

I thought the consumer (iterator) per-se was meant to be non re-entrant. So, either a user will iterator over the consumer directly or will use an API like get_messages to get the messages.

The effect of two users accessing the same consumer is the same whether they iterate over it or use an API.

I am OK with implementing get_messages(count=1) as you mentioned.

def get_messages(self, count=1):
    return list(islice(self, 0, count))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants