ACE Connect long-running tasks

Hello Team,
we are implementing a long running jobs on Heroku following this project: GitHub - heroku-examples/node-workers-example: A simple example of using Redis to coordinate a worker process

as the worker.js runs on a different dyno now there is a question how we can handle an authenticated request call to the host JIRA

usually we do use this construction in our application:

var httpClient = addon.httpClient(req);
httpClient.get('/', function(err, res, body) {

and in the ideal scenario we would need something like this:

const reqData = stringify(req);
const addonData = stringify(addon);
let job = await workQueue.add({reqData, addonData})

so we could access the host Jira within the job process easily, but since these objects are not serializable (converting circular structure to JSON), we are not sure how to do it the right way. Is there a simple way how we can access the host JIRA within je job process?

The Readme at Bitbucket
shows how to do an outbound request with a given clientKey:

var httpClient = addon.httpClient({
  clientKey: clientKey  // The unique client key of the tenant to make a request to
httpClient.get('/', function(err, res, body) {

So if you give the clientKey to your worker, they can authenticate.

We are aware of this but how can we pass the addon object (so we can access its httpClient) to our worker?

Since your worker is on a separate dyno, the easiest is to instantiate ACE on the worker too, but just not start the Express server. This way you’ll be able to use ACE’s addon object. Of course, you’ll need to pass the clientKey from the web server to the worker so that it knows for which “client” it’s operating, but the clientKey is a simple string so perfectly serializable.