Class: ManageIQ::PostgresHaAdmin::LogicalReplicationConfigHandler

Inherits:
ConfigHandler
  • Object
show all
Defined in:
lib/manageiq/postgres_ha_admin/config_handler/logical_replication_config_handler.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from ConfigHandler

#after_failover, #before_failover, #do_after_failover, #do_before_failover

Constructor Details

#initialize(options = {}) ⇒ LogicalReplicationConfigHandler

Returns a new instance of LogicalReplicationConfigHandler.



9
10
11
12
# File 'lib/manageiq/postgres_ha_admin/config_handler/logical_replication_config_handler.rb', line 9

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

Instance Attribute Details

#conn_infoObject (readonly)

Returns the value of attribute conn_info.



7
8
9
# File 'lib/manageiq/postgres_ha_admin/config_handler/logical_replication_config_handler.rb', line 7

def conn_info
  @conn_info
end

#subscriptionObject (readonly)

Returns the value of attribute subscription.



7
8
9
# File 'lib/manageiq/postgres_ha_admin/config_handler/logical_replication_config_handler.rb', line 7

def subscription
  @subscription
end

Instance Method Details

#nameObject



14
15
16
# File 'lib/manageiq/postgres_ha_admin/config_handler/logical_replication_config_handler.rb', line 14

def name
  "Logical Replication subscription #{subscription} Config Handler"
end

#readObject



18
19
20
21
22
23
24
25
26
# File 'lib/manageiq/postgres_ha_admin/config_handler/logical_replication_config_handler.rb', line 18

def read
  conn = PG::Connection.open(@conn_info)
  dsn = conn.exec_params(<<~SQL, [@subscription]).first["subconninfo"]
    SELECT subconninfo
    FROM pg_subscription
    WHERE subname = $1
  SQL
  PG::DSNParser.new.parse(dsn)
end

#write(_params) ⇒ Object



28
29
30
31
# File 'lib/manageiq/postgres_ha_admin/config_handler/logical_replication_config_handler.rb', line 28

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