cavai-research / Adonis-Queue

Queue provider for Adonis V5
MIT License
39 stars 2 forks source link

Return the Job Identifier on dispatch #35

Closed egorovpavel closed 1 year ago

egorovpavel commented 1 year ago

It would be nice to get a some kind of reference to a job after it was dispatched, so we can track its status.

so instead of "fire and forget"

await MyJob.dispatch({config})

we could do something with the job

const job = await MyJob.dispatch({config})

Thanks for the proper "redisless" queue!

McSneaky commented 1 year ago

True! That would be really nice indeed Did initial test real fast. Need to return from two places

Also need to update TS typings and would be cool to have some unified return across drivers for job creation I wonder, if just job ID would be enuf to return or should return more info? 🤔 Like

const job = await MyJob.dispatch({ foo: 'bar' })
console.log(job)
// 10

// vs
console.log(job)
{
  id: 10,
  class_path: '/foo/bar/MyJob.ts',
  payload: { foo: 'bar' }
}

For just tracking, ID itself would be enuf, but would there be cases for other info to be returned? 🤔

McSneaky commented 1 year ago

Just realized, can start with returning:

{
  id: 10
}

And then can add extra return data when needed in future without breaking changes

I'll try to get it out within a week. Or also accepting PRs for it :)

McSneaky commented 1 year ago

Released as version 3.0.0. Breaking change for people who wrote custom drivers. They'll need to return job ID too now