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)


170
171
172
# File 'lib/pg_easy_replicate/cli.rb', line 170

def self.exit_on_failure?
  true
end

Instance Method Details

#bootstrapObject



59
60
61
# File 'lib/pg_easy_replicate/cli.rb', line 59

def bootstrap
  PgEasyReplicate.bootstrap(options)
end

#cleanupObject



76
77
78
# File 'lib/pg_easy_replicate/cli.rb', line 76

def cleanup
  PgEasyReplicate.cleanup(options)
end

#config_checkObject



33
34
35
36
37
38
39
40
41
42
43
# File 'lib/pg_easy_replicate/cli.rb', line 33

def config_check
  PgEasyReplicate.assert_config(
    special_user_role: options[:special_user_role],
    copy_schema: options[:copy_schema],
    tables: options[:tables],
    exclude_tables: options[:exclude_tables],
    schema_name: options[:schema_name],
  )

  puts "✅ Config is looking good."
end

#start_syncObject



111
112
113
# File 'lib/pg_easy_replicate/cli.rb', line 111

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

#statsObject



157
158
159
160
161
162
163
# File 'lib/pg_easy_replicate/cli.rb', line 157

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

#stop_syncObject



121
122
123
# File 'lib/pg_easy_replicate/cli.rb', line 121

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"


143
144
145
146
147
148
149
# File 'lib/pg_easy_replicate/cli.rb', line 143

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

#versionObject



166
167
168
# File 'lib/pg_easy_replicate/cli.rb', line 166

def version
  puts PgEasyReplicate::VERSION
end