New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

resque-async

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

resque-async

  • 0.0.4
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

ResqueAsync

A simple way to invoke methods asynchronously using Resque. There are a few gems that provide similar functionality. However this this implementation provides more expressive syntax that it gives the caller control over the invocation.

Installation

Add this line to your application's Gemfile:

gem 'resque-async'

And then execute:

$ bundle

Or install it yourself as:

$ gem install resque-async

Usage

Assuming

class MyObject < ActiveRecord::Base
    def self.slow_class_method
    end
    def slow_instance_method
    end
end

Supports Class Methods and ActiveRecord instance methods

MyObject.async(:high).slow_class_method

# ActiveRecord instances will be queued/loaded/invoked asynchronously
MyObject.new.async(:medium).slow_instance_method

Natural synchronous invocation

    MyObject.slow_class_method
    MyObject.new.slow_instance_method

Support high, medium, low priority out of the box. As well as custom worker/queue

# slow_class_method queued/invoked on 'high' queue
MyObject.async(:high).slow_class_method

# slow_class_method queued/invoked on 'medium' queue
MyObject.async(:medium).slow_class_method

# slow_class_method queued/invoked on 'low' queue
MyObject.async(:low).slow_class_method

OR

class MyCustomerWorker
    extend ResqueAsync::Workers::AsyncClassWorker
    @queue :crazy
end 
MyObject.async(MyCustomerWorker).crazy_priority

What about resque-async-method?

resque-async-method hides the fact that a method may be invoked asynchronously. From the caller's perspective things can get really confusing.

With resque-async-method

class MyObject < ActiveRecord::Base
    def slow_method
    end
    async_method :slow_method
end

# is this async or not? What does result equal? Better check the implementation of MyObject
result = MyObject.new.slow_method 

With resque-async

class MyObject < ActiveRecord::Base
    def slow_method
    end
end

# this should be pretty obvious, even years later, that slow_method is invoked async
d = MyObject.new.async(:low).slow_method

Contributing

  1. Fork it ( https://github.com/exitround/resque-async/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

FAQs

Package last updated on 14 Mar 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc