solid_queue
solid_queue copied to clipboard
recurring task argument not successfully passing all ActiveJob supported types
I ran into a problem with passing an ActiveSupport::Duration to a recurring job.
I built a couple of jobs that just pass arguments and check that they are received as the expected types. I tested each of the supported type described on the Rails guides Active Job Basics.
- I was unable to successfully pass any ActiveSupport supported datatypes: TimeWithZone, Duration, or HasWithIndifferentAccess. I tried positional and kwargs and regardless of how I attempted to pass the argument, they are received by the job as a string.
- I was unable to figure out pass a symbol as an argument in any permutation: arg: :sym, arg: ":sym", arg: 'sym'.to_sym
- I made a quick test with an ActiveJob custom serializer, but my custom types where also being processed as strings.
Sample solid_queue.yml:
default: &default
dispatchers:
- polling_interval: 1
batch_size: 500
recurring_tasks:
rails_types_job:
class: RailsTypesJob
args: [ 10.minutes, { twt: Time.current, duration: 10.minutes } ]
schedule: every 1 minute
Hey @hms, yes, this is expected as the way this is implemented allows only types supported by YAML. I went for this for simplicity, pretty much mirroring the way resque-scheduler's static schedules work, as this is what we've used before when we couldn't rely on Unix's cron
, and it's covered everything we needed. More complex arguments can be supported in different ways directly on the job itself.
However, I'd be happy to consider any contributions that enhance this!
Hi Rosa,
Once I figure out how to get Docker and the tests working on my fork, I might make a run at this and #176 (something that would make my life a little better). Until then, could we update the Readme with the officially supported argument types?
Of course, sure thing! 🙏
What's not working for you when you run bin/setup
?
@rosa Sorry for going radio silent, getting crushed on a delivery. Can I get back to this in a week or 2?
Hey @hms, of course, no worries at all! 🙏