switchman 1.9.2 → 1.9.3
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.
- checksums.yaml +4 -4
 - data/app/models/switchman/shard.rb +1 -1
 - data/lib/switchman/engine.rb +2 -2
 - data/lib/switchman/r_spec_helper.rb +2 -2
 - data/lib/switchman/version.rb +1 -1
 - data/lib/tasks/switchman.rake +15 -13
 - metadata +7 -21
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: dd6a78ff6974c70fd495154833ff83a7b1408d89
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: a6ba5ec6032e7b82d808115cc09ce37d10a89b09
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 9a3a696130257d94b959fd6ef57e200196fe9993aa066a356b6ebde4ef56076ac342bbd8bc866eb45e1e0c9cd3229201972b039a02f209b258ecc2788fabfa6a
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: ce87fe2d582572246d05c7761b61fd3b4b1ce7dc49d90e0cf9037de78edfd73e67ba7641c87e6737320aca0b2ac30e8191d570f45ca82454ff045fc77dfc6158
         
     | 
| 
         @@ -8,4 +8,4 @@ ActiveRecord::Base 
     | 
|
| 
       8 
8 
     | 
    
         
             
            # we need to make sure we define the class someone wanted (in which case
         
     | 
| 
       9 
9 
     | 
    
         
             
            # AR's on_load hook won't be called either yet, and establish_connection
         
     | 
| 
       10 
10 
     | 
    
         
             
            # will be safe)
         
     | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
      
 11 
     | 
    
         
            +
            require_dependency 'switchman/shard_internal'
         
     | 
    
        data/lib/switchman/engine.rb
    CHANGED
    
    | 
         @@ -2,7 +2,7 @@ module Switchman 
     | 
|
| 
       2 
2 
     | 
    
         
             
              class Engine < ::Rails::Engine
         
     | 
| 
       3 
3 
     | 
    
         
             
                isolate_namespace Switchman
         
     | 
| 
       4 
4 
     | 
    
         | 
