xbar 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.mkdn CHANGED
@@ -153,6 +153,31 @@ automatically:
153
153
  @user.save
154
154
  ```
155
155
 
156
+ Another variant of `using` is `using_any`. It many be invoked as
157
+
158
+ ```ruby
159
+ # When the model is replicated, allow the find to take
160
+ # place on a slave.
161
+ User.using_any.find(...)
162
+
163
+ # When the model is replicated, allow the find to take place on
164
+ # any slave of the Canada shard.
165
+ User.using(:canada).find(...)
166
+
167
+ # This is essentially the same as the above.
168
+ XBar.using(:canada) do
169
+ User.using_any.find(...)
170
+ end
171
+
172
+ # The find will still take place on any slave of the Canada shard.
173
+ XBar.using(:brazil) do
174
+ User.using_any(:canada).find(...)
175
+ end
176
+ ```
177
+
178
+ The `using_any` construction only is valid for the immediately
179
+ following database 'select' type operation.
180
+
156
181
  ### Migrations
157
182
 
158
183
  In migrations, you also have access to the using method. The syntax is
@@ -1,5 +1,5 @@
1
1
  PATH
2
- remote: /opt/projects/xbar
2
+ remote: /Volumes/Opt/projects/xbar
3
3
  specs:
4
4
  xbar (0.4.0)
5
5
  activerecord
data/lib/xbar/model.rb CHANGED
@@ -126,6 +126,15 @@ module XBar::Model
126
126
  return XBar::ScopeProxy.new(shard_name, self)
127
127
  end
128
128
 
129
+ def using_any(shard_name = nil)
130
+ connection_proxy.slave_read_allowed = true
131
+ if shard_name
132
+ using(shard_name)
133
+ else
134
+ self
135
+ end
136
+ end
137
+
129
138
  def unreplicated_model
130
139
  if XBar.rails32?
131
140
  self._unreplicated = true
data/lib/xbar/proxy.rb CHANGED
@@ -18,6 +18,8 @@ class XBar::Proxy
18
18
  attr_reader :current_model, :current_shard
19
19
 
20
20
  attr_reader :shard_list
21
+
22
+ attr_accessor :slave_read_allowed
21
23
 
22
24
  def initialize
23
25
  puts "Initializing new proxy."
data/lib/xbar/shard.rb CHANGED
@@ -24,10 +24,11 @@ module XBar
24
24
  if XBar.debug
25
25
  puts("Shard##{BLUE_TEXT}run_queries#{RESET_COLORS}: " +
26
26
  "method = #{RED_TEXT}#{method}#{RESET_COLORS}, " +
27
- "shard= #{shard_name}, " +
27
+ "shard= #{shard_name}, slave_read=#{!!proxy.slave_read_allowed}, " +
28
28
  "block_scope = #{in_block_scope?}")
29
29
  end
30
- if method.to_s =~ /select/ && !in_block_scope? # XXX needed???, eventual flag??
30
+ if slave_read_allowed(method)
31
+ proxy.slave_read_allowed = false # just once
31
32
  # OK to send the query to a slave
32
33
  run_queries_on_slave(method, *args, &block)
33
34
  else
@@ -76,9 +77,14 @@ module XBar
76
77
  prepare_connection_pool(replica)
77
78
  replica.connection.send(method, *args, &block)
78
79
  end
80
+
81
+ def slave_read_allowed(method)
82
+ method.to_s =~ /select/ && !current_model.unreplicated_model? &&
83
+ (proxy.slave_read_allowed || !in_block_scope?)
84
+ end
79
85
 
80
86
  def run_queries_on_slave(method, *args, &block)
81
- if current_model.unreplicated_model? || @slaves.empty?
87
+ if @slaves.empty?
82
88
  replica = @master
83
89
  else
84
90
  if XBar.debug
data/lib/xbar/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module XBar
2
- VERSION = '0.4.0'
2
+ VERSION = '0.4.1'
3
3
  end
data/run CHANGED
@@ -24,4 +24,4 @@ fi
24
24
 
25
25
  echo $TEST
26
26
 
27
- bundle exec ${RUBY} ${RSPEC} -fd -c ${TEST}
27
+ bundle exec ${RUBY} ${RSPEC} -fd -b -c ${TEST}
@@ -28,7 +28,7 @@
28
28
 
29
29
  "environments": {
30
30
  "test": {
31
- "any_option": true,
31
+ "any_option": true,
32
32
  "shards": {
33
33
  "master": "mysql_m",
34
34
 
@@ -42,10 +42,12 @@
42
42
  "moscow": "moscow_s",
43
43
 
44
44
  "__COMMENT": "Postgres unreplicated shard (for now)",
45
- "__COMMENT": "One server has three different databases.",
45
+ "__COMMENT": "One server has three different databases.",
46
46
  "russia": ["russia_1", "russia_2", "russia_3"],
47
47
 
48
48
  "__COMMENT": "Convenience to get at the shard replicas as shards.",
49
+ "__COMMENT": "Some tests assume that the Russia environment is",
50
+ "__COMMENT": "not really replicated.",
49
51
  "russia_east": "russia_1",
50
52
  "russia_central": "russia_2",
51
53
  "russia_west": "russia_3",
@@ -65,14 +67,14 @@
65
67
  "china": ["china_1", "china_2"],
66
68
 
67
69
  "__COMMENT": "Convenience to get at the shard replicas as shards.",
68
- "__COMMENT": "Two different servers have the same-named database.",
70
+ "__COMMENT": "Two different servers have the same-named database.",
69
71
  "china_east": "china_1",
70
72
  "china_west": "china_2"
71
73
  }
72
74
  },
73
75
  "development": {
74
- "verify_connection": true,
75
- "favorite_color": "blue",
76
+ "verify_connection": true,
77
+ "favorite_color": "blue",
76
78
  "shards": {
77
79
  "master": "mysql_m",
78
80
 
@@ -86,7 +88,7 @@
86
88
  "moscow": "moscow_s",
87
89
 
88
90
  "__COMMENT": "Postgres unreplicated shard (for now)",
89
- "__COMMENT": "One server has three different databases.",
91
+ "__COMMENT": "One server has three different databases.",
90
92
  "russia": ["russia_1", "russia_2", "russia_3"],
91
93
 
92
94
  "__COMMENT": "Convenience to get at the shard replicas as shards.",
@@ -109,7 +111,7 @@
109
111
  "china": ["china_1", "china_2"],
110
112
 
111
113
  "__COMMENT": "Convenience to get at the shard replicas as shards.",
112
- "__COMMENT": "Two different servers have the same-named database.",
114
+ "__COMMENT": "Two different servers have the same-named database.",
113
115
  "china_east": "china_1",
114
116
  "china_west": "china_2"
115
117
  }
@@ -128,7 +130,7 @@
128
130
  "moscow": "moscow_s",
129
131
 
130
132
  "__COMMENT": "Postgres unreplicated shard (for now)",
131
- "__COMMENT": "One server has three different databases.",
133
+ "__COMMENT": "One server has three different databases.",
132
134
  "russia": ["russia_1", "russia_2", "russia_3"],
133
135
 
134
136
  "__COMMENT": "Convenience to get at the shard replicas as shards.",
@@ -151,10 +153,19 @@
151
153
  "china": ["china_1", "china_2"],
152
154
 
153
155
  "__COMMENT": "Convenience to get at the shard replicas as shards.",
154
- "__COMMENT": "Two different servers have the same-named database.",
156
+ "__COMMENT": "Two different servers have the same-named database.",
155
157
  "china_east": "china_1",
156
158
  "china_west": "china_2"
157
159
  }
160
+ },
161
+ "local_test": {
162
+ "shards": {
163
+ "master": "paris_s",
164
+ "russia": ["russia_1", "russia_2", "russia_3"],
165
+ "russia_east": "russia_1",
166
+ "russia_central": "russia_2",
167
+ "russia_west": "russia_3"
168
+ }
158
169
  }
159
170
  }
160
171
  }
@@ -31,6 +31,8 @@ ensure
31
31
  XBar::Mapper.reset(xbar_env: 'default', app_env: prev_env)
32
32
  end
33
33
 
34
+ alias :using_app_environment :using_environment
35
+
34
36
  def set_xbar_env(xbar_env, app_env = nil)
35
37
  opts = {xbar_env: xbar_env.to_s, :clear_cache => true}
36
38
  if app_env && !defined?(Rails)
@@ -1,8 +1,11 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
2
 
3
3
  describe "when the database is replicated" do
4
- it "should send all writes/reads queries to master when you have a non replicated model" do
5
- using_environment :production_replicated do
4
+ before(:each) do
5
+ set_xbar_env('default', 'local_test')
6
+ end
7
+ it "should send all writes/reads queries go to master by default" do
8
+ XBar.using(:russia) do
6
9
  u = User.create!(:name => "Replicated")
7
10
  User.count.should == 1
8
11
  User.find(u).should == u
@@ -10,64 +13,56 @@ describe "when the database is replicated" do
10
13
  end
11
14
 
12
15
  it "should send all writes queries to master" do
13
- using_environment :production_replicated do
14
- Cat.create!(:name => "Slave Cat")
15
- # The next line will break if the database really is replicated.
16
- # This test is assuming that no external mechanism is actually
17
- # propagating the writes.
18
- Cat.find_by_name("Slave Cat").should be_nil # will read from slave
19
- Client.create!(:name => "Slave Client")
20
- Client.find_by_name("Slave Client").should_not be_nil # will read from master
21
- end
16
+
17
+ # The Cat model is assumed replicated, so reads via that model
18
+ # with 'using_any' will go to the slave. Since the Russia shards
19
+ # are not really replicated, the "Slave Cat" will not be found.
20
+ Cat.using(:russia).create!(name: "Slave Cat")
21
+ Cat.using_any(:russia).find_by_name("Slave Cat").should be_nil
22
+
23
+ # The client model is declared to be unreplicated, so reads via that
24
+ # model will go to the master, even when we specify 'using_any'.
25
+ Client.using(:russia).create!(:name => "Slave Client")
26
+ Client.using_any(:russia).find_by_name("Slave Client").should_not be_nil
22
27
  end
23
28
 
24
- it "should allow to create multiple models on the master" do
25
- using_environment :production_replicated do
29
+ it "should allow creation of multiple models on the shard master" do
30
+ XBar.using(:russia) do
26
31
  Cat.create!([{:name => "Slave Cat 1"}, {:name => "Slave Cat 2"}])
27
- Cat.find_by_name("Slave Cat 1").should be_nil
28
- Cat.find_by_name("Slave Cat 2").should be_nil
29
- Cat.using(:master).find_by_name("Slave Cat 1").should_not be_nil # MBS
30
- Cat.using(:master).find_by_name("Slave Cat 2").should_not be_nil # MBS
32
+ Cat.using_any.find_by_name("Slave Cat 1").should be_nil # reads from russia_2
33
+ Cat.using_any.find_by_name("Slave Cat 2").should be_nil # reads from russia_3
34
+ Cat.find_by_name("Slave Cat 1").should_not be_nil # reads from master
35
+ Cat.find_by_name("Slave Cat 2").should_not be_nil # reads from master
31
36
  end
32
37
  end
33
38
 
34
- it "should allow #using syntax to send queries to master" do
35
- Cat.create!(:name => "Master Cat")
36
-
37
- using_environment :production_fully_replicated do
38
- Cat.using(:master).find_by_name("Master Cat").should_not be_nil
39
+ it "should allow using syntax to send queries to the shard master" do
40
+ XBar.using(:russia) do
41
+ Cat.create!(:name => "Master Cat")
42
+ Cat.using(:russia_east).find_by_name("Master Cat").should_not be_nil
39
43
  end
40
44
  end
41
45
 
42
46
  it "should send the count query to a slave" do
43
- pending()
44
- # using_environment :production_replicated do
45
- # Cat.create!(:name => "Slave Cat")
46
- # Cat.count.should == 0
47
- # end
48
- end
49
- end
50
-
51
-
52
- describe "when the database is replicated and the entire application is replicated" do
53
- before(:each) do
54
- XBar.stub!(:env).and_return("production_fully_replicated")
55
- clean_connection_proxy()
47
+ XBar.using(:russia) do
48
+ Cat.create!(:name => "Slave Cat")
49
+ Cat.using_any.count.should == 0
50
+ Cat.using(:russia_east).count.should == 1 # the shard master
51
+ end
56
52
  end
57
53
 
58
54
  it "should send all writes queries to master" do
59
- using_environment :production_fully_replicated do
55
+ XBar.using(:russia) do
60
56
  Cat.create!(:name => "Slave Cat")
61
- Cat.find_by_name("Slave Cat").should be_nil
57
+ Cat.using_any.find_by_name("Slave Cat").should be_nil
62
58
  Client.create!(:name => "Slave Client")
63
- Client.find_by_name("Slave Client").should be_nil
59
+ Client.using_any.find_by_name("Slave Client").should_not be_nil
64
60
  end
65
61
  end
66
62
 
67
63
  it "should work with validate_uniquess_of" do
68
- Keyboard.create!(:name => "thiago")
69
-
70
- using_environment :production_fully_replicated do
64
+ XBar.using(:russia) do
65
+ Keyboard.create!(:name => "thiago")
71
66
  k = Keyboard.new(:name => "thiago")
72
67
  k.save.should be_false
73
68
  if XBar.rails31?
@@ -78,17 +73,19 @@ describe "when the database is replicated and the entire application is replicat
78
73
  end
79
74
  end
80
75
 
81
- it "should reset current shard if slave throws an exception" do
82
-
83
- using_environment :production_fully_replicated do
76
+ it "should reset slave read allowed if slave throws an exception" do
77
+ XBar.using(:russia) do
84
78
  Cat.create!(:name => "Slave Cat")
85
- Cat.connection.current_shard.should eql(:master)
79
+ Cat.connection.current_shard.should eql(:russia)
86
80
  begin
87
- Cat.find(:all, :conditions => 'rubbish = true')
81
+ Cat.using_any.find(:all, :conditions => 'rubbish = true')
88
82
  rescue
89
83
  end
90
- Cat.connection.current_shard.should eql(:master)
84
+ Cat.connection.current_shard.should eql(:russia)
85
+ Cat.connection.slave_read_allowed.should_not be_true
91
86
  end
92
87
  end
88
+
93
89
  end
94
90
 
91
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xbar
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-02-07 00:00:00.000000000 Z
12
+ date: 2012-02-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &70299244954380 !ruby/object:Gem::Requirement
16
+ requirement: &70184876580280 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70299244954380
24
+ version_requirements: *70184876580280
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: mysql2
27
- requirement: &70299244952740 !ruby/object:Gem::Requirement
27
+ requirement: &70184876579860 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70299244952740
35
+ version_requirements: *70184876579860
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: activerecord
38
- requirement: &70299244951780 !ruby/object:Gem::Requirement
38
+ requirement: &70184876579440 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70299244951780
46
+ version_requirements: *70184876579440
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rake
49
- requirement: &70299244965880 !ruby/object:Gem::Requirement
49
+ requirement: &70184876579000 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70299244965880
57
+ version_requirements: *70184876579000
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: actionpack
60
- requirement: &70299244961660 !ruby/object:Gem::Requirement
60
+ requirement: &70184876578580 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70299244961660
68
+ version_requirements: *70184876578580
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: appraisal
71
- requirement: &70299244971220 !ruby/object:Gem::Requirement
71
+ requirement: &70184876506720 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: '0'
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *70299244971220
79
+ version_requirements: *70184876506720
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: rspec
82
- requirement: &70299244983260 !ruby/object:Gem::Requirement
82
+ requirement: &70184876506180 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - =
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: 2.8.0
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *70299244983260
90
+ version_requirements: *70184876506180
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: mysql2
93
- requirement: &70299244979900 !ruby/object:Gem::Requirement
93
+ requirement: &70184876505720 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ! '>='
@@ -98,10 +98,10 @@ dependencies:
98
98
  version: '0'
99
99
  type: :development
100
100
  prerelease: false
101
- version_requirements: *70299244979900
101
+ version_requirements: *70184876505720
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: pg
104
- requirement: &70299244977220 !ruby/object:Gem::Requirement
104
+ requirement: &70184876505260 !ruby/object:Gem::Requirement
105
105
  none: false
106
106
  requirements:
107
107
  - - ! '>='
@@ -109,10 +109,10 @@ dependencies:
109
109
  version: '0'
110
110
  type: :development
111
111
  prerelease: false
112
- version_requirements: *70299244977220
112
+ version_requirements: *70184876505260
113
113
  - !ruby/object:Gem::Dependency
114
114
  name: sqlite3
115
- requirement: &70299244991040 !ruby/object:Gem::Requirement
115
+ requirement: &70184876504820 !ruby/object:Gem::Requirement
116
116
  none: false
117
117
  requirements:
118
118
  - - ! '>='
@@ -120,10 +120,10 @@ dependencies:
120
120
  version: '0'
121
121
  type: :development
122
122
  prerelease: false
123
- version_requirements: *70299244991040
123
+ version_requirements: *70184876504820
124
124
  - !ruby/object:Gem::Dependency
125
125
  name: syntax
126
- requirement: &70299244989980 !ruby/object:Gem::Requirement
126
+ requirement: &70184876504380 !ruby/object:Gem::Requirement
127
127
  none: false
128
128
  requirements:
129
129
  - - ! '>='
@@ -131,7 +131,7 @@ dependencies:
131
131
  version: '0'
132
132
  type: :development
133
133
  prerelease: false
134
- version_requirements: *70299244989980
134
+ version_requirements: *70184876504380
135
135
  description: Supports MongoDB style sharding and mirroring
136
136
  email:
137
137
  - lydianblues@gmail.com
@@ -183,14 +183,7 @@ files:
183
183
  - spec/config/default.json
184
184
  - spec/config/duplicate_shard.json
185
185
  - spec/config/missing_key.json
186
- - spec/config/new_shards.json
187
186
  - spec/config/no_master_shard.json
188
- - spec/config/not_entire_sharded.json
189
- - spec/config/octopus.json
190
- - spec/config/octopus_rails.json
191
- - spec/config/production_fully_replicated.json
192
- - spec/config/production_raise_error.json
193
- - spec/config/simple.json
194
187
  - spec/config/single_adapter.json
195
188
  - spec/console.rb
196
189
  - spec/migrations/10_create_users_using_replication.rb
@@ -234,7 +227,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
234
227
  version: '0'
235
228
  segments:
236
229
  - 0
237
- hash: -1412410971893777561
230
+ hash: 2639363329198087997
238
231
  required_rubygems_version: !ruby/object:Gem::Requirement
239
232
  none: false
240
233
  requirements:
@@ -243,7 +236,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
243
236
  version: '0'
244
237
  segments:
245
238
  - 0
246
- hash: -1412410971893777561
239
+ hash: 2639363329198087997
247
240
  requirements: []
248
241
  rubyforge_project: xbar
249
242
  rubygems_version: 1.8.15
@@ -256,14 +249,7 @@ test_files:
256
249
  - spec/config/default.json
257
250
  - spec/config/duplicate_shard.json
258
251
  - spec/config/missing_key.json
259
- - spec/config/new_shards.json
260
252
  - spec/config/no_master_shard.json
261
- - spec/config/not_entire_sharded.json
262
- - spec/config/octopus.json
263
- - spec/config/octopus_rails.json
264
- - spec/config/production_fully_replicated.json
265
- - spec/config/production_raise_error.json
266
- - spec/config/simple.json
267
253
  - spec/config/single_adapter.json
268
254
  - spec/console.rb
269
255
  - spec/migrations/10_create_users_using_replication.rb
@@ -1,29 +0,0 @@
1
- {
2
- "connections": {
3
- "p1": "postgres://user:password@alpha.server.com:5432/mydatabase?encoding=unicode&pool=5",
4
- "p2": "postgres://user:password@beta.server.com:5432/mydatabase?encoding=unicode&pool=5",
5
- "m1": "mysql://user:password@alpha.server.com:3306/mydatabase?pool=10",
6
- "m2": "postgres://user:password@beta.server.com:3306/mydatabase?pool=10",
7
- "m3": {"database": "xbar_shard5", "adapter": "mysql2", "host": "localhost" }
8
- },
9
- "environments": {
10
- "development": {
11
- "shards": [
12
- {"name": "shard_one", "connections": ["p1", "p2"]},
13
- {"name": "shard_one", "connections": ["p1", "p2"]}
14
- ]
15
- },
16
- "test": {
17
- "shards": [
18
- {"name": "shard_one", "connections": ["p1", "p2"]},
19
- {"name": "shard_one", "connections": ["p1", "p2"]}
20
- ]
21
- },
22
- "production": {
23
- "shards": [
24
- {"name": "shard_one", "connections": ["p1", "p2"]},
25
- {"name": "shard_one", "connections": ["p1", "p2"]}
26
- ]
27
- }
28
- }
29
- }
@@ -1,23 +0,0 @@
1
- {
2
- "__COMMENT": "Not Entire Sharded",
3
-
4
- "entire_sharded": false,
5
-
6
- "connections": {
7
- "europe": {"database": "xbar_shard2", "adapter": "mysql2", "host": "localhost"},
8
- "canada": {"database": "xbar_shard3", "adapter": "mysql2", "host": "localhost"},
9
- "brazil": {"database": "xbar_shard4", "adapter": "mysql2", "host": "localhost"},
10
- "russia": {"database": "xbar_shard5", "adapter": "mysql2", "host": "localhost"}
11
- },
12
-
13
- "environments": {
14
- "shards": {
15
- "shards": {
16
- "europe": "europe",
17
- "canada": "canada",
18
- "brazil": "brazil",
19
- "russia": "russia"
20
- }
21
- }
22
- }
23
- }
@@ -1,27 +0,0 @@
1
- {
2
- "__COMMENT": "Shards for the XBar meta-environment.",
3
-
4
- "connections": {
5
- "alone_shard": "mysql2://localhost/xbar_shard5",
6
- "aug2009": {"database": "xbar_shard2", "adapter": "mysql2", "host": "localhost"},
7
- "aug2010": {"database": "xbar_shard3", "adapter": "mysql2", "host": "localhost"},
8
- "aug2011": {"database": "xbar_shard4", "adapter": "mysql2", "host": "localhost"},
9
- "postgresql_shard": {"adapter": "postgresql", "username": "postgres", "password": null,
10
- "database": "xbar_shard1", "encoding": "unicode"},
11
- "sqlite_shard": { "adapter": "sqlite3", "database": "/tmp/database.sqlite3"},
12
- "canada": "mysql2://localhost/xbar_shard2",
13
- "brazil": {"database": "xbar_shard3", "adapter": "mysql2", "host": "localhost"},
14
- "russia": {"database": "xbar_shard4", "adapter": "mysql2", "host": "localhost"}
15
- },
16
- "environments": {
17
- "shards": {
18
- "shards": {
19
- "alone_shard": "alone_shard",
20
- "postgresql_shard": "postgresql_shard",
21
- "sqlite_shard": "sqlite_shard",
22
- "history_shard": ["aug2009", "aug2010", "aug2011"],
23
- "country_shard": ["canada", "brazil", "russia"]
24
- }
25
- }
26
- }
27
- }
@@ -1,25 +0,0 @@
1
- {
2
- "__COMMENT": "XBar Rails Mapperuration",
3
- "replicated": true,
4
- "verify_connection": true,
5
- "connections": {
6
- "slave1": {"database": "xbar_shard2", "adapter": "mysql2", "host": "localhost"},
7
- "slave2": {"database": "xbar_shard3", "adapter": "mysql2", "host": "localhost"},
8
- "slave3": {"database": "xbar_shard4", "adapter": "mysql2", "host": "localhost"},
9
- "slave4": {"database": "xbar_shard5", "adapter": "mysql2", "host": "localhost"}
10
- },
11
- "environments": {
12
- "staging": {
13
- "shards": {
14
- "slave1": "slave1",
15
- "slave2": "slave2"
16
- }
17
- },
18
- "production": {
19
- "shards": {
20
- "slave3": "slave3",
21
- "slave4": "slave4"
22
- }
23
- }
24
- }
25
- }
@@ -1,21 +0,0 @@
1
- {
2
- "__COMMENT": "Production Fully Replicated",
3
- "replicated": true,
4
- "connections": {
5
- "slave1": {"database": "xbar_shard2", "adapter": "mysql2", "host": "localhost"},
6
- "slave2": {"database": "xbar_shard3", "adapter": "mysql2", "host": "localhost"},
7
- "slave3": {"database": "xbar_shard4", "adapter": "mysql2", "host": "localhost"},
8
- "slave4": {"database": "xbar_shard5", "adapter": "mysql2", "host": "localhost"}
9
- },
10
-
11
- "environments": {
12
- "shards": {
13
- "shards": {
14
- "slave1": "slave1",
15
- "slave2": "slave2",
16
- "slave3": "slave3",
17
- "slave4": "slave4"
18
- }
19
- }
20
- }
21
- }
@@ -1,17 +0,0 @@
1
- {
2
- "__COMMENT": "Production Raise Error",
3
-
4
- "connections": {
5
- "duplicated_shard_name": {"database": "xbar_shard5", "adapter": "mysql2", "host": "localhost"},
6
- "duplicated_shard_name": {"database": "xbar_shard4", "adapter": "mysql2", "host": "localhost"}
7
- },
8
-
9
- "environments": {
10
- "shards": {
11
- "shards": {
12
- "history_shard": "duplicated_shard_name",
13
- "country_shard": "duplicated_shard_name"
14
- }
15
- }
16
- }
17
- }
@@ -1,22 +0,0 @@
1
- {
2
- "__COMMENT": "Simple SQLite French Environment",
3
-
4
- "connections": {
5
- "paris_m": { "adapter": "sqlite3", "database": "/tmp/paris.sqlite3"},
6
- "france_1": { "adapter": "sqlite3", "database": "/tmp/france_1.sqlite3"},
7
- "france_2": { "adapter": "sqlite3", "database": "/tmp/france_2.sqlite3"},
8
- "france_3": { "adapter": "sqlite3", "database": "/tmp/france_3.sqlite3"}
9
- },
10
-
11
- "environments": {
12
- "test": {
13
- "shards": {
14
- "master": "paris_m",
15
- "france": ["france_1", "france_2", "france_3"],
16
- "france_nord": "france_1",
17
- "france_central": "france_2",
18
- "france_sud": "france_3"
19
- }
20
- }
21
- }
22
- }