Skip to content

Commit

Permalink
Instructions for ActiveRecord Usage. Closes #2
Browse files Browse the repository at this point in the history
  • Loading branch information
jwo committed Feb 19, 2015
1 parent 1869bb9 commit eab418a
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,19 @@ The pmap will return an array of values when all of the Futures have completed a

The pool can help to make sure you don't exceed your connection resources. A common use case for this is in Rails, you can easily exceed the default ActiveRecord connection size.

### Use with ActiveRecord

Some users have reported connection leaking with using ActiveRecord objects in a
pmap. You can reuse a connection with this code below. You can read the backstory
on the [decision to not include an AR dependency](https://github.com/jwo/celluloid-pmap/pull/2).

```ruby
users.pmap(4) do |user|
ActiveRecord::Base.connection_pool.with_connection { user.do_hefty_stuff! }
end
```


### Inspiration for this code

Tony Arcieri created [celluloid](http://celluloid.io/), and the [simple_pmap example](https://github.com/celluloid/celluloid/blob/master/examples/simple_pmap.rb) from which this codebase started
Expand Down

0 comments on commit eab418a

Please sign in to comment.