| 
       5 
     | 
    
         
            -
                config.autoload_once_paths << File.expand_path( 
     | 
| 
      
 5 
     | 
    
         
            +
                config.autoload_once_paths << File.expand_path("app/models", config.paths.path)
         
     | 
| 
       6 
6 
     | 
    
         | 
| 
       7 
7 
     | 
    
         
             
                def self.lookup_stores(cache_store_config)
         
     | 
| 
       8 
8 
     | 
    
         
             
                  result = {}
         
     | 
| 
         @@ -87,7 +87,7 @@ module Switchman 
     | 
|
| 
       87 
87 
     | 
    
         
             
                    require "switchman/call_super"
         
     | 
| 
       88 
88 
     | 
    
         
             
                    require "switchman/rails"
         
     | 
| 
       89 
89 
     | 
    
         
             
                    require "switchman/shackles/relation"
         
     | 
| 
       90 
     | 
    
         
            -
                     
     | 
| 
      
 90 
     | 
    
         
            +
                    require_dependency "switchman/shard_internal"
         
     | 
| 
       91 
91 
     | 
    
         
             
                    require "switchman/standard_error"
         
     | 
| 
       92 
92 
     | 
    
         | 
| 
       93 
93 
     | 
    
         
             
                    ::StandardError.include(StandardError)
         
     | 
| 
         @@ -118,7 +118,7 @@ module Switchman 
     | 
|
| 
       118 
118 
     | 
    
         
             
                  klass.before do
         
     | 
| 
       119 
119 
     | 
    
         
             
                    raise "Sharding did not set up correctly" if @@sharding_failed
         
     | 
| 
       120 
120 
     | 
    
         
             
                    Shard.clear_cache
         
     | 
| 
       121 
     | 
    
         
            -
                    if use_transactional_fixtures
         
     | 
| 
      
 121 
     | 
    
         
            +
                    if (::Rails.version >= '5' && use_transactional_tests) || use_transactional_fixtures
         
     | 
| 
       122 
122 
     | 
    
         
             
                      Shard.default(true)
         
     | 
| 
       123 
123 
     | 
    
         
             
                      @shard1 = Shard.find(@shard1.id)
         
     | 
| 
       124 
124 
     | 
    
         
             
                      @shard2 = Shard.find(@shard2.id)
         
     | 
| 
         @@ -134,7 +134,7 @@ module Switchman 
     | 
|
| 
       134 
134 
     | 
    
         | 
| 
       135 
135 
     | 
    
         
             
                  klass.after do
         
     | 
| 
       136 
136 
     | 
    
         
             
                    next if @@sharding_failed
         
     | 
| 
       137 
     | 
    
         
            -
                    if use_transactional_fixtures
         
     | 
| 
      
 137 
     | 
    
         
            +
                    if (::Rails.version >= '5' && use_transactional_tests) || use_transactional_fixtures
         
     | 
| 
       138 
138 
     | 
    
         
             
                      shards = [@shard2]
         
     | 
| 
       139 
139 
     | 
    
         
             
                      shards << @shard1 unless @shard1.database_server == Shard.default.database_server
         
     | 
| 
       140 
140 
     | 
    
         
             
                      shards.each do |shard|
         
     | 
    
        data/lib/switchman/version.rb
    CHANGED
    
    
    
        data/lib/tasks/switchman.rake
    CHANGED
    
    | 
         @@ -60,21 +60,23 @@ module Switchman 
     | 
|
| 
       60 
60 
     | 
    
         
             
                    end
         
     | 
| 
       61 
61 
     | 
    
         | 
| 
       62 
62 
     | 
    
         
             
                    ::Shackles.activate(:deploy) do
         
     | 
| 
       63 
     | 
    
         
            -
                       
     | 
| 
       64 
     | 
    
         
            -
                         
     | 
| 
       65 
     | 
    
         
            -
             
     | 
| 
       66 
     | 
    
         
            -
                           
     | 
| 
       67 
     | 
    
         
            -
             
     | 
| 
       68 
     | 
    
         
            -
             
     | 
| 
       69 
     | 
    
         
            -
             
     | 
| 
       70 
     | 
    
         
            -
             
     | 
| 
       71 
     | 
    
         
            -
                             
     | 
| 
      
 63 
     | 
    
         
            +
                      Shard.default.database_server.unshackle do
         
     | 
| 
      
 64 
     | 
    
         
            +
                        begin
         
     | 
| 
      
 65 
     | 
    
         
            +
                          categories = categories.call if categories.respond_to?(:call)
         
     | 
| 
      
 66 
     | 
    
         
            +
                          Shard.with_each_shard(scope, categories, options) do
         
     | 
| 
      
 67 
     | 
    
         
            +
                            shard = Shard.current
         
     | 
| 
      
 68 
     | 
    
         
            +
                            puts "#{shard.id}: #{shard.description}"
         
     | 
| 
      
 69 
     | 
    
         
            +
                            ::ActiveRecord::Base.connection_pool.spec.config[:shard_name] = Shard.current.name
         
     | 
| 
      
 70 
     | 
    
         
            +
                            ::ActiveRecord::Base.configurations[::Rails.env] = ::ActiveRecord::Base.connection_pool.spec.config.stringify_keys
         
     | 
| 
      
 71 
     | 
    
         
            +
                            shard.database_server.unshackle do
         
     | 
| 
      
 72 
     | 
    
         
            +
                              old_actions.each { |action| action.call(*task_args) }
         
     | 
| 
      
 73 
     | 
    
         
            +
                            end
         
     | 
| 
      
 74 
     | 
    
         
            +
                            nil
         
     | 
| 
       72 
75 
     | 
    
         
             
                          end
         
     | 
| 
       73 
     | 
    
         
            -
             
     | 
| 
      
 76 
     | 
    
         
            +
                        rescue => e
         
     | 
| 
      
 77 
     | 
    
         
            +
                          puts "Exception from #{e.current_shard.id}: #{e.current_shard.description}" if options[:parallel] != 0
         
     | 
| 
      
 78 
     | 
    
         
            +
                          raise
         
     | 
| 
       74 
79 
     | 
    
         
             
                        end
         
     | 
| 
       75 
     | 
    
         
            -
                      rescue => e
         
     | 
| 
       76 
     | 
    
         
            -
                        puts "Exception from #{e.current_shard.id}: #{e.current_shard.description}" if options[:parallel] != 0
         
     | 
| 
       77 
     | 
    
         
            -
                        raise
         
     | 
| 
       78 
80 
     | 
    
         
             
                      end
         
     | 
| 
       79 
81 
     | 
    
         
             
                    end
         
     | 
| 
       80 
82 
     | 
    
         
             
                  end
         
     | 
    
        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.9. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 1.9.3
         
     | 
| 
       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:  
     | 
| 
      
 13 
     | 
    
         
            +
            date: 2017-02-02 00:00:00.000000000 Z
         
     | 
| 
       14 
14 
     | 
    
         
             
            dependencies:
         
     | 
| 
       15 
15 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       16 
16 
     | 
    
         
             
              name: railties
         
     | 
| 
         @@ -108,20 +108,6 @@ dependencies: 
     | 
|
| 
       108 
108 
     | 
    
         
             
                - - ">="
         
     | 
| 
       109 
109 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       110 
110 
     | 
    
         
             
                    version: '0'
         
     | 
| 
       111 
     | 
    
         
            -
            - !ruby/object:Gem::Dependency
         
     | 
| 
       112 
     | 
    
         
            -
              name: mysql2
         
     | 
| 
       113 
     | 
    
         
            -
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
       114 
     | 
    
         
            -
                requirements:
         
     | 
| 
       115 
     | 
    
         
            -
                - - "~>"
         
     | 
| 
       116 
     | 
    
         
            -
                  - !ruby/object:Gem::Version
         
     | 
| 
       117 
     | 
    
         
            -
                    version: '0.3'
         
     | 
| 
       118 
     | 
    
         
            -
              type: :development
         
     | 
| 
       119 
     | 
    
         
            -
              prerelease: false
         
     | 
| 
       120 
     | 
    
         
            -
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
       121 
     | 
    
         
            -
                requirements:
         
     | 
| 
       122 
     | 
    
         
            -
                - - "~>"
         
     | 
| 
       123 
     | 
    
         
            -
                  - !ruby/object:Gem::Version
         
     | 
| 
       124 
     | 
    
         
            -
                    version: '0.3'
         
     | 
| 
       125 
111 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       126 
112 
     | 
    
         
             
              name: pg
         
     | 
| 
       127 
113 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
         @@ -142,14 +128,14 @@ dependencies: 
     | 
|
| 
       142 
128 
     | 
    
         
             
                requirements:
         
     | 
| 
       143 
129 
     | 
    
         
             
                - - '='
         
     | 
| 
       144 
130 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       145 
     | 
    
         
            -
                    version: 3. 
     | 
| 
      
 131 
     | 
    
         
            +
                    version: 3.5.2
         
     | 
| 
       146 
132 
     | 
    
         
             
              type: :development
         
     | 
| 
       147 
133 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       148 
134 
     | 
    
         
             
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
       149 
135 
     | 
    
         
             
                requirements:
         
     | 
| 
       150 
136 
     | 
    
         
             
                - - '='
         
     | 
| 
       151 
137 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       152 
     | 
    
         
            -
                    version: 3. 
     | 
| 
      
 138 
     | 
    
         
            +
                    version: 3.5.2
         
     | 
| 
       153 
139 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       154 
140 
     | 
    
         
             
              name: sqlite3
         
     | 
| 
       155 
141 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
         @@ -170,14 +156,14 @@ dependencies: 
     | 
|
| 
       170 
156 
     | 
    
         
             
                requirements:
         
     | 
| 
       171 
157 
     | 
    
         
             
                - - "~>"
         
     | 
| 
       172 
158 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       173 
     | 
    
         
            -
                    version: ' 
     | 
| 
      
 159 
     | 
    
         
            +
                    version: '12.0'
         
     | 
| 
       174 
160 
     | 
    
         
             
              type: :development
         
     | 
| 
       175 
161 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       176 
162 
     | 
    
         
             
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
       177 
163 
     | 
    
         
             
                requirements:
         
     | 
| 
       178 
164 
     | 
    
         
             
                - - "~>"
         
     | 
| 
       179 
165 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       180 
     | 
    
         
            -
                    version: ' 
     | 
| 
      
 166 
     | 
    
         
            +
                    version: '12.0'
         
     | 
| 
       181 
167 
     | 
    
         
             
            description: Sharding
         
     | 
| 
       182 
168 
     | 
    
         
             
            email:
         
     | 
| 
       183 
169 
     | 
    
         
             
            - cody@instructure.com
         
     | 
| 
         @@ -256,7 +242,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       256 
242 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       257 
243 
     | 
    
         
             
            requirements: []
         
     | 
| 
       258 
244 
     | 
    
         
             
            rubyforge_project: 
         
     | 
| 
       259 
     | 
    
         
            -
            rubygems_version: 2. 
     | 
| 
      
 245 
     | 
    
         
            +
            rubygems_version: 2.6.10
         
     | 
| 
       260 
246 
     | 
    
         
             
            signing_key: 
         
     | 
| 
       261 
247 
     | 
    
         
             
            specification_version: 4
         
     | 
| 
       262 
248 
     | 
    
         
             
            summary: Rails 4 sharding magic
         
     |