switchman 1.12.11 → 1.12.12
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 809ad5808c045d1b4f9b2e7ac5084b0d10ced204c76d85b6649ec8a55384dd04
|
4
|
+
data.tar.gz: bba8310639966bc33a47ada04d46628a15ddf7a531e92c9ff9cecd9e1050a338
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6ccf69f1a56258e1bd8b1c1dd915f50bb2b7fbff026168a08aadb5a71d7ede117bdebfaff48ea0ecd870295d0be810e1f425dd864dbd0ca2532c882b241d8973
|
7
|
+
data.tar.gz: 8b12e4e22e15e7cfbbc9e635f4b9d6c035ccc20d21afdbc347b9f1ddc6c906dc507362c936cb2de65a52f00de8d6bc96ae7d6e64f1ed5e9f5600a49ac42fc0a6
|
@@ -28,6 +28,8 @@ module Switchman
|
|
28
28
|
after_save :clear_cache
|
29
29
|
after_destroy :clear_cache
|
30
30
|
|
31
|
+
after_rollback :on_rollback
|
32
|
+
|
31
33
|
scope :primary, -> { where(name: nil).order(:database_server_id, :id).distinct_on(:database_server_id) }
|
32
34
|
|
33
35
|
class << self
|
@@ -676,6 +678,18 @@ module Switchman
|
|
676
678
|
database_server.shard_name(self)
|
677
679
|
end
|
678
680
|
|
681
|
+
def on_rollback
|
682
|
+
# make sure all connection pool proxies are referencing valid pools
|
683
|
+
::ActiveRecord::Base.connection_handler.connection_pools.each do |pool|
|
684
|
+
next unless pool.is_a?(ConnectionPoolProxy)
|
685
|
+
::Shackles.activated_environments.each do |env|
|
686
|
+
::Shackles.activate(env) do
|
687
|
+
pool.current_pool
|
688
|
+
end
|
689
|
+
end
|
690
|
+
end
|
691
|
+
end
|
692
|
+
|
679
693
|
def hashify_categories(categories)
|
680
694
|
if categories.empty?
|
681
695
|
{ :primary => self }
|
@@ -4,11 +4,11 @@ module Switchman
|
|
4
4
|
module ActiveRecord
|
5
5
|
module ConnectionPool
|
6
6
|
def shard
|
7
|
-
Thread.current[
|
7
|
+
Thread.current[tls_key] || Shard.default
|
8
8
|
end
|
9
9
|
|
10
10
|
def shard=(value)
|
11
|
-
Thread.current[
|
11
|
+
Thread.current[tls_key] = value
|
12
12
|
end
|
13
13
|
|
14
14
|
def default_schema
|
@@ -84,6 +84,12 @@ module Switchman
|
|
84
84
|
end
|
85
85
|
conn.shard = shard
|
86
86
|
end
|
87
|
+
|
88
|
+
private
|
89
|
+
|
90
|
+
def tls_key
|
91
|
+
"#{object_id}_shard".to_sym
|
92
|
+
end
|
87
93
|
end
|
88
94
|
end
|
89
95
|
end
|
data/lib/switchman/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: switchman
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.12.
|
4
|
+
version: 1.12.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cody Cutrer
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2018-
|
13
|
+
date: 2018-10-12 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: railties
|
@@ -259,7 +259,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
259
259
|
version: '0'
|
260
260
|
requirements: []
|
261
261
|
rubyforge_project:
|
262
|
-
rubygems_version: 2.7.
|
262
|
+
rubygems_version: 2.7.2
|
263
263
|
signing_key:
|
264
264
|
specification_version: 4
|
265
265
|
summary: Rails 4 sharding magic
|