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
Added a Bull client, and a route /feeds/info to query queue's info #2541
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should try running this in GitPod so you don't have to set everything up locally.
Also, you have some lint errors to fix.
src/api/posts/src/routes/feeds.js
Outdated
| logger.error({ error }, "Unable to get queue's info"); | ||
| next(error); | ||
| } | ||
| res.json({ jobNum: jobNum }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move this to after line 42, inside the try/catch. Also, you don't need to repeat jobNum:
res.json({ jobNum });
src/api/posts/src/routes/feeds.js
Outdated
| @@ -42,7 +55,7 @@ feeds.get('/:id', validateFeedsIdParam(), async (req, res, next) => { | |||
| const feed = await Feed.byId(id); | |||
| if (!feed) { | |||
| res.status(404).json({ | |||
| message: `Feed not found for id ${id}`, | |||
| message: `Feed not found fore id ${id}`, | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spelling mistake. Should be for not fore.
src/api/posts/src/routes/feeds.js
Outdated
| feeds.get('/info', async (req, res, next) => { | ||
| let jobNum; | ||
| try { | ||
| jobNum = await queue.count(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested on GitPod and this route never seems to return (e.g., I get no response from the server, it just loads forever). It looks like you're doing it correctly, but there's nothing coming back.
|
That's what I got for my response as well, the idea seems correct though. I'll look more into it |
|
I suspect that the connection to Redis isn't right somehow (e.g., it's never returning a response). |
|
I'll compare it to the connection in |
|
Hi @humphd, it's not returning any data because the redis clients from The const redisUrl = process.env.REDIS_URL || 'redis://redis:6379'; // redis.js from satellitetelescope/src/backend/lib/redis.js Line 9 in 2359565
I tried uncommenting this line How do I change the variable |
|
Fantastic detective work! I'm really impressed that you didn't give up, and kept pushing to find the underlying problem. That's awesome. We should change the backend to match the microservices, unless @manekenpix or @HyperTHD have a better idea? NOTE: all the config happens via environment variables in the We also override things in the https://github.com/Seneca-CDOT/telescope/blob/master/docker/development.yml#L72-L74 I'd have to sit with this for a while to wrap my head around it, but in general, I think the backend should be bent to work the same way as the stuff in |
|
Thank you! I tested it out and the queue from If cleaning up the backend is on the list for the next release, it'll be probably late for my release 0.4. Also, I don't think I should touch the configuration of So how should I move forward from here, should I wait for the other devs' ideas? |
|
I'm not sure if this is a |
|
I agree it's odd that this isn't working, since everything else is running against that same Redis instance. Is it just your dev setup? |
|
I agree, if it works for other endpoints why not It's just when I followed Josue's instructions, the promise from I'll keep trying. |
deb8e03
to
0ffda02
Compare
|
Turns out, I need to provide the {"queueInfo":{"waiting":785,"active":0,"completed":0,"failed":2,"delayed":0,"paused":0,"jobCnt":785}}The reason telescope/src/backend/feed/queue.js Lines 29 to 30 in 4b1c074
I also added the 2 options |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to add a test for this as well in https://github.com/Seneca-CDOT/telescope/blob/master/src/api/posts/test/posts.test.js. We won't have real data, but hopefully it should return something.
I'm fine if you do that test here or in a follow-up PR. If you do the latter, please file the issue now.
I'll add tests in this PR |
|
Hi, for now, {"queueInfo":{"waiting":785,"active":0,"completed":0,"failed":2,"delayed":0,"paused":0,"jobCnt":785}}I try listening for completed queue events but the event is never fired as the //this event is never fired
queue.on('completed', (job) => {
console.log(`${job.id} completed`);
});
//this event is fired but get error when trying to use Bull Api on queue
queue.on('global:completed', (jobid) => {
console.log(`${jobid} completed`);
});I'm not sure how to get |
|
This is one reason why doing this in the parser would make the most sense, since that's where we actually manage the queue to begin with. That said, why don't we start with the items you can get, and do other things in follow ups? |
|
If that's the case, I'd love to work on the parser service later on. I'll follow up with what I can get right now. Thanks. |
c00e7bc
to
71344c0
Compare
71344c0
to
2fd0b98
Compare
|
I clicked on Update Branch accidentally. |
|
872ca06
to
7f190d8
Compare
|
After this got merged, I need to work on the front-end right? |
|
Yup, you can start now if you want, just base your new branch on this branch, and rebase onto master when it lands. |
|
Got it! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just for reference, Redis was added to Satellite so we should extract it from there. That way, we can also remove ioredis and ioredis-mock from the posts service. We can do that in another issue though. Nice job
|
@TueNguyen2911 let's get this in soon, can you rebase and fix the conflict in your package.json? Ping me when it's ready so I can merge. |
7f190d8
to
881e9cc
Compare
| @@ -17,6 +17,7 @@ | |||
| }, | |||
| "dependencies": { | |||
| "@senecacdot/satellite": "^1.x", | |||
| "bull": "^3.20.1", | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because you a dependency, you need to also update the pnpm lock file and commit that as well.
- Added a test for the new route - Added Bull to package.json - Added a new file queue.js to create a Bull queue - Updated pnpm-lock.yaml
881e9cc
to
3409f74
Compare

Issue This PR Addresses
This fixes #2414
Type of Change
Description
This is draft PR for issue #2414.
I added a new file
queue.jsthat creates and exports a new Bull client withredisclient connection required from posts/src/redis.js. I also added a new GET routefeeds/infoto return the queue's information, for now I'm trying to return the number of jobs in the queue.I tested the route by running
npm run services:start,npm startfirst and runninghttp://localhost/v1/posts/feeds/infoin Postman. However, I haven't got the expected response, please let me know if I'm on the right track!The response I got was a long loading screen until Bad Gateway
Checklist