Skip to content

Feature: pass Job by id #88

@frederikheld

Description

@frederikheld

Problem

IMHO the whole "pass Job by path" approach is not a good idea. It works well enough if job runner, the code that enqueues the job and the definition of the job are in the same package. But the beauty of a system like sidequest is that you can separate the job runner from the API that creates them and deploy both independently.

It was very hard setting up the job runner and the API that creates the jobs in different packages of my monorepo. Ending up with the exact same paths would have forced a file structure that I did not want. So the fix was symlinking the build results of a separate third package that defines the jobs into the two packages that use those definitions. Eventually, this worked. And lucky me, Git can store symlinks.

But then I dockerized these packages and learned that Docker doesn't copy symlinks. So now I have to look for another workaround.

The path approach requires a lot of workarounds and debugging. And looking at my database, I see job paths like this: ../../../../../../../../../../sidequest-jobs/SomeJob.ts. It's hard to debug such things, it almost feels like callback hell back in the time.

Add Docker on top of that (which is hard to debug in itself) and you waste a lot of time poking around to fix "cannot find module" errors thrown by the job runner.

Proposed Solution

Wouldn't it be possible to have unique id's per job and then store the job id instead of the path in the database?

At start, the job runner could check for uniqueness and then create an index of all jobs, which would allow for fast access as well.

This approach would make it way easier to use sidequest in a more flexible architecture.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions