switchman 1.16.0 → 2.0.5

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.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/app/models/switchman/shard.rb +10 -5
  3. data/db/migrate/20130328212039_create_switchman_shards.rb +2 -0
  4. data/db/migrate/20130328224244_create_default_shard.rb +3 -1
  5. data/db/migrate/20161206323434_add_back_default_string_limits_switchman.rb +2 -0
  6. data/db/migrate/20180828183945_add_default_shard_index.rb +2 -0
  7. data/db/migrate/20180828192111_add_timestamps_to_shards.rb +2 -0
  8. data/db/migrate/20190114212900_add_unique_name_indexes.rb +2 -0
  9. data/lib/switchman.rb +3 -1
  10. data/lib/switchman/action_controller/caching.rb +2 -0
  11. data/lib/switchman/active_record/abstract_adapter.rb +8 -2
  12. data/lib/switchman/active_record/association.rb +10 -4
  13. data/lib/switchman/active_record/attribute_methods.rb +2 -0
  14. data/lib/switchman/active_record/base.rb +13 -11
  15. data/lib/switchman/active_record/batches.rb +2 -0
  16. data/lib/switchman/active_record/calculations.rb +2 -0
  17. data/lib/switchman/active_record/connection_handler.rb +8 -6
  18. data/lib/switchman/active_record/connection_pool.rb +2 -0
  19. data/lib/switchman/active_record/finder_methods.rb +2 -0
  20. data/lib/switchman/active_record/log_subscriber.rb +2 -0
  21. data/lib/switchman/active_record/migration.rb +3 -1
  22. data/lib/switchman/active_record/model_schema.rb +2 -0
  23. data/lib/switchman/active_record/persistence.rb +3 -1
  24. data/lib/switchman/active_record/postgresql_adapter.rb +3 -1
  25. data/lib/switchman/active_record/predicate_builder.rb +2 -0
  26. data/lib/switchman/active_record/query_cache.rb +2 -0
  27. data/lib/switchman/active_record/query_methods.rb +121 -72
  28. data/lib/switchman/active_record/reflection.rb +2 -0
  29. data/lib/switchman/active_record/relation.rb +7 -5
  30. data/lib/switchman/active_record/spawn_methods.rb +2 -0
  31. data/lib/switchman/active_record/statement_cache.rb +3 -1
  32. data/lib/switchman/active_record/table_definition.rb +4 -2
  33. data/lib/switchman/active_record/type_caster.rb +2 -0
  34. data/lib/switchman/active_record/where_clause_factory.rb +2 -0
  35. data/lib/switchman/active_support/cache.rb +4 -2
  36. data/lib/switchman/arel.rb +2 -0
  37. data/lib/switchman/call_super.rb +2 -0
  38. data/lib/switchman/connection_pool_proxy.rb +13 -11
  39. data/lib/switchman/database_server.rb +18 -16
  40. data/lib/switchman/default_shard.rb +2 -0
  41. data/lib/switchman/engine.rb +10 -8
  42. data/lib/switchman/environment.rb +2 -0
  43. data/lib/switchman/errors.rb +2 -0
  44. data/lib/switchman/{shackles.rb → guard_rail.rb} +6 -4
  45. data/lib/switchman/{shackles → guard_rail}/relation.rb +7 -5
  46. data/lib/switchman/open4.rb +2 -0
  47. data/lib/switchman/r_spec_helper.rb +7 -5
  48. data/lib/switchman/rails.rb +2 -0
  49. data/lib/switchman/schema_cache.rb +2 -0
  50. data/lib/switchman/sharded_instrumenter.rb +3 -1
  51. data/lib/switchman/standard_error.rb +2 -0
  52. data/lib/switchman/test_helper.rb +5 -3
  53. data/lib/switchman/version.rb +3 -1
  54. data/lib/tasks/switchman.rake +3 -3
  55. metadata +30 -16
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Switchman::Rails
2
4
  module ClassMethods
3
5
  def self.prepended(klass)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Switchman
2
4
  class SchemaCache < ::ActiveRecord::ConnectionAdapters::SchemaCache
3
5
  delegate :connection, to: :pool
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Switchman
2
4
  class ShardedInstrumenter < ::SimpleDelegator
3
5
  def initialize(instrumenter, shard_host)
@@ -14,7 +16,7 @@ module Switchman
14
16
  payload[:shard] = {
15
17
  database_server_id: shard.database_server.id,
16
18
  id: shard.id,
17
- env: shard.database_server.shackles_environment
19
+ env: shard.database_server.guard_rail_environment
18
20
  }
19
21
  end
20
22
  super name, payload
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Switchman
2
4
  module StandardError
3
5
  def initialize(*args)
@@ -1,10 +1,12 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Switchman
2
4
  module TestHelper
3
5
  class << self
4
6
  def recreate_persistent_test_shards(dont_create: false)
5
7
  # recreate the default shard (it got buhleted)
