Module: PartitionGardener::MaintenanceBackend
- Defined in:
- lib/partition_gardener/maintenance_backend.rb
Defined Under Namespace
Classes: ValidationError
Constant Summary collapse
- GARDENER =
:gardener- PG_PARTMAN =
:pg_partman- HYBRID_LAYOUT_ONLY =
:hybrid_layout_only
Class Method Summary collapse
- .gardener_owned?(config) ⇒ Boolean
- .hybrid?(config) ⇒ Boolean
- .normalize(backend) ⇒ Object
- .partman_parent_configured?(table_name) ⇒ Boolean
- .skipped?(config) ⇒ Boolean
- .validate!(config) ⇒ Object
- .validation_messages(config) ⇒ Object
Class Method Details
.gardener_owned?(config) ⇒ Boolean
15 16 17 |
# File 'lib/partition_gardener/maintenance_backend.rb', line 15 def gardener_owned?(config) normalize(config[:maintenance_backend]) != PG_PARTMAN end |
.hybrid?(config) ⇒ Boolean
23 24 25 |
# File 'lib/partition_gardener/maintenance_backend.rb', line 23 def hybrid?(config) normalize(config[:maintenance_backend]) == HYBRID_LAYOUT_ONLY end |
.normalize(backend) ⇒ Object
11 12 13 |
# File 'lib/partition_gardener/maintenance_backend.rb', line 11 def normalize(backend) backend&.to_sym || GARDENER end |
.partman_parent_configured?(table_name) ⇒ Boolean
27 28 29 30 31 |
# File 'lib/partition_gardener/maintenance_backend.rb', line 27 def partman_parent_configured?(table_name) Connection.partman_parent_configured?(table_name) rescue false end |
.skipped?(config) ⇒ Boolean
19 20 21 |
# File 'lib/partition_gardener/maintenance_backend.rb', line 19 def skipped?(config) normalize(config[:maintenance_backend]) == PG_PARTMAN end |
.validate!(config) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/partition_gardener/maintenance_backend.rb', line 33 def validate!(config) violations = (config) return if violations.empty? violations.each do || if PartitionGardener.configuration.strict_maintenance_backend_validation raise ValidationError, end PartitionGardener.configuration.notify( "[PartitionGardener] #{}", context: { table_name: config[:table_name], maintenance_backend: normalize(config[:maintenance_backend]) } ) end end |
.validation_messages(config) ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/partition_gardener/maintenance_backend.rb', line 52 def (config) backend = normalize(config[:maintenance_backend]) table_name = config[:table_name] partman_row = partman_parent_configured?(table_name) = [] if backend == PG_PARTMAN && !partman_row << "#{table_name} maintenance_backend is pg_partman but partman.part_config has no row" end if backend == GARDENER && partman_row << "#{table_name} is registered for gardener but partman.part_config also lists this parent; pick one maintainer" end if hybrid?(config) && !partman_row << "#{table_name} hybrid_layout_only expects partman premake on the same parent" end end |