Skip to content

Support for Ruby 3.0 and deconstruct Hashes as keyword arguments.  #439

@abMatGit

Description

@abMatGit

We use sidekiq-schedule for a lot of periodically timed jobs. We have our configuration set up with keyword arguments since most of our jobs use keyword method signatures.

This results in our schedule to look like:
init/schedule.rb

schedule = {
  'morning job' => {
    class: 'MorningJob',
    cron: '0 8 * * * America/Los_Angeles',
    args: { foo: 'bar', hello: 'world' }
    persist: true
  }

... 
Sidekiq.configure_server do |config|
  config.on(:startup) do 
    schedule.each do |(name, schedule_config)|
      Sidekiq.set_schedule(name, schedule_config)
    end
  end
end

The issue is that args: { foo: 'bar', hello: 'world' } is passed along as a Hash, when we intend for it to be deconstructed as keyword arguments. This is a hard requirement for Ruby 3.0 which no longer allows Hashes to be auto-interpolated as keyword arguments.

Suggestion is to modify this method: https://github.com/sidekiq-scheduler/sidekiq-scheduler/blob/master/lib/sidekiq-scheduler/utils.rb#L63-L69 to have a condition for Hash and double splat in that scenario.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions