Class: Pgai::CloneManager

Inherits:
Object
  • Object
show all
Defined in:
lib/pgai/clone_manager.rb

Constant Summary collapse

HOSTNAME =
"127.0.0.1"

Instance Method Summary collapse

Constructor Details

#initialize(environment, config:) ⇒ CloneManager

Returns a new instance of CloneManager.



9
10
11
12
13
14
# File 'lib/pgai/clone_manager.rb', line 9

def initialize(environment, config:)
  @environment = environment
  @config = config
  @port_forward = PortForward.new(config: config, hostname: HOSTNAME)
  @dblab = Dblab.new(config: config, hostname: HOSTNAME)
end

Instance Method Details

#cleanupObject



22
23
24
25
26
27
28
29
# File 'lib/pgai/clone_manager.rb', line 22

def cleanup
  configure_enviroment
  return unless find_raw_clone

  dblab.destroy_clone(id: clone_id)
  config.remove_clone(clone_id)
  port_forward.stop
end

#connectObject



16
17
18
19
20
# File 'lib/pgai/clone_manager.rb', line 16

def connect
  configure_enviroment

  psql find_or_create_clone
end

#infoObject



31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/pgai/clone_manager.rb', line 31

def info
  configure_enviroment

  clone = find_clone
  return {} unless clone

  {
    connection_string: clone.connection_string,
    created_at: clone.created_at,
    data_state_at: clone.data_state_at
  }
end