wye 0.0.3 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/wye/active_record/base.rb +1 -1
- data/lib/wye/active_record/connection_handler.rb +4 -0
- data/lib/wye/distributor/round_robin.rb +15 -0
- data/lib/wye/distributor/sticky.rb +15 -0
- data/lib/wye/distributor.rb +12 -0
- data/lib/wye/version.rb +1 -1
- data/lib/wye.rb +1 -0
- metadata +4 -1
@@ -19,6 +19,10 @@ module Wye
|
|
19
19
|
@class_to_alternate_pools.map { |(klass,atp)| atp.map(&:first) }.flatten.uniq
|
20
20
|
end
|
21
21
|
|
22
|
+
def distributor(type)
|
23
|
+
Distributor.new(type, alternates << nil)
|
24
|
+
end
|
25
|
+
|
22
26
|
def establish_connection(name, spec)
|
23
27
|
super.tap do
|
24
28
|
@class_to_alternate_pools[name] ||= {}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Wye
|
2
|
+
module Distributor
|
3
|
+
autoload :RoundRobin, 'wye/distributor/round_robin'
|
4
|
+
autoload :Sticky, 'wye/distributor/sticky'
|
5
|
+
|
6
|
+
def self.new(type, values)
|
7
|
+
klass = type.to_s.classify
|
8
|
+
raise "unknown distributor type" unless const_defined?(klass, false)
|
9
|
+
const_get(klass).new(values)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
data/lib/wye/version.rb
CHANGED
data/lib/wye.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wye
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -56,6 +56,9 @@ files:
|
|
56
56
|
- lib/wye/active_record/base.rb
|
57
57
|
- lib/wye/active_record/connection_handler.rb
|
58
58
|
- lib/wye/active_record.rb
|
59
|
+
- lib/wye/distributor/round_robin.rb
|
60
|
+
- lib/wye/distributor/sticky.rb
|
61
|
+
- lib/wye/distributor.rb
|
59
62
|
- lib/wye/railtie.rb
|
60
63
|
- lib/wye/switch.rb
|
61
64
|
- lib/wye/version.rb
|