-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Active job token expiring integration #102
Comments
@caulfield - can you talk about the advantages of using jobs for this? Also, are there any downsides to the current system? These are some of the thoughts I had when building out the current implementation: Advantages of the current system
Disadvantages of using jobs
|
Thank you @lynndylanhurley for great response. The main goal is not to do extra queries. user record can be updated often, so each query we will deserialize tokens and find expired. so we will get big perfomance gain.
I think you don't understand. I mean something about it: # resource model
def create_new_auth_token
...
TokensJob.set(wait_until: expiry_time).perform_later(self, client_id)
end
# in TokensJob
def perform(resource, client)
resource.delete_token(client)
resource.save!
end So, if active job is not set up, user get error(example for resque) NotImplementedError, "To be able to schedule jobs with Resque you need the resque-scheduler gem. Please add it to your Gemfile and run bundle install" Currently I'm not sure how to configure gem and select default setting way |
Just to clarify, a token's lifecycle looks like this:
Because step 3 already requires a trip to the DB, no extra queries are made. Also note that the |
Closing this. Can re-open if people feel passionately about this, but there's been some recent logic to reduce # of queries during user resource load, etc. |
Hi.
After rails 4.2 support we can refactor this code and use active job framework
https://github.com/lynndylanhurley/devise_token_auth/blob/master/app/models/devise_token_auth/concerns/user.rb#L29
I think this feature is complex and I want to discuss implementations.
The idea is to add configuration variable
Devise.config.use_active_job_for_token_expiring
and if this value truthy we will add new delayed job (defined by user and client_id) after token creatingAnother one is check ActiveJob::Base.queue_adapter and add this behaviour automatically.
Any thoughts about it and/or new ideas are welcome
The text was updated successfully, but these errors were encountered: