-
Notifications
You must be signed in to change notification settings - Fork 325
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add basic support for ConnectionPool
- Loading branch information
1 parent
49cd15f
commit 8fa2f81
Showing
5 changed files
with
157 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
begin | ||
require 'connection_pool' | ||
rescue LoadError | ||
fail "'connection_pool' gem is required to use Her::API's pool_size and pool_timeout options" | ||
end | ||
require 'her/model/http' | ||
|
||
module Her | ||
class API | ||
class ConnectionPool < ::ConnectionPool | ||
DELEGATED_METHODS = Model::HTTP::METHODS | ||
|
||
DELEGATED_METHODS.each do |method| | ||
class_eval <<-RUBY, __FILE__, __LINE__ + 1 | ||
def #{method}(*args, &blk) | ||
with do |conn| | ||
conn.#{method}(*args, &blk) | ||
end | ||
end | ||
RUBY | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters