title: How do I execute my functions as background processes in Node.js with Bull?
body: <p>I have a Node.js web application in which I make some 3rd party API calls with, creating some really long request/response times. This causes my Heroku to timeout ~50% of the time, and according to Heroku docs there's no way to change this hard limit. They recommend using background processes to scale, and this seemed like a good fit to the problem (they provide examples and recommend using <a href="https://optimalbits.github.io/bull/" rel="nofollow noreferrer">https://optimalbits.github.io/bull/</a>). </p>
  
  <p>I'm following the simple example provided by Heroku here <a href="https://github.com/heroku-examples/node-workers-example" rel="nofollow noreferrer">https://github.com/heroku-examples/node-workers-example</a>), however for my sake this example is a bit too simple. </p>
  
  <p>I have a filed named <code>worker.js</code> which will be my worker. There is a function <code>start()</code> that instantiates the queue, and tells the queue how to process jobs. My issue is that I will be adding jobs to the queue via my API endpoints, and I would like each job to execute specific functions in order to complete their task. </p>
  
  <p>Here is the <code>start()</code> function: </p>
  
  <pre><code>function start(){
   let workQueue = new Queue('work', REDIS_URL);
    workQueue.process(maxJobsPerWorker, async (job,data) =&gt; {
      return {message: "Finished"};
    });
  </code></pre>
  
  <p>What I would like to do is to execute different functions in the logic block instead of returning a finished message. For example, I'd like to do something like this: </p>
  
  <pre><code>function start(){
   let workQueue = new Queue('work', REDIS_URL);
    workQueue.process(maxJobsPerWorker, async (job,data) =&gt; {
      return someFunction();
    });
  </code></pre>
  
  <p>Again, that would be straight-forward enough if I needed to run the same function every time, but I will be running several different functions that use different inputs. So <code>someFunction</code> is a variable and not a constant.</p>
  
  <p>I was considering passing the name of the function to execute to the job directly, something like this: 
  <code>let job = await workQueue.add({ callback: functionName });</code> </p>
  
  <p>However I can't really tell if this works or not... How can I get this up and running?</p>