stillwater 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +22 -17
- data/lib/stillwater/connection_pool.rb +1 -3
- data/lib/stillwater/version.rb +1 -1
- data/stillwater.gemspec +0 -2
- metadata +9 -25
data/README.md
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
# Stillwater
|
2
2
|
|
3
|
+
[](http://travis-ci.org/trobrock/stillwater)
|
4
|
+
[](https://gemnasium.com/trobrock/stillwater)
|
5
|
+
|
3
6
|
A simple connection pool, that allows connections to different servers (or anything else)
|
4
7
|
|
5
8
|
## Installation
|
@@ -18,23 +21,25 @@ Or install it yourself as:
|
|
18
21
|
|
19
22
|
## Usage
|
20
23
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
24
|
+
```ruby
|
25
|
+
pool = Stillwater::ConnectionPool.new
|
26
|
+
%q{ host1.com host2.com }.each do |host|
|
27
|
+
pool.add { MyConnectionClass.new(host) }
|
28
|
+
end
|
29
|
+
|
30
|
+
# Basic connection handling
|
31
|
+
pool.with_connection do |connection|
|
32
|
+
# Do some stuff with your connection
|
33
|
+
end
|
34
|
+
|
35
|
+
# Retry connections
|
36
|
+
# This will retry your code with a new connection and mark the tried
|
37
|
+
# connection as bad. The bad connection will be put back in the pool
|
38
|
+
# at the default period of 5 minutes.
|
39
|
+
pool.retry_connection_from(ServerConnectionFailed) do |connection|
|
40
|
+
# Do some stuff with your connection
|
41
|
+
end
|
42
|
+
```
|
38
43
|
|
39
44
|
## Contributing
|
40
45
|
|
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'active_support/core_ext/array'
|
2
|
-
|
3
1
|
module Stillwater
|
4
2
|
class ConnectionNotAvailable < StandardError ; end
|
5
3
|
|
@@ -46,7 +44,7 @@ module Stillwater
|
|
46
44
|
end
|
47
45
|
|
48
46
|
def checkout
|
49
|
-
connection_info = available.sample
|
47
|
+
connection_info = available.respond_to?(:sample) ? available.sample : available.choice
|
50
48
|
raise ConnectionNotAvailable if connection_info.nil?
|
51
49
|
connection_info[:state] = :in_use
|
52
50
|
|
data/lib/stillwater/version.rb
CHANGED
data/stillwater.gemspec
CHANGED
@@ -15,8 +15,6 @@ Gem::Specification.new do |gem|
|
|
15
15
|
gem.require_paths = ["lib"]
|
16
16
|
gem.version = Stillwater::VERSION
|
17
17
|
|
18
|
-
gem.add_dependency %q<activesupport>, '~> 2.3.0'
|
19
|
-
|
20
18
|
gem.add_development_dependency %q<rake>
|
21
19
|
gem.add_development_dependency %q<rspec>
|
22
20
|
gem.add_development_dependency %q<mocha>
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stillwater
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 2
|
10
|
+
version: 0.0.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Trae Robrock
|
@@ -16,26 +16,10 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2012-07-
|
19
|
+
date: 2012-07-09 00:00:00 Z
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
22
|
version_requirements: &id001 !ruby/object:Gem::Requirement
|
23
|
-
none: false
|
24
|
-
requirements:
|
25
|
-
- - ~>
|
26
|
-
- !ruby/object:Gem::Version
|
27
|
-
hash: 3
|
28
|
-
segments:
|
29
|
-
- 2
|
30
|
-
- 3
|
31
|
-
- 0
|
32
|
-
version: 2.3.0
|
33
|
-
name: activesupport
|
34
|
-
type: :runtime
|
35
|
-
prerelease: false
|
36
|
-
requirement: *id001
|
37
|
-
- !ruby/object:Gem::Dependency
|
38
|
-
version_requirements: &id002 !ruby/object:Gem::Requirement
|
39
23
|
none: false
|
40
24
|
requirements:
|
41
25
|
- - ">="
|
@@ -47,9 +31,9 @@ dependencies:
|
|
47
31
|
name: rake
|
48
32
|
type: :development
|
49
33
|
prerelease: false
|
50
|
-
requirement: *
|
34
|
+
requirement: *id001
|
51
35
|
- !ruby/object:Gem::Dependency
|
52
|
-
version_requirements: &
|
36
|
+
version_requirements: &id002 !ruby/object:Gem::Requirement
|
53
37
|
none: false
|
54
38
|
requirements:
|
55
39
|
- - ">="
|
@@ -61,9 +45,9 @@ dependencies:
|
|
61
45
|
name: rspec
|
62
46
|
type: :development
|
63
47
|
prerelease: false
|
64
|
-
requirement: *
|
48
|
+
requirement: *id002
|
65
49
|
- !ruby/object:Gem::Dependency
|
66
|
-
version_requirements: &
|
50
|
+
version_requirements: &id003 !ruby/object:Gem::Requirement
|
67
51
|
none: false
|
68
52
|
requirements:
|
69
53
|
- - ">="
|
@@ -75,7 +59,7 @@ dependencies:
|
|
75
59
|
name: mocha
|
76
60
|
type: :development
|
77
61
|
prerelease: false
|
78
|
-
requirement: *
|
62
|
+
requirement: *id003
|
79
63
|
description: A simple connection pool, that allows connections to different servers (or anything else)
|
80
64
|
email:
|
81
65
|
- trobrock@gmail.com
|