Hi! I was wondering if there’s any way for a job to have access to its own definition when it is running. I scanned the docs and didn’t find anything.
My use case is that I have a few jobs where the function called is the same but the schedule is different (e.g., same job runs at 10 AM and 3 PM). In those jobs I’d like to do something that is parameterized by when the job is run (could be as simple as logging “the 3PM foo job is running”). Obviously I could pass this information in as an argument in the configuration but that seems error prone (suppose I change the 3PM job to run at 2 PM and forget to change one of the settings).
I had a couple ideas about how this could be implemented. One is to have a dummy parameter for the arguments - e.g. [“arg1”, :quantum_job_definition] where :quantum_job_definition is replaced on-the-fly by the actual Quantum.Job. Another idea is to have a registry mapping job pid to job definition. This way the job could simply call something like Quantum.get_running_job(self()) and have that return the Quantum.Job.
If this is already possible or there’s a reasonable workaround then that’s awesome. If not I would be willing to help with a PR. Thanks!
Hi! I was wondering if there’s any way for a job to have access to its own definition when it is running. I scanned the docs and didn’t find anything.
My use case is that I have a few jobs where the function called is the same but the schedule is different (e.g., same job runs at 10 AM and 3 PM). In those jobs I’d like to do something that is parameterized by when the job is run (could be as simple as logging “the 3PM foo job is running”). Obviously I could pass this information in as an argument in the configuration but that seems error prone (suppose I change the 3PM job to run at 2 PM and forget to change one of the settings).
I had a couple ideas about how this could be implemented. One is to have a dummy parameter for the arguments - e.g.
[“arg1”, :quantum_job_definition]
where:quantum_job_definition
is replaced on-the-fly by the actual Quantum.Job. Another idea is to have a registry mapping job pid to job definition. This way the job could simply call something likeQuantum.get_running_job(self())
and have that return the Quantum.Job.If this is already possible or there’s a reasonable workaround then that’s awesome. If not I would be willing to help with a PR. Thanks!