Class: PgEasyReplicate::CLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/pg_easy_replicate/cli.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.exit_on_failure?Boolean

Returns:

  • (Boolean)


127
128
129
# File 'lib/pg_easy_replicate/cli.rb', line 127

def self.exit_on_failure?
  true
end

Instance Method Details

#bootstrapObject



33
34
35
# File 'lib/pg_easy_replicate/cli.rb', line 33

def bootstrap
  PgEasyReplicate.bootstrap(options)
end

#cleanupObject



50
51
52
# File 'lib/pg_easy_replicate/cli.rb', line 50

def cleanup
  PgEasyReplicate.cleanup(options)
end

#config_checkObject



15
16
17
18
19
20
21
# File 'lib/pg_easy_replicate/cli.rb', line 15

def config_check
  PgEasyReplicate.assert_config(
    special_user_role: options[:special_user_role],
  )

  puts "✅ Config is looking good."
end

#start_syncObject



73
74
75
# File 'lib/pg_easy_replicate/cli.rb', line 73

def start_sync
  PgEasyReplicate::Orchestrate.start_sync(options)
end

#statsObject



114
115
116
117
118
119
120
# File 'lib/pg_easy_replicate/cli.rb', line 114

def stats
  if options[:watch]
    PgEasyReplicate::Stats.follow(options[:group_name])
  else
    PgEasyReplicate::Stats.print(options[:group_name])
  end
end

#stop_syncObject



83
84
85
# File 'lib/pg_easy_replicate/cli.rb', line 83

def stop_sync
  PgEasyReplicate::Orchestrate.stop_sync(group_name: options[:group_name])
end

#switchoverObject

method_option :bi_directional,

aliases: "-b",
desc:
  "Setup replication from target database to source database"


101
102
103
104
105
106
# File 'lib/pg_easy_replicate/cli.rb', line 101

def switchover
  PgEasyReplicate::Orchestrate.switchover(
    group_name: options[:group_name],
    lag_delta_size: options[:lag_delta_size],
  )
end

#versionObject



123
124
125
# File 'lib/pg_easy_replicate/cli.rb', line 123

def version
  puts PgEasyReplicate::VERSION
end