<commit_before># MicroQ [![Build Status](https://travis-ci.org/bnorton/micro_q.png)](https://travis-ci.org/bnorton/micro_q)

MicroQ is a per-process asynchronous background queue.

It's simple startup and intuitive interface makes it the best choice for new and lagacy apps.

## Installation

Add this line to your Gemfile:

    gem 'micro_q'

    $ bundle

Or install it:

    $ gem install micro_q

## Usage

```ruby
# A typical worker
class MyWorker
  def perform
    # do some performing here
  end

  def update(options = {})
    # do some updating
   end
end
```

###Simple (default)

```ruby
# Using the async proxy API
MyWorker.async.perform

MyWorker.async.update(:user_id => user.id)

# Through the raw push API
MicroQ.push(:class => 'MyWorker') # Defaults to the perform method

# With a custom method
MicroQ.push(:class => 'MyWorker', :method => 'update', :args => [{:user_id => user.id}])
```

###Advanced

###Custom Loaders

## Contributing

1. Fork it
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 new Pull Request
<commit_msg>Adding new async_:method API. Safe AR instance async usage<commit_after># MicroQ [![Build Status](https://travis-ci.org/bnorton/micro_q.png)](https://travis-ci.org/bnorton/micro_q)

MicroQ is a per-process asynchronous background queue.

It's simple startup and intuitive interface makes it the best choice for new and lagacy apps.

## Installation

Add this line to your Gemfile:

    gem 'micro_q'

    $ bundle

Or install it:

    $ gem install micro_q

## Usage

```ruby
## A typical worker class
class MyWorker
  worker :update # sets up the dsl and takes additional async_ methods

  def perform
    # do some performing here
  end

  def update(options = {})
    # do some updating
   end
end
```

###Simple

```ruby
MyWorker.async_perform
MyWorker.async_update(:user_id => user.id)
```

###Advanced

Safely using an ActiveRecord instance via the Custom Loader API 
```ruby
# app/models/user.rb
class User < Activerecord::Base
  def update_social_data
    # Send HTTP requests to Facebook, Twitter, etc
  end
end

# app/controllers/users_controller.rb
def update
  user = account.users.find(params[:id])
  user.async.update_social_data
end
```

## Contributing

1. Fork it
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 new Pull Request

{'fraction_non_alphanumeric': 0.11085271317829458, 'fraction_numerical': 0.003875968992248062, 'mean_word_length': 3.8790170132325144, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 10, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6085050', 'n_tokens_mistral': 858, 'n_tokens_neox': 799, 'n_words': 298}