Skip to content

Conversation

boazpoolman
Copy link
Member

@boazpoolman boazpoolman commented Aug 28, 2022

Queue documentation

To solve #14 we need queueing. This PR is a setup for a queue system. Here some docs:

Create queue
To create a queue you have to call the create service which takes one parameter that is a string that is unique to your queue. We refer to this as the name of the queue.

const { getPluginService } = require('./util/getPluginService');

getPluginService('queueService').create("my queue");

Add jobs
Once you have created your queue you have to add jobs to it. You can do that by calling the addJob service which takes two parameters. The first being the name of the queue, and the second being the data of the job.

await getPluginService('queueService').addJob("my queue", {
  some: 'data',
});
await getPluginService('queueService').addJob("my queue", {
  some: 'more data',
});
await getPluginService('queueService').addJob("my queue", {
  some: 'even data',
});

Process queue
After creating your queue and adding your jobs you have to process the queue. You can do that by calling the process service which takes two parameters. The first being the name of the queue, the second is a function that will be called to process a single job.

await getPluginService('queueService').process("my queue", async (job, done) => {
  // job.data is the job data.
  console.log('we be processing the job breh', job.data);

  // Call the done function when you're done processing the job.
  done();
});

@Alexnortung
Copy link
Collaborator

Hey Boaz, I think it is a good idea to implement a queue, I am also maintaining another plugin which could also use a queue, maybe we could make a separate queue plugin which this and other plugins could use?

@boazpoolman
Copy link
Member Author

Yeah, that crossed my mind too. I'm all for it!

@boazpoolman boazpoolman marked this pull request as draft January 17, 2024 09:03
@SalahAdDin
Copy link
Contributor

Yeah, that crossed my mind too. I'm all for it!

not finished yet?

@boazpoolman
Copy link
Member Author

Sadly I haven't found the time to continue this feature.

I think its still something that could be very helpful for the Strapi ecosystem.

@SalahAdDin
Copy link
Contributor

Sadly I haven't found the time to continue this feature.

I think its still something that could be very helpful for the Strapi ecosystem.

Maybe asking for some help on Discord...

@boazpoolman
Copy link
Member Author

Would you like to take the lead on this project?

I got my hands full working on the core features of Webrools.

@SalahAdDin
Copy link
Contributor

@boazpoolman is #14 related to this issue: #150?

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.

3 participants