Skip to content
This repository has been archived by the owner on Mar 22, 2018. It is now read-only.

Commit

Permalink
Merge pull request #128 from leafnode/return-queue-length
Browse files Browse the repository at this point in the history
Return queue length with metadata
  • Loading branch information
arafato authored Dec 15, 2017
2 parents e1f886b + 997c57b commit c08caca
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
4 changes: 3 additions & 1 deletion lib/actions/queue/GetQueueMetadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ class GetQueueMetadata {
process(request, res) {
const queue = QueueManager.getQueueAndMessage({ queueName: request.queueName }).queue,
metaProps = queue.metaProps,
queueLength = queue.getLength(),
response = new AzuriteQueueResponse();
response.addMetaProps(metaProps);
response.addHttpProperty(`x-ms-approximate-messages-count`, queueLength);
res.set(response.httpProps);
res.status(200).send();
}
}

module.exports = new GetQueueMetadata();
module.exports = new GetQueueMetadata();
2 changes: 1 addition & 1 deletion lib/model/queue/AzuriteQueueResponse.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ class AzuriteQueueResponse {
}
}

module.exports = AzuriteQueueResponse;
module.exports = AzuriteQueueResponse;
6 changes: 5 additions & 1 deletion lib/model/queue/Queue.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ class Queue {
index: index
};
}

getLength() {
return this.messages.length;
}
}

module.exports = Queue;
module.exports = Queue;

0 comments on commit c08caca

Please sign in to comment.