Sha256: 74e8eb4624562c082175ff5b6d030efd21bea442014ce7108adb858f814b1422

Contents?: true

Size: 919 Bytes

Versions: 7

Compression:

Stored size: 919 Bytes

Contents

require 'pg'
require 'pg/dsn_parser'

module ManageIQ
module PostgresHaAdmin
  class PglogicalConfigHandler < ConfigHandler
    attr_reader :subscription, :conn_info

    def initialize(options = {})
      @subscription = options[:subscription]
      @conn_info    = options[:conn_info]
    end

    def name
      "pglogical subscription #{subscription} Config Handler"
    end

    def read
      conn = PG::Connection.open(@conn_info)
      dsn = conn.exec_params(<<~SQL, [@subscription]).first["if_dsn"]
        SELECT if_dsn
        FROM pglogical.subscription s
        JOIN pglogical.node_interface i
          ON s.sub_origin_if = i.if_id
        WHERE s.sub_name = $1
      SQL
      PG::DSNParser.new.parse(dsn)
    end

    def write(_params)
      # Nothing to do here as the expectation is that the user will 
      # remove and re-add the subscription in the after failover callback
    end
  end
end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
manageiq-postgres_ha_admin-3.1.4 lib/manageiq/postgres_ha_admin/config_handler/pglogical_config_handler.rb
manageiq-postgres_ha_admin-3.1.3 lib/manageiq/postgres_ha_admin/config_handler/pglogical_config_handler.rb
manageiq-postgres_ha_admin-3.1.2 lib/manageiq/postgres_ha_admin/config_handler/pglogical_config_handler.rb
manageiq-postgres_ha_admin-3.1.1 lib/manageiq/postgres_ha_admin/config_handler/pglogical_config_handler.rb
manageiq-postgres_ha_admin-3.1.0 lib/manageiq/postgres_ha_admin/config_handler/pglogical_config_handler.rb
manageiq-postgres_ha_admin-3.0.1 lib/manageiq/postgres_ha_admin/config_handler/pglogical_config_handler.rb
manageiq-postgres_ha_admin-3.0.0 lib/manageiq/postgres_ha_admin/config_handler/pglogical_config_handler.rb