Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ActiveJob and Que arguments compatibility issue #156

Closed
clamoris opened this issue May 18, 2016 · 3 comments
Closed

ActiveJob and Que arguments compatibility issue #156

clamoris opened this issue May 18, 2016 · 3 comments

Comments

@clamoris
Copy link

Since Que using HashWithIndifferentAccess as default json converter symbol hash keys and named arguments do not work with ActiveJob.

ActiveJob use transform_keys to deserialize symbol keys

# activejob/lib/active_job/arguments.rb

def transform_symbol_keys(hash, symbol_keys)
  hash.transform_keys do |key|
    if symbol_keys.include?(key)
      key.to_sym
    else
      key
    end
  end
end

BUT

{ "foo" => 1 }.with_indifferent_access.transform_keys(&:to_sym) # => {"foo"=>1}

So jobs like

class AwesomeJob < ActiveJob::Base
  def perform(params)
    # code using params[:foo]
  end
end

will fail with no obvious reason

@chanks
Copy link
Collaborator

chanks commented May 18, 2016

Another reason to not use ActiveJob. There have been a few others, if you search the issues.

Does everything work as expected if you set Que.json_converter = Que::SYMBOLIZER instead? If so, I think the correct fix is probably to just document that, or to add it to the ActiveJob Que adapter.

@clamoris
Copy link
Author

@chanks Que.json_converter = nil works fine

@chanks
Copy link
Collaborator

chanks commented Apr 15, 2018

Closing old issues. This should no longer be a problem, our ActiveJob integration is much better (and better-tested!) now.

@chanks chanks closed this as completed Apr 15, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants