yam-db-charmer 1.7.4.9 → 1.7.4.10
Sign up to get free protection for your applications and to get access to all the features.
@@ -97,6 +97,16 @@ module DbCharmer
|
|
97
97
|
@@db_charmer_database_remappings = mappings || { }
|
98
98
|
end
|
99
99
|
|
100
|
+
#-----------------------------------------------------------------------------
|
101
|
+
@@db_charmer_allocated_shard_connection = nil
|
102
|
+
def db_charmer_allocated_shard_connection
|
103
|
+
@@db_charmer_allocated_shard_connection
|
104
|
+
end
|
105
|
+
|
106
|
+
def db_charmer_allocated_shard_connection=(conn)
|
107
|
+
@@db_charmer_allocated_shard_connection = conn
|
108
|
+
end
|
109
|
+
|
100
110
|
# For sharded models, return the table name without the schema prefix
|
101
111
|
def table_name_without_schema
|
102
112
|
if self.respond_to?(:orig_table_name)
|
@@ -36,6 +36,9 @@ module DbCharmer
|
|
36
36
|
class << self
|
37
37
|
# Make sure we check our accessors before going to the default connection retrieval method
|
38
38
|
def connection_with_magic
|
39
|
+
if db_charmer_allocated_shard_connection
|
40
|
+
return coerce_to_connection_proxy(db_charmer_allocated_shard_connection, true)
|
41
|
+
end
|
39
42
|
db_charmer_remapped_connection || db_charmer_connection_proxy || connection_without_magic
|
40
43
|
end
|
41
44
|
alias_method_chain :connection, :magic
|
@@ -18,8 +18,11 @@ module DbCharmer
|
|
18
18
|
group = sharder.least_loaded_group
|
19
19
|
shard_info = sharder.shard_info_by_group_id(group.id)
|
20
20
|
conn = sharder.shard_connection_config(shard_info, group.id)
|
21
|
+
# Set global shard connection obj
|
22
|
+
self.db_charmer_allocated_shard_connection = conn
|
21
23
|
key_obj = on_db(conn, nil, &block)
|
22
|
-
|
24
|
+
self.db_charmer_allocated_shard_connection = nil
|
25
|
+
sharder.allocate_new_block_for_key_on_group(key_obj.send(key_field), group)
|
23
26
|
key_obj
|
24
27
|
end
|
25
28
|
|
data/lib/db_charmer/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yam-db-charmer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 99
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 7
|
9
9
|
- 4
|
10
|
-
-
|
11
|
-
version: 1.7.4.
|
10
|
+
- 10
|
11
|
+
version: 1.7.4.10
|
12
12
|
platform: ruby
|
13
13
|
authors:
|
14
14
|
- Oleksiy Kovyrin
|
@@ -17,7 +17,7 @@ autorequire:
|
|
17
17
|
bindir: bin
|
18
18
|
cert_chain: []
|
19
19
|
|
20
|
-
date: 2012-10-
|
20
|
+
date: 2012-10-19 00:00:00 -07:00
|
21
21
|
default_executable:
|
22
22
|
dependencies:
|
23
23
|
- !ruby/object:Gem::Dependency
|