Class: OnlineMigrations::BackgroundDataMigrations::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/online_migrations/background_data_migrations/config.rb

Overview

Class representing configuration options for data migrations.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



51
52
53
54
55
56
57
58
59
# File 'lib/online_migrations/background_data_migrations/config.rb', line 51

def initialize
  @migrations_path = "lib"
  @migrations_module = "OnlineMigrations::DataMigrations"
  @max_attempts = 5
  @stuck_timeout = 5.minutes
  @iteration_pause = 0.seconds
  @error_handler = ->(error, errored_migration) {}
  @job = "OnlineMigrations::BackgroundDataMigrations::MigrationJob"
end

Instance Attribute Details

#error_handlerProc

The callback to perform when an error occurs during the data migration.

Examples:

OnlineMigrations.config.background_migrations.error_handler = ->(error, errored_migration) do
  Bugsnag.notify(error) do |notification|
    notification.(:background_migration, { name: errored_migration.migration_name })
  end
end

Returns:

  • (Proc)


43
44
45
# File 'lib/online_migrations/background_data_migrations/config.rb', line 43

def error_handler
  @error_handler
end

#iteration_pauseInteger

The pause interval between each data migration’s ‘process` method execution (in seconds).

Returns:

  • (Integer)

    defaults to 0



30
31
32
# File 'lib/online_migrations/background_data_migrations/config.rb', line 30

def iteration_pause
  @iteration_pause
end

#jobString

The name of the sidekiq job to be used to perform data migrations.

Returns:

  • (String)

    defaults to “OnlineMigrations::BackgroundDataMigrations::MigrationJob”



49
50
51
# File 'lib/online_migrations/background_data_migrations/config.rb', line 49

def job
  @job
end

#max_attemptsInteger

Maximum number of run attempts.

When attempts are exhausted, the data migration is marked as failed.

Returns:

  • (Integer)

    defaults to 5



19
20
21
# File 'lib/online_migrations/background_data_migrations/config.rb', line 19

def max_attempts
  @max_attempts
end

#migrations_moduleString

The module in which data migrations will be placed.

Returns:

  • (String)

    defaults to “OnlineMigrations::DataMigrations”



13
14
15
# File 'lib/online_migrations/background_data_migrations/config.rb', line 13

def migrations_module
  @migrations_module
end

#migrations_pathString

The path where generated data migrations will be placed.

Returns:

  • (String)

    defaults to “lib”



9
10
11
# File 'lib/online_migrations/background_data_migrations/config.rb', line 9

def migrations_path
  @migrations_path
end

#stuck_timeoutInteger

The number of seconds that must pass before the cancelling or pausing data migration is considered stuck.

Returns:

  • (Integer)

    defaults to 5 minutes



25
26
27
# File 'lib/online_migrations/background_data_migrations/config.rb', line 25

def stuck_timeout
  @stuck_timeout
end