6
- ::Shackles.activate(:deploy) { Switchman.cache.clear }
7
- if Shard.default(true).is_a?(DefaultShard)
8
+ ::GuardRail.activate(:deploy) { Switchman.cache.clear }
9
+ if Shard.default(reload: true).is_a?(DefaultShard)
8
10
  begin
9
11
  Shard.create!(default: true)
10
12
  rescue
@@ -12,7 +14,7 @@ module Switchman
12
14
  # database doesn't exist yet, presumably cause we're creating it right now
13
15
  return [nil, nil]
14
16
  end
15
- Shard.default(true)
17
+ Shard.default(reload: true)
16
18
  end
17
19
 
18
20
  # can't auto-create a new shard on the default shard's db server if the
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Switchman
2
- VERSION = "1.16.0"
4
+ VERSION = "2.0.5"
3
5
  end
@@ -64,8 +64,8 @@ module Switchman
64
64
  TestHelper.recreate_persistent_test_shards(dont_create: true)
65
65
  end
66
66
 
67
- ::Shackles.activate(:deploy) do
68
- Shard.default.database_server.unshackle do
67
+ ::GuardRail.activate(:deploy) do
68
+ Shard.default.database_server.unguard do
69
69
  begin
70
70
  categories = categories.call if categories.respond_to?(:call)
71
71
  Shard.with_each_shard(scope, categories, options) do
@@ -83,7 +83,7 @@ module Switchman
83
83
 
84
84
  ::ActiveRecord::Base.configurations = new_configs
85
85
  end
86
- shard.database_server.unshackle do
86
+ shard.database_server.unguard do
87
87
  old_actions.each { |action| action.call(*task_args) }
88
88
  end
89
89
  nil
metadata CHANGED
@@ -1,16 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: switchman
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.16.0
4
+ version: 2.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cody Cutrer
8
8
  - James Williams
9
9
  - Jacob Fugal
10
- autorequire:
10
+ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2020-09-15 00:00:00.000000000 Z
13
+ date: 2021-03-02 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: railties
@@ -53,19 +53,19 @@ dependencies:
53
53
  - !ruby/object:Gem::Version
54
54
  version: '6.1'
55
55
  - !ruby/object:Gem::Dependency
56
- name: shackles
56
+ name: guardrail
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 1.4.2
61
+ version: 2.0.0
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 1.4.2
68
+ version: 2.0.0
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: open4
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -140,16 +140,30 @@ dependencies:
140
140
  name: rspec-rails
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
- - - '='
143
+ - - "~>"
144
144
  - !ruby/object:Gem::Version
145
- version: 3.5.2
145
+ version: '3.5'
146
146
  type: :development
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
- - - '='
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: '3.5'
153
+ - !ruby/object:Gem::Dependency
154
+ name: rspec-mocks
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - "~>"
158
+ - !ruby/object:Gem::Version
159
+ version: '3.5'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - "~>"
151
165
  - !ruby/object:Gem::Version
152
- version: 3.5.2
166
+ version: '3.5'
153
167
  - !ruby/object:Gem::Dependency
154
168
  name: simplecov
155
169
  requirement: !ruby/object:Gem::Requirement
@@ -228,12 +242,12 @@ files:
228
242
  - lib/switchman/engine.rb
229
243
  - lib/switchman/environment.rb
230
244
  - lib/switchman/errors.rb
245
+ - lib/switchman/guard_rail.rb
246
+ - lib/switchman/guard_rail/relation.rb
231
247
  - lib/switchman/open4.rb
232
248
  - lib/switchman/r_spec_helper.rb
233
249
  - lib/switchman/rails.rb
234
250
  - lib/switchman/schema_cache.rb
235
- - lib/switchman/shackles.rb
236
- - lib/switchman/shackles/relation.rb
237
251
  - lib/switchman/sharded_instrumenter.rb
238
252
  - lib/switchman/standard_error.rb
239
253
  - lib/switchman/test_helper.rb
@@ -243,7 +257,7 @@ homepage: http://www.instructure.com/
243
257
  licenses:
244
258
  - MIT
245
259
  metadata: {}
246
- post_install_message:
260
+ post_install_message:
247
261
  rdoc_options: []
248
262
  require_paths:
249
263
  - lib
@@ -251,7 +265,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
251
265
  requirements:
252
266
  - - ">="
253
267
  - !ruby/object:Gem::Version
254
- version: '2.4'
268
+ version: '2.5'
255
269
  required_rubygems_version: !ruby/object:Gem::Requirement
256
270
  requirements:
257
271
  - - ">="
@@ -259,7 +273,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
259
273
  version: '0'
260
274
  requirements: []
261
275
  rubygems_version: 3.0.3
262
- signing_key:
276
+ signing_key:
263
277
  specification_version: 4
264
- summary: Rails 4 sharding magic
278
+ summary: Rails sharding magic
265
279
  test_files: []