Class: ManageIQ::PostgresHaAdmin::PglogicalConfigHandler

Inherits:
ConfigHandler
  • Object
show all
Defined in:
lib/manageiq/postgres_ha_admin/config_handler/pglogical_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 = {}) ⇒ PglogicalConfigHandler

Returns a new instance of PglogicalConfigHandler.



9
10
11
12
# File 'lib/manageiq/postgres_ha_admin/config_handler/pglogical_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/pglogical_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/pglogical_config_handler.rb', line 7

def subscription
  @subscription
end

Instance Method Details

#nameObject



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

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

#readObject



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

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

#write(_params) ⇒ Object



30
31
32
33
# File 'lib/manageiq/postgres_ha_admin/config_handler/pglogical_config_handler.rb', line 30

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