Skip to content

Commit

Permalink
closes #5
Browse files Browse the repository at this point in the history
  • Loading branch information
goenning committed Sep 27, 2016
1 parent 5e85862 commit 3fd8775
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/redis_task_queue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@ export class RedisTaskQueue extends TaskQueue {
private client: redis.RedisClient;
private key = "yago.queue";

constructor(connString: string) {
constructor(connString: string, key?: string) {
super();
this.client = redis.createClient(connString);

if (key)
this.key = key;
}

async enqueue(task: Task): Promise<Task> {
Expand Down
15 changes: 15 additions & 0 deletions test/task_queue.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,20 @@ items.forEach((item) => {
expect(secondDequeued).to.deep.equal(thirdEnqueued);
expect(thirdDequeued).to.deep.equal(firstEnqueued);
});

if (item.name === "RedisQueue") {
it("should be able to have a different key", async () => {
const otherQueue = new RedisTaskQueue("redis://localhost:6060", "some-other-key");
otherQueue.flush();

await otherQueue.enqueue(new Task("hello-world"));

const queueCount = await queue.count();
const otherQueueCount = await otherQueue.count();

expect(queueCount).to.be.equal(0);
expect(otherQueueCount).to.be.equal(1);
});
}
});
});

0 comments on commit 3fd8775

Please sign in to comment.